/* ============================================================
   Lift & Shift — shared design system (v1)
   One source of truth for tokens, shell, and components across
   every page (dashboard + auth/utility pages).

   Dark mode is intentionally OPT-IN via [data-theme="dark"] on
   <html> so it never auto-activates before there is an official
   dark palette. When that palette is ready, fill in the values in
   the [data-theme="dark"] block below — nothing else changes.
   ============================================================ */

/* ---------- Tokens (light) ---------- */
:root {
  /* Brand — pulled from weliftandshift.org */
  --brand:          #204080;   /* primary navy */
  --brand-hover:    #1a3360;
  --brand-soft:     #5c84bc;
  --accent:         #2b6cb0;   /* interactive blue (links/focus) */
  --accent-hover:   #234e7d;

  /* Roles */
  --success:        #2f855a;   /* veteran / verified */
  --success-bg:     #eaf5ee;
  --danger:         #b30518;   /* destructive (brand red) */
  --danger-hover:   #8f0413;
  --warning:        #b7791f;

  /* Surfaces */
  --page-bg:        #f4f5f8;
  --surface:        #ffffff;   /* cards */
  --surface-2:      #f7f8fb;   /* subtle fills / inset */
  --header-bg:      #204080;
  --header-fg:      #ffffff;

  /* Text */
  --text:           #1f2a44;
  --text-secondary: #55607a;
  --text-muted:     #8b95ab;
  --on-brand:       #ffffff;

  /* Lines */
  --border:         #e2e6ee;
  --border-strong:  #cbd2e0;

  /* Shape & motion */
  --radius:         8px;
  --radius-lg:      12px;
  --focus:          0 0 0 3px rgba(43, 108, 176, 0.35);
  --shadow-sm:      0 1px 2px rgba(24, 39, 75, 0.06), 0 1px 3px rgba(24, 39, 75, 0.08);
  --shadow-md:      0 4px 16px rgba(24, 39, 75, 0.10);

  /* Layout */
  --rail-w:         224px;
  --header-h:       56px;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Tokens (dark, opt-in via [data-theme="dark"]) ---------- */
:root[data-theme="dark"] {
  --brand:          #2f5296;   /* lifted navy so primary controls read on dark */
  --brand-hover:    #39609f;
  --brand-soft:     #4f74b5;
  --accent:         #6fa8e0;
  --accent-hover:   #8ab9e8;

  --success:        #48bb78;
  --success-bg:     #12291f;
  --danger:         #f2657a;
  --danger-hover:   #e0455d;
  --warning:        #e0a44a;

  --page-bg:        #0f1420;
  --surface:        #182234;
  --surface-2:      #131b2a;
  --header-bg:      #131b2a;
  --header-fg:      #f2f5fb;

  --text:           #e7ecf5;
  --text-secondary: #a9b3c9;
  --text-muted:     #7c869d;
  --on-brand:       #ffffff;

  --border:         #29344d;
  --border-strong:  #3a486a;

  --focus:          0 0 0 3px rgba(111, 168, 224, 0.4);
  --shadow-sm:      none;
  --shadow-md:      0 8px 24px rgba(0, 0, 0, 0.45);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background-color: var(--page-bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--text); font-weight: 600; line-height: 1.25; }
h2.page-title { font-size: 1.5rem; margin: 0 0 1.25rem; }
h3 { font-size: 1.15rem; margin: 1.5rem 0 0.6rem; }
a { color: var(--accent); }
p { line-height: 1.6; }
strong { font-weight: 600; color: var(--text); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }

/* ============================================================
   App shell — header + desktop rail + mobile bottom nav
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--header-bg);
  color: var(--header-fg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  box-shadow: var(--shadow-sm);
}
.app-header .brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--header-fg); }
.app-header .brand img { height: 34px; width: auto; display: block; }
.app-header .brand-name { font-weight: 600; font-size: 1.05rem; letter-spacing: 0.01em; }
.app-header .header-actions { display: flex; align-items: center; gap: 0.75rem; }
.app-header .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-soft); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600;
}

/* Theme toggle (dark mode). Icon swaps via [data-theme] — no JS needed for it. */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: auto; max-width: none; padding: 6px;
  background: none; border: none; border-radius: var(--radius);
  color: inherit; cursor: pointer;
}
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .ic-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: inline; }
.app-header .theme-toggle { color: var(--header-fg); }
.app-header .theme-toggle:hover { background: rgba(255, 255, 255, 0.14); }
.theme-toggle.floating {
  position: fixed; top: 14px; right: 14px; z-index: 300;
  width: 40px; height: 40px;
  background: var(--surface); color: var(--text-secondary);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.theme-toggle.floating:hover { background: var(--surface-2); }

.app-body { display: flex; min-height: calc(100vh - var(--header-h)); }

/* Desktop navigation rail */
.rail {
  width: var(--rail-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rail-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: none;
  padding: 0.7rem 0.9rem;
  border: none;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-ico { width: 1.35rem; height: 1.35rem; flex-shrink: 0; }
.nav-ico use, .nav-ico { stroke: currentColor; }
.rail-item:hover { background: var(--surface-2); color: var(--text); }
.rail-item.active { background: rgba(43, 108, 176, 0.10); color: var(--brand); font-weight: 600; }
:root[data-theme="dark"] .rail-item.active { background: rgba(111, 168, 224, 0.15); color: var(--accent); }

.content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.25rem;
  max-width: 960px;
}

/* Mobile bottom tab bar (hidden on desktop) */
.bottom-nav { display: none; }

/* ============================================================
   Buttons — modern base + compatibility utility classes
   (the app's JS injects buttons using the old class names,
    so they are redefined here rather than removed)
   ============================================================ */
button { font-family: inherit; }
.bg-blue-500, .bg-gray-500, .bg-red-500, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: auto;
  max-width: none;
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: #fff;
  transition: background-color 0.15s ease, transform 0.05s ease;
}
.bg-blue-500, .btn { background-color: var(--brand); }
.bg-blue-500:hover, .hover\:bg-blue-600:hover, .btn:hover { background-color: var(--brand-hover); }
.bg-gray-500 { background-color: #6b7488; }
.bg-gray-500:hover, .hover\:bg-gray-600:hover { background-color: #565e70; }
.bg-red-500 { background-color: var(--danger); }
.bg-red-500:hover, .hover\:bg-red-600:hover { background-color: var(--danger-hover); }
.bg-blue-500:active, .bg-gray-500:active, .bg-red-500:active, .btn:active { transform: translateY(1px); }

/* Secondary (outline) treatment */
.btn-secondary {
  background-color: transparent !important;
  color: var(--brand) !important;
  border: 1px solid var(--border-strong) !important;
  max-width: none !important;
  font-size: 0.9rem !important;
}
.btn-secondary:hover { background-color: var(--surface-2) !important; color: var(--brand-hover) !important; }
:root[data-theme="dark"] .btn-secondary { color: var(--accent) !important; }

/* ---------- Cards / sections ---------- */
.card, .content-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
}
.content-section { margin-bottom: 1.5rem; }
.content-section p { line-height: 1.6; }
.section-spacing { margin-bottom: 2rem; }
.space-y-4 > * { margin-bottom: 1rem; }

/* Stat / field tiles */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin: 0.5rem 0 1rem;
}
.tile {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.tile .tile-label { font-size: 0.78rem; color: var(--text-secondary); margin: 0 0 0.25rem; text-transform: uppercase; letter-spacing: 0.04em; }
.tile .tile-value { font-size: 1rem; margin: 0; word-break: break-word; }

/* Info callout */
.callout {
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.1rem;
  margin: 1.25rem 0;
}
.callout p { margin: 0; font-size: 0.95rem; }
.badge-veteran {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--success-bg); color: var(--success);
  font-size: 0.78rem; font-weight: 600;
  padding: 0.25rem 0.6rem; border-radius: 999px;
}

/* ---------- Forms ---------- */
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.lb-input { max-width: 320px; }

/* ---------- Comparison table ---------- */
.comparison-table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; font-size: 0.9rem; }
.comparison-table th, .comparison-table td { padding: 0.7rem; text-align: left; border-bottom: 1px solid var(--border); }
.comparison-table th { background: var(--surface-2); font-weight: 600; }
.comparison-table tr:hover td { background: var(--surface-2); }
.feature-check { color: var(--success); font-weight: 700; }
.feature-none { color: var(--text-muted); }

