/**
 * base.css
 * D&D 5e Initiative Tracker — Shared variables, themes, layout, buttons
 * Version: 1.1
 * Date: 2026-10-08
 * v1.1 (app v1.2): Night theme, dropdown menus, phone nav ☰, version label.
 */
/* ── CSS Custom Properties ──────────────────────────────────────────────────── */
:root {
  --bg-primary:   #f7f7f7;
  --bg-secondary: #eeeeee;
  --bg-card:      #ffffff;
  --bg-info:      #E6F1FB;
  --text-primary:   #1a1a1a;
  --text-secondary: #666666;
  --text-muted:     #999999;
  --border:         rgba(0,0,0,0.13);
  --border-md:      rgba(0,0,0,0.22);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font: system-ui, -apple-system, sans-serif;
  --font-mono: 'Courier New', monospace;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.12);

  /* Theme-controlled tokens */
  --nav-bg:           var(--bg-card);
  --nav-border:       var(--border-md);
  --nav-text:         var(--text-secondary);
  --nav-brand:        var(--text-primary);
  --nav-active-bg:    var(--bg-info);
  --nav-active-color: #185FA5;
  --nav-hover-bg:     var(--bg-secondary);
  --accent:           #185FA5;
  --accent-hover-bg:  #E6F1FB;
  --accent-2:         #3B6D11;
  --accent-2-hover:   #EAF3DE;
  --page-bg:          var(--bg-primary);
}

/* ── Theme: D&D Red ─────────────────────────────────────────────────────────── */
[data-theme="red"] {
  --bg-primary:   #f7f4f0;
  --bg-secondary: #efe9e1;
  --bg-card:      #ffffff;
  --bg-info:      #fdf0f0;
  --text-primary:   #1a0a0a;
  --text-secondary: #6b5040;
  --text-muted:     #a08070;
  --border:         rgba(100,50,20,0.13);
  --border-md:      rgba(100,50,20,0.22);
  --nav-bg:           #1a0a0a;
  --nav-border:       #1a0a0a;
  --nav-text:         #c9b99a;
  --nav-brand:        #f7f4f0;
  --nav-active-bg:    #C22B28;
  --nav-active-color: #ffffff;
  --nav-hover-bg:     rgba(255,255,255,0.08);
  --accent:           #C22B28;
  --accent-hover-bg:  #fdf0f0;
  --accent-2:         #8B6914;
  --accent-2-hover:   #fdf5e4;
}

/* ── Theme: Forest ──────────────────────────────────────────────────────────── */
[data-theme="forest"] {
  --bg-primary:   #f2f5f0;
  --bg-secondary: #e6ece2;
  --bg-card:      #ffffff;
  --bg-info:      #eaf3de;
  --text-primary:   #0d1a0a;
  --text-secondary: #4a6040;
  --text-muted:     #7a9070;
  --border:         rgba(20,60,10,0.13);
  --border-md:      rgba(20,60,10,0.22);
  --nav-bg:           #0d2010;
  --nav-border:       #0d2010;
  --nav-text:         #a8c890;
  --nav-brand:        #e8f4e0;
  --nav-active-bg:    #3B6D11;
  --nav-active-color: #ffffff;
  --nav-hover-bg:     rgba(255,255,255,0.08);
  --accent:           #3B6D11;
  --accent-hover-bg:  #eaf3de;
  --accent-2:         #6B5010;
  --accent-2-hover:   #f5ecd8;
}

