/* ============================================================
   Ingage Dashboard — Shared CSS
   Used across all pages: dashboard, weekly, cmc, summary, pipeline
   ============================================================ */

/* Theme variables */
:root {
  --bg-page: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #262a36;
  --border: #2d3141;
  --border-hover: #404560;
  --text-primary: #e1e4e8;
  --text-heading: #fff;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --text-muted: #4b5563;
  --accent: #6366f1;
  --link: #818cf8;
  --link-hover: #a5b4fc;
  --table-row-hover: rgba(99, 102, 241, 0.06);
  --table-border: rgba(45, 49, 65, 0.5);
  --modal-overlay: rgba(0,0,0,0.6);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-page: #f5f5f7;
    --bg-card: #ffffff;
    --bg-input: #f0f1f3;
    --border: #d1d5db;
    --border-hover: #9ca3af;
    --text-primary: #1f2937;
    --text-heading: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #6366f1;
    --link: #4f46e5;
    --link-hover: #6366f1;
    --table-row-hover: rgba(99, 102, 241, 0.04);
    --table-border: rgba(209, 213, 219, 0.5);
    --modal-overlay: rgba(0,0,0,0.3);
  }
}

body.light-mode {
  --bg-page: #f5f5f7; --bg-card: #ffffff; --bg-input: #f0f1f3;
  --border: #d1d5db; --border-hover: #9ca3af;
  --text-primary: #1f2937; --text-heading: #111827;
  --text-secondary: #6b7280; --text-tertiary: #6b7280; --text-muted: #9ca3af;
  --accent: #6366f1; --link: #4f46e5; --link-hover: #6366f1;
  --table-row-hover: rgba(99, 102, 241, 0.04);
  --table-border: rgba(209, 213, 219, 0.5);
  --modal-overlay: rgba(0,0,0,0.3);
}

body.dark-mode,
body.tv-mode {
  --bg-page: #0f1117; --bg-card: #1a1d27; --bg-input: #262a36;
  --border: #2d3141; --border-hover: #404560;
  --text-primary: #e1e4e8; --text-heading: #fff;
  --text-secondary: #6b7280; --text-tertiary: #9ca3af; --text-muted: #4b5563;
  --accent: #6366f1; --link: #818cf8; --link-hover: #a5b4fc;
  --table-row-hover: rgba(99, 102, 241, 0.06);
  --table-border: rgba(45, 49, 65, 0.5);
  --modal-overlay: rgba(0,0,0,0.6);
}

/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
}

/* ---- Sticky nav bar ---- */
.site-nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 0 24px; display: flex; align-items: center; height: 44px; gap: 24px;
}
.site-nav-brand {
  font-size: 14px; font-weight: 800; color: var(--text-heading);
  text-decoration: none; white-space: nowrap;
}
.site-nav-links { display: flex; gap: 4px; flex: 1; }
.site-nav-links a {
  font-size: 12px; font-weight: 500; color: var(--text-secondary); text-decoration: none;
  padding: 6px 10px; border-radius: 6px; transition: all 0.15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
.site-nav-links a svg { flex-shrink: 0; }
.site-nav-links a:hover { color: var(--text-primary); background: var(--bg-input); }
.site-nav-links a.nav-active { color: var(--text-heading); background: var(--bg-input); font-weight: 600; }
.site-nav-right { display: flex; align-items: center; gap: 8px; }
.site-nav .quarter-select { font-size: 12px; padding: 4px 8px; }
.tv-mode .site-nav, .notion-mode .site-nav { display: none; }

/* ---- Shared controls ---- */
.quarter-select {
  background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 500; cursor: pointer;
  outline: none;
}
.quarter-select:hover { border-color: var(--border-hover); }
.quarter-select:focus { border-color: var(--accent); }

.settings-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-secondary); cursor: pointer; font-size: 16px; padding: 0 8px;
  height: 28px; display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.settings-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }

.last-updated { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }

/* ---- Page layout ---- */
.page-title {
  font-size: 20px; font-weight: 800; color: var(--text-heading); margin-bottom: 16px;
}

