/* ================================================================
   InvestX Publisher — Base CSS
   Design tokens (light default / html.dark override) + sidebar
   + shared utilities. Included by all templates.
   ================================================================ */

/* ── Google Fonts ──────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ================================================================
   DESIGN TOKENS — light mode (default)
   ================================================================ */
:root {
  /* New tokens */
  --bg:         #F6F6F2;
  --bg-panel:   #FFFFFF;
  --bg-panel-2: #FAFAF7;
  --bg-side:    #FBFBF8;
  --border:     #E0DED7;
  --border-2:   #EAE8E2;
  --border-3:   #D7D5CD;
  --text:       #0E0E12;
  --text-mute:  #5A5F6B;
  --text-dim:   #9CA1AC;
  --chip:       #F0EFEA;
  --chip-2:     #E6E5E0;
  --good:       #0F9F6E;
  --warn:       #B97400;
  --bad:        #C5314A;
  --link:       #C24516;
  --accent:     #FF6B2C;

  /* Backward-compat aliases (used by existing page CSS) */
  --bg-card:    #FFFFFF;
  --bg-hover:   #E6E5E0;
  --bg-elevated:#F0EFEA;
  --border-hover:#D7D5CD;
  --text-2:     #5A5F6B;
  --text-3:     #9CA1AC;
  --green:      #0F9F6E;
  --green-d:    rgba(15,159,110,.10);
  --amber:      #B97400;
  --amber-d:    rgba(185,116,0,.10);
  --red:        #C5314A;
  --red-d:      rgba(197,49,74,.10);
  --blue:       #1D6DE5;
  --blue-d:     rgba(29,109,229,.10);
  --purple:     #7C3AED;
  --purple-d:   rgba(124,58,237,.10);
  --r:          10px;
}

/* ================================================================
   DESIGN TOKENS — dark mode
   ================================================================ */
html.dark {
  --bg:         #070809;
  --bg-panel:   #0E1014;
  --bg-panel-2: #11141A;
  --bg-side:    #0A0B0E;
  --border:     #1E2026;
  --border-2:   #16181C;
  --border-3:   #2A2D34;
  --text:       #ECEDEE;
  --text-mute:  #8E929C;
  --text-dim:   #545860;
  --chip:       #17181C;
  --chip-2:     #1E2026;
  --good:       #34D399;
  --warn:       #F59E0B;
  --bad:        #F87171;
  --link:       #FF8A55;

  /* Backward-compat aliases */
  --bg-card:    #0E1014;
  --bg-hover:   #1E2026;
  --bg-elevated:#17181C;
  --border-hover:#2A2D34;
  --text-2:     #8E929C;
  --text-3:     #545860;
  --green:      #34D399;
  --green-d:    rgba(52,211,153,.12);
  --amber:      #F59E0B;
  --amber-d:    rgba(245,158,11,.12);
  --red:        #F87171;
  --red-d:      rgba(248,113,113,.12);
  --blue:       #60A5FA;
  --blue-d:     rgba(96,165,250,.12);
  --purple:     #A78BFA;
  --purple-d:   rgba(167,139,250,.12);
}

/* ================================================================
   BASE RESET & BODY
   ================================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Monospace font */
code, pre, .font-mono, [class*="font-mono"] {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace;
}

/* Date inputs */
input[type="date"] { color-scheme: light; }
html.dark input[type="date"] { color-scheme: dark; }

/* Scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-3);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ================================================================
   LAYOUT
   ================================================================ */
.layout, .app {
  display: flex;
  min-height: 100vh;
}

.main {
  flex: 1;
  margin-left: 244px;
  padding: 28px 36px;
  max-width: 1280px;
}

/* ================================================================
   SIDEBAR — new design
   ================================================================ */
.sidebar {
  width: 244px;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
}

/* Brand */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
  flex-shrink: 0;
}

.logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.04em;
  flex-shrink: 0;
  background: linear-gradient(135deg, #FF8A4A 0%, #E94C0B 100%);
  box-shadow: 0 0 0 1px rgba(255,138,74,.5) inset, 0 0 28px -6px rgba(255,107,44,.55);
}

