/* ============================================================
   GLOBAL STYLES

   Minimal overrides on top of Bootstrap 5.
   A4 report pages use a4-report.css separately.
   ============================================================ */

body {
  font-family: var(--bs-font-sans-serif) !important;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--bs-headings-font-family) !important;
}

.navbar-brand {
  font-family: var(--bs-headings-font-family) !important;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ============================================================
   NAVBAR THEME-AWARE TEXT COLORS
   ============================================================ */

.navbar-theme-text {
  color: var(--bs-body-color) !important;
}

.navbar-theme-text .navbar-brand,
.navbar-theme-text .navbar-nav .nav-link,
.navbar-theme-text .navbar-text {
  color: var(--bs-body-color) !important;
}

.navbar-theme-text .navbar-brand:hover,
.navbar-theme-text .navbar-nav .nav-link:hover {
  color: var(--bs-primary) !important;
}

[data-bs-theme="dark"] .navbar-theme-text {
  color: var(--bs-white) !important;
}

[data-bs-theme="dark"] .navbar-theme-text .navbar-brand,
[data-bs-theme="dark"] .navbar-theme-text .navbar-nav .nav-link,
[data-bs-theme="dark"] .navbar-theme-text .navbar-text {
  color: var(--bs-white) !important;
}

[data-bs-theme="dark"] .navbar-theme-text .navbar-brand:hover,
[data-bs-theme="dark"] .navbar-theme-text .navbar-nav .nav-link:hover {
  color: var(--bs-gray-200) !important;
}

._dash-loading { visibility: hidden; }

/* ============================================================
   LAYOUT - Navbar + Sidebar
   ============================================================ */

.sidebar-fixed {
  top: 56px;
  height: calc(100vh - 56px);
  transition: all 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Watchlist items - simple links, no Bootstrap pill interference */
.wl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  margin: 1px 8px;
  border-radius: 6px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.78rem;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.wl-item:hover {
  background-color: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.wl-item .wl-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.wl-section-label {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  padding: 8px 12px 2px;
  text-transform: uppercase;
}

.sidebar-collapsed { width: 0 !important; padding: 0 !important; overflow: hidden; }
.sidebar-collapsed .nav,
.sidebar-collapsed .nav-link,
.sidebar-collapsed .btn { display: none; }

#content-col { transition: all 0.3s ease; }

/* Sidebar nav links */
.nav-link-inactive,
.nav-link-active {
  display: block;
  color: white;
  text-decoration: none;
  padding: 10px 16px;
  margin: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-link-active {
  background-color: #dc3545;
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

/* ============================================================
   DROPDOWN - Red accent for Dash dropdowns
   ============================================================ */

.dropdown-red .Select-control { border-color: #98151b; }
.dropdown-red .Select-option.is-selected { background-color: #98151b; color: white; }
.dropdown-red .Select-option.is-focused { background-color: rgba(152,21,27,0.1); color: #98151b; }
.dropdown-red .Select-multi-value-wrapper .Select-value { background-color: #98151b; color: white; }

/* ============================================================
   GRAPH HEIGHTS - utility classes for dcc.Graph wrappers
   ============================================================ */

.graph-sm  { height: 170px; }
.graph-md  { height: 200px; }
.graph-lg  { height: 250px; }
.graph-xl  { height: 260px; }
.graph-2xl { height: 350px; }
.graph-3xl { height: 600px; }

/* ============================================================
   CARDS - hover lift for portfolio + ETF cards
   ============================================================ */

.portfolio-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.portfolio-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.10) !important;
}

.sparkline-graph .js-plotly-plot,
.sparkline-graph .plot-container {
  height: 50px !important;
}

.portfolio-card .vr { opacity: 0.15; }
.portfolio-card .progress { border-radius: 2px; background-color: rgba(0,0,0,0.04); }

/* ETF selection cards - pointer + selected ring */
.etf-card-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.etf-card-clickable:hover {
  border-color: rgba(151,21,28,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.etf-card-selected {
  border-color: #97151c !important;
  box-shadow: 0 0 0 1px #97151c, 0 2px 6px rgba(151,21,28,0.12) !important;
  background-color: rgba(151,21,28,0.02);
}

/* ============================================================
   TABS - brand red accent
   ============================================================ */

.nav-tabs .nav-link.active {
  color: #97151c !important;
  border-bottom-color: #97151c !important;
  font-weight: 600;
}

.nav-tabs .nav-link {
  color: #6c757d;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.nav-tabs .nav-link:hover {
  color: #97151c;
}

/* ============================================================
   MISC DASH OVERRIDES
   ============================================================ */

.dash-spinner { border-color: #dc3545 !important; }
.tab-pane .dash-loading-callback { min-height: 200px; }

/* Floating save button */
#save-portfolio-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  transition: all 0.3s ease;
}

#save-portfolio-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 16px rgba(220,53,69,0.4);
}

/* ============================================================
   GLOW - ETF X-Ray heading effect
   ============================================================ */

.glow-danger {
  color: #dc3545;
  text-shadow:
    0 0 6px rgba(220, 53, 69, 0.9),
    0 0 18px rgba(220, 53, 69, 0.65),
    0 0 40px rgba(220, 53, 69, 0.35);
  animation: glow-pulse 2.5s ease-in-out infinite;
}

/* ============================================================
   LANDING PAGE - Responsive overrides
   ============================================================ */

@media (max-width: 1199.98px) {
  footer .d-flex.justify-content-center {
    flex-direction: column !important;
    gap: 0.5rem;
  }

  footer .d-inline-flex {
    justify-content: center;
  }

  .display-3 {
    font-size: 2rem !important;
  }

  .display-4 {
    font-size: 1.75rem !important;
  }

  .lead {
    font-size: 1rem !important;
  }
}

@media (min-width: 992px) {
  #hero {
    min-height: calc(100vh - 200px);
  }
}

/* White glow when ETF X-RAY nav link is active (red background) */
.nav-link-active .glow-danger {
  color: #fff !important;
  text-shadow: 0 0 6px rgba(255,255,255,0.8), 0 0 14px rgba(255,255,255,0.4);
  animation: none;
}

@keyframes glow-pulse {
  0%, 100% {
    text-shadow:
      0 0 6px rgba(220, 53, 69, 0.9),
      0 0 18px rgba(220, 53, 69, 0.65),
      0 0 40px rgba(220, 53, 69, 0.35);
  }
  50% {
    text-shadow:
      0 0 10px rgba(220, 53, 69, 1),
      0 0 28px rgba(220, 53, 69, 0.85),
      0 0 60px rgba(220, 53, 69, 0.5);
  }
}


/* ============================================================
   NOTEBOOK PAGE
   ============================================================ */

/* Code editor textarea */
.nb-code-editor {
  background: #fafbfc !important;
  color: #1e293b !important;
  font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace !important;
  font-size: 13px !important;
  line-height: 1.7 !important;
  border: 1px solid #d1d5db !important;
  border-radius: 8px !important;
  padding: 16px 20px !important;
  min-height: 420px;
  tab-size: 4;
  white-space: pre;
  overflow-x: auto;
  resize: vertical;
  transition: border-color 0.15s;
}

.nb-code-editor:focus {
  border-color: #97151c !important;
  box-shadow: 0 0 0 0.2rem rgba(151, 21, 28, 0.12) !important;
  outline: none !important;
}

/* Output panel */
.nb-output-panel {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 16px;
  min-height: 60px;
}

.nb-stdout-output {
  background: #f0fdf4;
  color: #166534;
  font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 12px 16px;
  border-radius: 6px;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  border: 1px solid #bbf7d0;
}

.nb-error-output {
  background: #fef2f2;
  color: #dc2626;
  font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  padding: 12px 16px;
  border-radius: 6px;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #fecaca;
  margin: 0;
}

/* Toolbar */
.nb-toolbar {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 10px 16px;
}

.nb-filename-badge {
  font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
  color: #374151;
  background: #f3f4f6;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
}

/* AI chat */
.nb-chat-container {
  min-height: 180px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  scroll-behavior: smooth;
  background: #f9fafb;
  border-radius: 6px;
}

.nb-msg-user {
  background: #dbeafe;
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  align-self: flex-end;
  max-width: 92%;
  font-size: 0.82rem;
  color: #1e3a8a;
  line-height: 1.5;
}

.nb-msg-ai {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 14px 14px 14px 4px;
  padding: 10px 14px;
  align-self: flex-start;
  max-width: 97%;
  font-size: 0.82rem;
  color: #1e293b;
  line-height: 1.5;
}

.nb-ai-code {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 12px 14px;
  font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: #1e40af;
  white-space: pre-wrap;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 8px;
  line-height: 1.5;
}

/* Version history */
.nb-history-item {
  padding: 9px 4px;
  border-bottom: 1px solid #f1f5f9;
}

.nb-sha-badge {
  font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  color: #b45309;
  background: #fffbeb;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.73rem;
  border: 1px solid #fde68a;
}

/* Notebook list cards */
.nb-card {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.nb-card:hover {
  border-color: #ced4da;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.nb-card-filename {
  font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  color: #1e293b;
  font-weight: 500;
}

.nb-card-meta {
  font-size: 0.74rem;
  color: #9ca3af;
}

/* Empty / unauthenticated states */
.nb-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #9ca3af;
}