/* ---- Modal / Popup ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: var(--modal-overlay);
  z-index: 1000; justify-content: center; align-items: flex-start; padding-top: 10vh;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  width: 600px; max-width: 90vw; max-height: 75vh; overflow-y: auto; padding: 24px;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; gap: 8px;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--text-heading); }
.modal-close {
  background: none; border: none; color: var(--text-secondary); font-size: 22px;
  cursor: pointer; padding: 4px 8px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-total { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

/* ---- Deal list (used in popups) ---- */
.deal-list { list-style: none; }
.deal-list li {
  padding: 8px 0; border-bottom: 1px solid var(--table-border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.deal-list li:last-child { border-bottom: none; }
.deal-list a { color: var(--link); text-decoration: none; font-size: 13px; font-weight: 500; }
.deal-list a:hover { color: var(--link-hover); }
.deal-meta { font-size: 12px; color: var(--text-secondary); text-align: right; white-space: nowrap; }
.deal-amount { font-weight: 600; color: var(--text-heading); }
.deal-owner { font-size: 11px; color: var(--text-tertiary); }

/* ---- CSV button ---- */
.csv-btn {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-secondary); padding: 4px 10px; font-size: 11px; cursor: pointer; white-space: nowrap;
}
.csv-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }

/* ---- Footer ---- */
.site-footer {
  margin-top: 24px; padding: 12px 0; text-align: center;
  border-top: 1px solid var(--table-border);
}

/* ---- Auth / Loading overlays ---- */
.overlay {
  display: none; position: fixed; inset: 0; background: var(--bg-page);
  z-index: 9999; justify-content: center; align-items: center; text-align: center;
}
.overlay p { color: var(--text-secondary); font-size: 15px; }
.overlay a { color: var(--link); }

/* ---- Print ---- */
@media print {
  body { background: #fff; color: #111; }
  .site-nav, .quarter-select, .settings-btn { display: none; }
  .modal-overlay { display: none; }
}

/* ---- Hamburger toggle (mobile only) ---- */
.site-nav-toggle {
  display: none;
  width: 36px; height: 36px;
  background: none; border: none; padding: 0;
  color: var(--text-primary); cursor: pointer;
  border-radius: 6px;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.site-nav-toggle:active { background: var(--bg-input); }
.site-nav-toggle svg { display: block; }

/* ---- Slide-out drawer (mobile only) ---- */
.site-nav-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 998;
  opacity: 0; transition: opacity 0.2s ease;
}
.site-nav-drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 78vw; max-width: 320px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  z-index: 999;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: none;
  flex-direction: column;
}
.site-nav-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.site-nav-drawer-brand {
  font-size: 16px; font-weight: 800;
  color: var(--text-heading); text-decoration: none;
}
.site-nav-drawer-close {
  width: 44px; height: 44px;
  background: none; border: none; padding: 0;
  color: var(--text-secondary); cursor: pointer;
  font-size: 24px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: -10px;
}
.site-nav-drawer-close:active { color: var(--text-primary); }
.site-nav-drawer-links {
  flex: 1; overflow-y: auto;
  padding: 8px 0;
  display: flex; flex-direction: column;
}
.site-nav-drawer-links a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  font-size: 15px; font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
  min-height: 44px;
}
.site-nav-drawer-links a:active { background: var(--bg-input); }
.site-nav-drawer-links a.nav-active {
  color: var(--text-heading); font-weight: 600;
  background: var(--bg-input);
  border-left-color: var(--accent, #28D4C0);
}
.site-nav-drawer-links a svg { flex-shrink: 0; }

body.site-nav-open { overflow: hidden; }
body.site-nav-open .site-nav-backdrop { display: block; opacity: 1; }
body.site-nav-open .site-nav-drawer { display: flex; transform: translateX(0); }

/* ---- Mobile ---- */
@media (max-width: 768px) {
  .site-nav { padding: 0 12px; gap: 8px; }
  /* Hide horizontal links inside the bar — they live in the drawer now.
     The dashboard's in-page Trends button is also inside .site-nav-links,
     but Trends is reachable via the drawer (links to /?trends=1). */
  .site-nav > .site-nav-links { display: none; }
  .site-nav-toggle { display: inline-flex; }
}
@media (min-width: 769px) {
  /* Drawer is mobile-only — keep it hidden on desktop even if toggled. */
  body.site-nav-open .site-nav-backdrop,
  body.site-nav-open .site-nav-drawer { display: none; }
  body.site-nav-open { overflow: auto; }
}