.logo-meta {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.logo-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo-sub {
  font-size: 10.5px;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-version {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  background: var(--chip);
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--text-dim);
}

/* Search bar */
.sidebar-search {
  margin: 0 12px 10px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-mute);
  background: var(--chip);
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.sidebar-search:hover { background: var(--chip-2); }
.sidebar-search svg { width: 13px; height: 13px; flex-shrink: 0; }
.sidebar-search-text { flex: 1; }
.sidebar-search-kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  background: var(--bg-panel);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-dim);
}

/* Nav container */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Nav section */
.nav-section { display: flex; flex-direction: column; }

.nav-label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px 6px;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.nav-section-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Nav items */
.nav-item,
.nav-item:link,
.nav-item:visited,
.nav-item:active {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-mute);
  text-decoration: none;
  cursor: pointer;
  transition: color .15s, background .15s;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  color: var(--text);
  background: var(--chip);
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity .15s;
}

.nav-item:hover svg { opacity: 0.85; }

/* Active state */
.nav-item.active,
.nav-item.active:link,
.nav-item.active:visited {
  color: var(--text);
  background: linear-gradient(90deg, rgba(255,107,44,0.14) 0%, transparent 90%);
}

.nav-item.active svg { opacity: 1; }

/* Left accent bar for active */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 0 3px 3px 0;
  background: #FF6B2C;
  box-shadow: 0 0 12px #FF6B2C;
}

/* Nav badge */
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--chip);
  color: var(--text-mute);
  tabular-nums: true;
}

.nav-item.active .nav-badge {
  background: #FF6B2C;
  color: white;
}

/* ================================================================
   SIDEBAR FOOTER
   ================================================================ */
.sidebar-footer {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Logout button */
.logout-btn {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 11.5px;
  font-family: inherit;
  color: var(--text-mute);
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: rgba(248,113,113,.10); color: #F87171; }
.logout-btn svg { flex-shrink: 0; }

/* Theme toggle button */
.theme-toggle {
  width: 100%;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--chip);
  transition: background .15s;
}
.theme-toggle:hover { background: var(--chip-2); }
.theme-toggle svg { width: 14px; height: 14px; flex-shrink: 0; }
.theme-toggle-label { flex: 1; text-align: left; }
.theme-toggle-track {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  padding: 2px;
  flex-shrink: 0;
  background: rgba(15,15,20,.12);
  transition: background .2s;
}
html.dark .theme-toggle-track { background: rgba(255,255,255,.1); }
.theme-toggle-track.on { background: #FF6B2C !important; }
.theme-toggle-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .2s;
}
.theme-toggle-track.on .theme-toggle-thumb { transform: translateX(14px); }

/* Pipeline status pill */
.status-pill {
  min-height: 54px;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--chip);
  border: 1px solid var(--border-2);
}

.dot-wrap {
  position: relative;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  flex-shrink: 0;
  transition: background .3s, box-shadow .3s;
}

.dot.on {
  background: var(--good);
  box-shadow: 0 0 10px var(--good);
}

.dot.pulse {
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
  animation: dot-pulse 1.5s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

.dot-ping {
  display: none;
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--good);
  opacity: 0;
  animation: ping 1.4s cubic-bezier(0,.2,.8,1) infinite;
}

.dot.on ~ .dot-ping,
.dot-ping.visible {
  display: block;
}

@keyframes ping {
  75%, 100% { transform: scale(2.2); opacity: 0; }
}

.status-info {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.status-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.status-sub {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-mute);
  margin-top: 2px;
}

.status-play {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: var(--bg-panel);
  color: var(--good);
  transition: background .15s, opacity .15s;
}
.status-play:hover { opacity: .8; }
.status-play svg { width: 11px; height: 11px; }

/* Pause icon for stop button */
.status-play.running { color: var(--bad); }