/* ── Theme: Arcane ──────────────────────────────────────────────────────────── */
[data-theme="arcane"] {
  --bg-primary:   #f3f1f8;
  --bg-secondary: #e8e4f4;
  --bg-card:      #ffffff;
  --bg-info:      #eeedfe;
  --text-primary:   #0e0a1a;
  --text-secondary: #50407a;
  --text-muted:     #8070aa;
  --border:         rgba(60,30,120,0.13);
  --border-md:      rgba(60,30,120,0.22);
  --nav-bg:           #0e0a1a;
  --nav-border:       #0e0a1a;
  --nav-text:         #a898d8;
  --nav-brand:        #f0ecfc;
  --nav-active-bg:    #534AB7;
  --nav-active-color: #ffffff;
  --nav-hover-bg:     rgba(255,255,255,0.08);
  --accent:           #534AB7;
  --accent-hover-bg:  #eeedfe;
  --accent-2:         #8B3A6B;
  --accent-2-hover:   #fbeaf4;
}

/* ── Theme: Steel ───────────────────────────────────────────────────────────── */
[data-theme="steel"] {
  --bg-primary:   #f0f3f5;
  --bg-secondary: #e4eaee;
  --bg-card:      #ffffff;
  --bg-info:      #e0f4f2;
  --text-primary:   #080f14;
  --text-secondary: #3a5060;
  --text-muted:     #6a8090;
  --border:         rgba(10,40,60,0.12);
  --border-md:      rgba(10,40,60,0.20);
  --nav-bg:           #0f1923;
  --nav-border:       #0f1923;
  --nav-text:         #7aaabb;
  --nav-brand:        #e8f4f8;
  --nav-active-bg:    #00BFA5;
  --nav-active-color: #ffffff;
  --nav-hover-bg:     rgba(255,255,255,0.07);
  --accent:           #00897B;
  --accent-hover-bg:  #e0f4f2;
  --accent-2:         #1565C0;
  --accent-2-hover:   #e3eefa;
}

/* ── Theme: Shadowfell ──────────────────────────────────────────────────────── */
[data-theme="shadowfell"] {
  --bg-primary:   #f4f4f1;
  --bg-secondary: #e8e8e4;
  --bg-card:      #fafaf8;
  --bg-info:      #edf2e0;
  --text-primary:   #111210;
  --text-secondary: #4a4d3e;
  --text-muted:     #7a7d6e;
  --border:         rgba(30,35,20,0.12);
  --border-md:      rgba(30,35,20,0.20);
  --nav-bg:           #141418;
  --nav-border:       #141418;
  --nav-text:         #8a9070;
  --nav-brand:        #d8ddd0;
  --nav-active-bg:    #5a6e10;
  --nav-active-color: #d8e8a0;
  --nav-hover-bg:     rgba(255,255,255,0.05);
  --accent:           #7CB518;
  --accent-hover-bg:  #edf2e0;
  --accent-2:         #4a5a10;
  --accent-2-hover:   #e8ecd8;
}

/* ── Theme: Feywild ─────────────────────────────────────────────────────────── */
[data-theme="feywild"] {
  --bg-primary:   #fdf8f0;
  --bg-secondary: #f5ecdf;
  --bg-card:      #ffffff;
  --bg-info:      #fce8f4;
  --text-primary:   #1a0820;
  --text-secondary: #6a3060;
  --text-muted:     #a070a0;
  --border:         rgba(100,20,80,0.12);
  --border-md:      rgba(100,20,80,0.22);
  --nav-bg:           #1a0a2e;
  --nav-border:       #1a0a2e;
  --nav-text:         #c890c0;
  --nav-brand:        #fce8fc;
  --nav-active-bg:    #D1228E;
  --nav-active-color: #ffffff;
  --nav-hover-bg:     rgba(255,255,255,0.08);
  --accent:           #D1228E;
  --accent-hover-bg:  #fce8f4;
  --accent-2:         #D4A017;
  --accent-2-hover:   #fdf5dc;
}