/* ---------- Tooltips: tap-friendly (click/focus toggled via [data-open]) ---------- */
.tooltip { position: relative; display: inline-block; cursor: pointer; margin-left: 0.25rem; color: var(--accent); font-weight: 700; font-size: 0.85rem; vertical-align: super; line-height: 1; }
.tooltip::before {
  content: attr(data-tooltip);
  position: absolute; bottom: 135%; left: 50%; transform: translateX(-50%);
  background: #1a202c; color: #fff; padding: 0.5rem 0.7rem; border-radius: var(--radius);
  font-size: 0.8rem; font-weight: 400; line-height: 1.4; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease; z-index: 60; box-shadow: var(--shadow-md);
}
.tooltip:hover::before, .tooltip:focus::before, .tooltip[data-open]::before { opacity: 1; }
.tooltip-wide::before { white-space: normal; width: 220px; }

/* ---------- Modal ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 200; overflow: auto; background: rgba(15, 20, 32, 0.5); padding-top: 8vh; }
.modal-content { background: var(--surface); color: var(--text); margin: 0 auto; padding: 1.5rem; border: 1px solid var(--border); width: 90%; max-width: 500px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.modal-content h2, .modal-content h3 { margin-top: 0; }
.close { color: var(--text-muted); float: right; font-size: 1.6rem; font-weight: 700; line-height: 1; cursor: pointer; }
.close:hover, .close:focus { color: var(--text); }

/* ---------- Toasts ---------- */
#toastContainer { position: fixed; top: calc(var(--header-h) + 12px); right: 16px; z-index: 400; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast { background: #2d3748; color: #fff; padding: 0.9rem 1.1rem; border-radius: var(--radius); box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 0.7rem; min-width: 280px; animation: toastIn 0.25s ease-out; }
.toast.hiding { animation: toastOut 0.25s ease-out forwards; }
@keyframes toastIn { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(400px); opacity: 0; } }
.toast-icon { font-size: 1.3rem; flex-shrink: 0; }
.toast-message { flex: 1; font-size: 0.92rem; line-height: 1.4; }
.toast-close { background: none; border: none; color: rgba(255,255,255,0.75); font-size: 1.4rem; line-height: 1; cursor: pointer; width: auto; max-width: none; padding: 0; flex-shrink: 0; }
.toast-close:hover { color: #fff; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--accent); }
.toast.warning { background: var(--warning); }

/* ---------- Feedback FAB ---------- */
.feedback-fab { position: fixed; bottom: 20px; right: 20px; background: var(--accent); color: #fff; border: none; border-radius: 50%; width: 54px; height: 54px; max-width: none; font-size: 22px; cursor: pointer; box-shadow: var(--shadow-md); z-index: 120; transition: transform 0.15s ease, background-color 0.15s ease; }
.feedback-fab:hover { background: var(--accent-hover); transform: scale(1.06); }
.feedback-modal .modal-content textarea { min-height: 120px; resize: vertical; margin-bottom: 1rem; }
.feedback-modal .modal-content label { display: block; margin-bottom: 0.3rem; font-weight: 500; }
.feedback-modal .modal-content select { margin-bottom: 1rem; }
.feedback-modal-buttons { display: flex; gap: 0.6rem; justify-content: flex-end; }
.btn-feedback-cancel { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-strong); }
.btn-feedback-cancel:hover { background: var(--surface-2); }
.btn-feedback-submit { background: var(--accent); color: #fff; border: none; }
.btn-feedback-submit:hover { background: var(--accent-hover); }
.feedback-modal-buttons button { padding: 0.6rem 1.3rem; border-radius: var(--radius); cursor: pointer; font-size: 0.9rem; max-width: none; }

/* ---------- Welcome banner ---------- */
.welcome-banner { background: var(--brand); color: #fff; padding: 1.25rem 1.4rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); position: fixed; top: calc(var(--header-h) + 16px); left: 50%; transform: translateX(-50%); z-index: 150; max-width: 720px; width: calc(100% - 32px); }
.welcome-banner h2 { margin: 0 0 0.6rem; font-size: 1.3rem; color: #fff; }
.welcome-banner p { margin: 0 0 1rem; line-height: 1.5; font-size: 0.95rem; }
.welcome-banner-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.welcome-banner-actions button, .welcome-banner-actions a { background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.35); padding: 0.5rem 1rem; border-radius: var(--radius); cursor: pointer; text-decoration: none; font-size: 0.88rem; max-width: none; }
.welcome-banner-actions button:hover, .welcome-banner-actions a:hover { background: rgba(255,255,255,0.28); }
.welcome-banner .close-banner { position: absolute; top: 0.8rem; right: 0.9rem; background: none; border: none; color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; width: auto; max-width: none; padding: 0; opacity: 0.85; }
.welcome-banner .close-banner:hover { opacity: 1; }

/* ---------- Workspace list ---------- */
#workspaceList { list-style: none; padding: 0; margin: 0; }
.workspace-item { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.85rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.5rem; background: var(--surface-2); }
.workspace-item a { flex-grow: 1; margin-right: 0.6rem; text-decoration: none; color: var(--accent); }
.workspace-item .delete-icon { cursor: pointer; color: var(--danger); font-weight: 700; }

/* ---------- Utility compatibility layer ---------- */
.hidden { display: none; }
.active { display: block; }
/* Nav items get display from base + mobile media query, so a plain .hidden
   (equal specificity, earlier in source) loses. Force the hide for nav tabs. */
.rail-item.hidden, .bottom-item.hidden { display: none !important; }
.text-white { color: #fff; }
.font-medium { font-weight: 500; }
.text-lg { font-size: 1.1rem; }
.text-2xl { font-size: 1.5rem; font-weight: 600; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.no-border { border: none; }
.no-undln { text-decoration: none; font-size: 0.8rem; }

/* Centered card layout for auth / utility pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 2rem 1.75rem; }
.auth-card .auth-logo { display: block; margin: 0 auto 1.25rem; height: 64px; width: auto; }
/* The logo's darker "FOUNDATION" wordmark disappears on the dark card, so give
   it a soft white halo (drop-shadow follows the PNG's transparency). */
:root[data-theme="dark"] .auth-card .auth-logo {
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.95)) drop-shadow(0 0 3px rgba(255, 255, 255, 0.7));
}
.auth-card h1, .auth-card h2 { text-align: center; margin: 0 0 1.25rem; font-size: 1.4rem; }
.auth-card h3 { text-align: center; }
.auth-card form { width: 100%; }
.auth-card input[type="email"], .auth-card input[type="text"], .auth-card input[type="password"] { margin-bottom: 1rem; }
.auth-card .field { position: relative; margin-bottom: 1rem; }
.auth-card .field input { margin-bottom: 0; }
.auth-card input[type="submit"], .auth-card button[type="submit"] {
  width: 100%; margin-top: 0.5rem;
  background: var(--brand); color: #fff; border: none;
  padding: 0.7rem 1rem; border-radius: var(--radius);
  font: inherit; font-size: 1rem; font-weight: 500; cursor: pointer;
}
.auth-card input[type="submit"]:hover, .auth-card button[type="submit"]:hover { background: var(--brand-hover); }
.auth-card input[type="submit"]:disabled { background: var(--border-strong); cursor: not-allowed; }
.auth-card p { font-size: 0.92rem; color: var(--text-secondary); }
.auth-card a { color: var(--accent); }
.password-toggle { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); cursor: pointer; color: var(--accent); font-size: 0.85rem; user-select: none; }
.error { color: var(--danger); font-size: 0.85rem; display: block; min-height: 1.1rem; }
.success, .success-message { color: var(--success); font-size: 0.9rem; display: block; }
.req-list { list-style: none; padding: 0; margin: 0.25rem 0 1rem; font-size: 0.8rem; }
.valid { color: var(--success); }
.invalid { color: var(--danger); }
.disclaimer-text { font-size: 0.8rem; color: var(--text-muted); }
.acctSpan { text-align: center; max-width: 500px; display: block; margin: 0 auto; }
.cf-turnstile { margin: 0.75rem 0; }
/* Feedback modal buttons (login page) */
.modal-buttons { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1rem; }
.modal-buttons button { padding: 0.6rem 1.3rem; border: none; border-radius: var(--radius); cursor: pointer; font-size: 0.9rem; max-width: none; }
.btn-cancel { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-strong); }
.btn-cancel:hover { background: var(--surface-2); }
.btn-submit { background: var(--accent); color: #fff; }
.btn-submit:hover { background: var(--accent-hover); }

/* ============================================================
   Responsive — mobile first breakpoints
   ============================================================ */
@media (max-width: 767px) {
  .app-body { display: block; }
  .rail { display: none; }
  .content { padding: 1.25rem 1rem 5.5rem; max-width: none; }

  /* Bottom tab bar */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(24,39,75,0.08);
  }
  .bottom-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 0.5rem 0.25rem;
    border: none; background: none; cursor: pointer;
    color: var(--text-muted); font: inherit; font-size: 0.7rem; max-width: none;
  }
  .bottom-item .nav-ico { width: 1.5rem; height: 1.5rem; }
  .bottom-item.active { color: var(--brand); }
  :root[data-theme="dark"] .bottom-item.active { color: var(--accent); }

  #toastContainer { right: 10px; left: 10px; max-width: none; }
  .welcome-banner-actions { flex-direction: column; }
  .welcome-banner-actions button, .welcome-banner-actions a { width: 100%; text-align: center; }
  .tooltip::before { width: 170px; white-space: normal; }
  .feedback-fab { bottom: 76px; }  /* clear the bottom nav */
  .bg-blue-500, .bg-gray-500, .bg-red-500, .btn { width: 100%; }
}
