/* ══════════════════════════════════════════════════════════════════════
   base.css — the foundation every other stylesheet builds on:
   fonts, reset, theme variables (light + dark), body/typography defaults,
   form inputs, buttons, icons, and the keyframe animations several
   components reuse. Load this FIRST.

   Design: minimal, with a different accent per mode.
     Light mode — neutral white and grey (no warm tint), deep green for
       buttons/tabs/progress and marigold for highlights (profile IDs,
       favourite stars, score badges).
     Dark mode  — warm charcoal with the deep wine accent.
   Everything colour-related lives in the two blocks below: change a value
   there and it updates that mode everywhere (buttons, tabs, badges,
   charts, the login page).
   ══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&family=Newsreader:opsz,wght@6..72,500;6..72,600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Light mode (default) ── */
:root {
  --font-sans:  'Geist', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-mono:  'Geist Mono', Consolas, 'SF Mono', monospace;

  --bg:          #F7F8F8;
  --surface:     #FFFFFF;
  --surface-2:   #F2F3F3;
  --border:      #E4E5E6;
  --border-strong:#CDCFD0;
  --text:        #1F2221;
  --text-muted:  #707573;
  --text-label:  #4C504F;
  --input-bg:    #FFFFFF;
  --stat-bg:     #F2F3F3;
  --stat-border: #E8E9EA;
  --panel-shadow: 0 1px 2px rgba(20,25,23,0.04);
  --hover-shadow: 0 4px 14px rgba(20,25,23,0.06);
  --log-bg:      #F2F3F3;
  --log-text:    #353937;
  --progress-bg: #E8E9EA;

  /* Accent: deep green (buttons, active tab, progress, focus ring) */
  --accent:      #2F6B4F;
  --accent-dark: #245540;
  --accent-soft: #EBF2EE;
  --accent-ring: rgba(47,107,79,0.20);
  /* Highlight: marigold (profile IDs, favourite stars, score badges) */
  --highlight:   #B8862B;
  --gold:        #B8862B;

  /* Chart colours (donuts + bars on the Summary dashboard) */
  --chart-1: #2F6B4F; --chart-2: #B8862B; --chart-3: #6E9477; --chart-4: #4F7C8A;
  --chart-5: #A8763F; --chart-6: #7E7C93; --chart-7: #A6A8A6;

  /* Status colours (background / text) */
  --ok-bg:   #E9F1EA; --ok-text:   #2F6B3A;
  --bad-bg:  #FAECEA; --bad-text:  #9F3A2C;
  --info-bg: #E9EFF4; --info-text: #2B5A79;
  --warn-bg: #FAF2DC; --warn-text: #8A6417;
  --idle-bg: #EFF0F0; --idle-text: #6B706E;

  /* Kept for backwards compatibility (login page used these) */
  --header-from: var(--accent);
  --header-to:   var(--accent-dark);

  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* z-index scale */
  --z-dropdown: 60;
  --z-header:   50;
  --z-modal:    1000;
  --z-toast:    1100;
}

/* ── Dark mode (warm charcoal) ── */
body.dark {
  --bg:          #161412;
  --surface:     #1E1B19;
  --surface-2:   #25221F;
  --border:      #34302C;
  --border-strong:#46403A;
  --text:        #ECE7E1;
  --text-muted:  #9A928A;
  --text-label:  #BDB5AC;
  --input-bg:    #191715;
  --stat-bg:     #221F1C;
  --stat-border: #34302C;
  --panel-shadow: none;
  --hover-shadow: 0 4px 14px rgba(0,0,0,0.25);
  --log-bg:      #141210;
  --log-text:    #D9CFC3;
  --progress-bg: #2E2A26;

  /* Accent: deep wine */
  --accent:      #D38A93;
  --accent-dark: #A8414F;
  --accent-soft: #33221F;
  --accent-ring: rgba(211,138,147,0.25);
  /* Highlight: the same wine family, so IDs and stars stay warm here */
  --highlight:   #D38A93;
  --gold:        #D1A955;

  /* Chart colours — the warm wine family in this mode */
  --chart-1: #D38A93; --chart-2: #D1A955; --chart-3: #8FB394; --chart-4: #7FA3BF;
  --chart-5: #C4906A; --chart-6: #A399B5; --chart-7: #9A958E;

  --ok-bg:   #1F2C21; --ok-text:   #9CCB9F;
  --bad-bg:  #3A2121; --bad-text:  #EFA2A0;
  --info-bg: #1B2733; --info-text: #9CC4E4;
  --warn-bg: #352C18; --warn-text: #E4C57A;
  --idle-bg: #2A2724; --idle-text: #A59D95;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}

::selection { background: var(--accent-soft); color: var(--text); }

label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-label);
  margin-bottom: 4px;
  margin-top: 12px;
  font-weight: 500;
}

input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.86rem;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.25s;
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 0.8; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* Search boxes get a small magnifier drawn in CSS (no emoji) */
#search_query, #sl_search {
  padding-left: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237A736C' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m20 20-4.2-4.2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 14px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:focus-visible, button:focus-visible, a:focus-visible, .session-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary              { background: var(--accent); color: #fff; }
body.dark .btn-primary    { background: var(--accent-dark); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
body.dark .btn-primary:hover:not(:disabled) { background: #943845; }

.btn-secondary            { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); }

.btn-green                { background: var(--ok-text); color: #fff; }
.btn-green:hover          { filter: brightness(0.92); }
body.dark .btn-green      { background: #3F7A44; }

.btn-danger               { background: var(--surface); color: var(--bad-text); border-color: var(--border); }
.btn-danger:hover         { background: var(--bad-bg); border-color: transparent; }
.btn-warn                 { background: var(--surface); color: var(--warn-text); border-color: var(--border); }
.btn-warn:hover           { background: var(--warn-bg); border-color: transparent; }
.btn-ghost                { background: transparent; color: var(--text-muted); }
.btn-ghost:hover          { color: var(--text); background: var(--surface-2); }
.btn-sm                   { font-size: 0.78rem; padding: 6px 11px; }
.btn-lg                   { font-size: 0.92rem; padding: 12px 18px; }
.btn-block                { width: 100%; }

/* ── Icons (inline SVG sprite in index.html) ── */
.i {
  width: 1.05em; height: 1.05em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.15em;
}

/* Visually hidden but still read by screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Toast (created by showToast() in utils.js) ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--text);
  color: var(--bg);
  font-size: 0.84rem;
  line-height: 1.45;
  padding: 10px 18px;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(40,25,20,0.12);
  z-index: var(--z-toast);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

/* ── Shared animations (modals, status dots, cards) ── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity:0; } to { transform: translateY(0); opacity:1; } }
@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