/* ── Theme: Inferno ─────────────────────────────────────────────────────────── */
[data-theme="inferno"] {
  --bg-primary:   #f5f0eb;
  --bg-secondary: #ede4da;
  --bg-card:      #ffffff;
  --bg-info:      #fdf0e0;
  --text-primary:   #1a0d00;
  --text-secondary: #6b4020;
  --text-muted:     #a07050;
  --border:         rgba(100,40,0,0.13);
  --border-md:      rgba(100,40,0,0.22);
  --nav-bg:           #1a0c00;
  --nav-border:       #1a0c00;
  --nav-text:         #c8904a;
  --nav-brand:        #fdf0d8;
  --nav-active-bg:    #E05A00;
  --nav-active-color: #ffffff;
  --nav-hover-bg:     rgba(255,255,255,0.07);
  --accent:           #E05A00;
  --accent-hover-bg:  #fdf0e0;
  --accent-2:         #C0391A;
  --accent-2-hover:   #fdeae0;
}

/* ── Theme: Abyss ───────────────────────────────────────────────────────────── */
[data-theme="abyss"] {
  --bg-primary:   #eef2f5;
  --bg-secondary: #e0e8ef;
  --bg-card:      #ffffff;
  --bg-info:      #e0f5f5;
  --text-primary:   #010a14;
  --text-secondary: #1a4060;
  --text-muted:     #4a7090;
  --border:         rgba(0,30,60,0.12);
  --border-md:      rgba(0,30,60,0.20);
  --nav-bg:           #010d1a;
  --nav-border:       #010d1a;
  --nav-text:         #40a8c0;
  --nav-brand:        #d0f0f8;
  --nav-active-bg:    #0090B0;
  --nav-active-color: #ffffff;
  --nav-hover-bg:     rgba(255,255,255,0.06);
  --accent:           #0090B0;
  --accent-hover-bg:  #e0f5f5;
  --accent-2:         #006080;
  --accent-2-hover:   #d0eef5;
}

/* ── Theme: Blood Moon ──────────────────────────────────────────────────────── */
[data-theme="bloodmoon"] {
  --bg-primary:   #f5f0f0;
  --bg-secondary: #ede0e0;
  --bg-card:      #ffffff;
  --bg-info:      #fde8e8;
  --text-primary:   #1a0000;
  --text-secondary: #6b1a1a;
  --text-muted:     #a05050;
  --border:         rgba(100,0,0,0.12);
  --border-md:      rgba(100,0,0,0.22);
  --nav-bg:           #0d0000;
  --nav-border:       #0d0000;
  --nav-text:         #c04040;
  --nav-brand:        #fde8e8;
  --nav-active-bg:    #8B0000;
  --nav-active-color: #fde8e8;
  --nav-hover-bg:     rgba(255,255,255,0.06);
  --accent:           #8B0000;
  --accent-hover-bg:  #fde8e8;
  --accent-2:         #6B0000;
  --accent-2-hover:   #fde0e0;
}

/* ── Theme: Storm ───────────────────────────────────────────────────────────── */
[data-theme="storm"] {
  --bg-primary:   #f0f2f8;
  --bg-secondary: #e4e8f4;
  --bg-card:      #ffffff;
  --bg-info:      #e8ecff;
  --text-primary:   #08101a;
  --text-secondary: #304060;
  --text-muted:     #607090;
  --border:         rgba(20,40,100,0.12);
  --border-md:      rgba(20,40,100,0.20);
  --nav-bg:         #111824;
  --nav-border:     #111824;
  --nav-text:         #6888c0;
  --nav-brand:        #e0e8ff;
  --nav-active-bg:    #3A5FD9;
  --nav-active-color: #ffffff;
  --nav-hover-bg:     rgba(255,255,255,0.07);
  --accent:           #3A5FD9;
  --accent-hover-bg:  #e8ecff;
  --accent-2:         #1A3FA0;
  --accent-2-hover:   #dce4ff;
}


/* ── Theme: Night (true dark — v1.2) ───────────────────────────────────────────
   html[…] beats the phone-only light-mode :root override in tracker.css */