/* ================================================================
   SHARED COMPONENT STYLES
   ================================================================ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  background: var(--bg-panel);
  color: var(--text-mute);
  font-family: inherit;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-hover); }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { opacity: .88; }
.btn-green { background: var(--green-d); color: var(--green); border-color: rgba(15,159,110,.25); }
html.dark .btn-green { border-color: rgba(52,211,153,.25); }
.btn-green:hover { background: rgba(15,159,110,.15); }
html.dark .btn-green:hover { background: rgba(52,211,153,.18); }
.btn-red { background: var(--red-d); color: var(--red); border-color: rgba(197,49,74,.25); }
html.dark .btn-red { border-color: rgba(248,113,113,.25); }
.btn-red:hover { background: rgba(197,49,74,.15); }
html.dark .btn-red:hover { background: rgba(248,113,113,.18); }
.btn-amber { background: var(--amber-d); color: var(--amber); border-color: rgba(185,116,0,.25); }
html.dark .btn-amber { border-color: rgba(245,158,11,.25); }
.btn-blue { background: var(--blue-d); color: var(--blue); border-color: rgba(29,109,229,.25); }
html.dark .btn-blue { border-color: rgba(96,165,250,.25); }
.btn:disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 13px; height: 13px; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Badges (legacy .badge + .nav-badge share some CSS) */
.badge {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--amber-d);
  color: var(--amber);
}
.badge.green { background: var(--green-d); color: var(--green); }
.badge.red   { background: var(--red-d);   color: var(--red); }

/* Tags */
.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .2px; }
.tag-draft      { background: var(--amber-d); color: var(--amber); }
.tag-published  { background: var(--green-d); color: var(--green); }
.tag-rejected   { background: var(--red-d);   color: var(--red); }
.tag-pending    { background: var(--amber-d); color: var(--amber); }
.tag-duplicate  { background: var(--purple-d); color: var(--purple); }
.lang { background: var(--chip); color: var(--text-mute); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }

/* Page header */
.pg-header { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-end; }
.pg-header h1 { font-size: 20px; font-weight: 700; margin-bottom: 3px; }
.pg-header p { color: var(--text-dim); font-size: 12px; }
.pg-actions { display: flex; gap: 8px; }

/* Alert banner */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 9px; border: 1px solid; font-size: 13px; margin-bottom: 20px; }
.alert-warn { background: var(--amber-d); border-color: rgba(185,116,0,.30); color: var(--amber); }
html.dark .alert-warn { border-color: rgba(245,158,11,.30); }
.alert-red  { background: var(--red-d);   border-color: rgba(197,49,74,.30);  color: var(--red); }
html.dark .alert-red { border-color: rgba(248,113,113,.30); }
.alert-green{ background: var(--green-d); border-color: rgba(15,159,110,.30); color: var(--green); }
html.dark .alert-green { border-color: rgba(52,211,153,.30); }
.alert svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 9px 18px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-dim); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab:hover { color: var(--text-mute); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Loading spinner overlay */
.section { display: none; }
.section.active { display: block; }

/* Tables */
.table-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.table-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.table-head h3 { font-size: 13px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 14px; text-align: left; font-size: 10px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .6px; background: var(--bg-panel); border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,.02); }
html.dark tr:hover td { background: rgba(255,255,255,.015); }
.cell-title { max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-link { color: var(--link); cursor: pointer; text-decoration: none; }
.cell-link:hover { text-decoration: underline; }

/* Modal */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100; align-items: center; justify-content: center; padding: 40px; }
html.dark .modal-bg { background: rgba(0,0,0,.75); }
.modal-bg.show { display: flex; }
.modal { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; max-width: 860px; width: 100%; max-height: 88vh; overflow-y: auto; display: flex; flex-direction: column; }
.modal-hdr { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 26px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-panel); z-index: 1; }
.modal-hdr h2 { font-size: 16px; font-weight: 700; flex: 1; line-height: 1.4; padding-right: 16px; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1; padding: 0; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 26px 28px; flex: 1; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 18px; }
}