html[data-theme="night"] {
  --bg-primary:   #121418;
  --bg-secondary: #1b1e24;
  --bg-card:      #1f232a;
  --bg-info:      #1c2b40;
  --text-primary:   #e6e8ec;
  --text-secondary: #a7adb8;
  --text-muted:     #737a88;
  --border:         rgba(255,255,255,0.10);
  --border-md:      rgba(255,255,255,0.18);
  --shadow-md:      0 4px 18px rgba(0,0,0,0.5);
  --nav-bg:           #0b0d10;
  --nav-border:       #0b0d10;
  --nav-text:         #9aa3b2;
  --nav-brand:        #e6e8ec;
  --nav-active-bg:    #263652;
  --nav-active-color: #cfe0ff;
  --nav-hover-bg:     rgba(255,255,255,0.06);
  --accent:           #7aa7ff;
  --accent-hover-bg:  #1c2b40;
  --accent-2:         #6fcf7f;
  --accent-2-hover:   #1b3222;
  color-scheme: dark;
}
html[data-theme="night"] a:not(.nav-link):not(.nav-brand):not(.btn) { color: var(--accent); }
html[data-theme="night"] tbody tr.active-turn { background: #233552 !important; }
html[data-theme="night"] .mob-card.active-turn { background: #233552; }
html[data-theme="night"] .btn.danger { color: #ff8a8a; border-color: #b04a4a; }
html[data-theme="night"] .btn.danger:hover { background: #3a1c1c; }
html[data-theme="night"] .btn.amber  { color: #f0b860; border-color: #a0712a; }
html[data-theme="night"] .btn.amber:hover { background: #3a2c14; }
html[data-theme="night"] .player-row td   { color: #ff9eaa; }
html[data-theme="night"] .creature-row td { color: #9cc2ff; }
html[data-theme="night"] input, html[data-theme="night"] select, html[data-theme="night"] textarea {
  background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border-md);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary:   #1a1a1a;
    --bg-secondary: #242424;
    --bg-card:      #2a2a2a;
    --bg-info:      #0c2a45;
    --text-primary:   #e8e8e8;
    --text-secondary: #aaaaaa;
    --text-muted:     #777777;
    --border:         rgba(255,255,255,0.10);
    --border-md:      rgba(255,255,255,0.18);
  }
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
}
a { color: #185FA5; text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: var(--font); font-size: 13px; }

/* ── Top Navigation ─────────────────────────────────────────────────────────── */
.nav {
  background: var(--nav-bg);
  border-bottom: 0.5px solid var(--nav-border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 0;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-size: 16px;
  font-weight: 600;
  color: var(--nav-brand);
  text-decoration: none;
  margin-right: 24px;
  white-space: nowrap;
}
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 2px; flex: 1; }
.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--nav-text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--nav-hover-bg); color: var(--nav-brand); text-decoration: none; }
.nav-link.active { background: var(--nav-active-bg); color: var(--nav-active-color); font-weight: 500; }
.nav-user { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav-user span { font-size: 12px; color: var(--nav-text); }

/* ── Page Layout ────────────────────────────────────────────────────────────── */
.page { padding: 20px 20px 40px; max-width: 1600px; margin: 0 auto; }
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.page-header p  { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-md);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover    { background: var(--bg-secondary); }
.btn:active   { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary { border-color: var(--accent); color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover-bg); }
.btn.success { border-color: var(--accent-2); color: var(--accent-2); }
.btn.success:hover { background: var(--accent-2-hover); }
.btn.danger  { border-color: #A32D2D; color: #A32D2D; }
.btn.danger:hover  { background: #FCEBEB; }
.btn.amber   { border-color: #854F0B; color: #854F0B; }
.btn.amber:hover   { background: #FAEEDA; }
.btn.sm { padding: 3px 8px; font-size: 11px; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.card-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 0.5px solid var(--border);
}
.card-header h2 { font-size: 15px; font-weight: 600; flex: 1; }

/* ── Form elements ──────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 11px; font-weight: 500; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.form-control {
  width: 100%;
  padding: 7px 10px;
  border: 0.5px solid var(--border-md);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: #185FA5; }
.form-control:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 12px; border: 0.5px solid transparent; }
.alert.success { background: #EAF3DE; color: #27500A; border-color: #BEDF9D; }
.alert.error   { background: #FCEBEB; color: #7B1E1E; border-color: #F4C6CA; }
.alert.info    { background: #E6F1FB; color: #0C447C; border-color: #B5D4F4; }
.alert.warning { background: #FAEEDA; color: #633806; border-color: #FAC775; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 600; white-space: nowrap;
}
.badge.blue   { background: #E6F1FB; color: #0C447C; }
.badge.green  { background: #EAF3DE; color: #27500A; }
.badge.amber  { background: #FAEEDA; color: #633806; }
.badge.red    { background: #FCEBEB; color: #7B1E1E; }
.badge.gray   { background: var(--bg-secondary); color: var(--text-secondary); }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border-md);
  padding: 20px;
  width: 440px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-md);
}
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Utility ────────────────────────────────────────────────────────────────── */
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.gap-2      { gap: 6px; }
.gap-3      { gap: 10px; }
.gap-4      { gap: 14px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1     { flex: 1; }
.text-sm    { font-size: 12px; }
.text-xs    { font-size: 11px; }
.text-muted { color: var(--text-secondary); }
.text-right { text-align: right; }
.mt-1       { margin-top: 6px; }
.mt-2       { margin-top: 12px; }
.mt-3       { margin-top: 18px; }
.mb-1       { margin-bottom: 6px; }
.mb-2       { margin-bottom: 12px; }
.hidden     { display: none !important; }
.w-full     { width: 100%; }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.page-footer {
  margin-top: 40px;
  padding-top: 12px;
  border-top: 0.5px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
}

/* ── Dropdown menus (v1.2) ─────────────────────────────────────────────────── */
.menu-wrap { position: relative; display: inline-flex; }
.menu-list {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 400; min-width: 210px;
  background: var(--bg-card); border: 0.5px solid var(--border-md); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: 4px;
}
.menu-wrap.right .menu-list { left: auto; right: 0; }
.menu-wrap.open .menu-list { display: block; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer; padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-primary);
}
.menu-item:hover { background: var(--bg-secondary); }
.menu-item .menu-hint { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.menu-item.danger { color: #A32D2D; }
html[data-theme="night"] .menu-item.danger { color: #ff8a8a; }
.menu-sep { height: 0.5px; background: var(--border); margin: 4px 2px; }

/* ── Version label + phone nav (v1.2) ──────────────────────────────────────── */
.nav-version { font-size: 10px; color: var(--nav-text); opacity: 0.55; margin-right: 2px; }
.nav-burger {
  display: none; margin-left: auto; background: none; border: 0.5px solid var(--nav-text);
  color: var(--nav-text); border-radius: var(--radius-md); font-size: 16px; line-height: 1; padding: 5px 9px; cursor: pointer;
}
@media (max-width: 768px) {
  .nav { flex-wrap: wrap; height: auto; min-height: 48px; padding: 0 12px; }
  .nav-brand { margin-right: 0; line-height: 48px; }
  .nav-burger { display: inline-block; }
  .nav-links, .nav-user { display: none !important; }
  body.nav-open .nav-links {
    display: flex !important; flex: 0 0 100%; flex-direction: column; align-items: stretch; order: 3; padding: 4px 0 8px; gap: 2px;
  }
  body.nav-open .nav-user {
    display: flex !important; flex: 0 0 100%; order: 4; flex-wrap: wrap; gap: 8px;
    margin-left: 0; padding: 8px 0 12px; border-top: 0.5px solid rgba(127,127,127,0.25);
  }
  body.nav-open .nav-link { padding: 10px 12px; font-size: 15px; }
  .card-header { flex-wrap: wrap; }   /* header buttons drop under the title instead of overflowing */
}
