/* ==========================================================================
   OSINT Portal — Surveillance Dashboard styles (Phase 6, TSK-037/038)
   Dark theme custom layer on top of Bootstrap 5. Responsive shell:
   persistent sidebar ≥900px, offcanvas drawer below that; wheel hub on home.
   ========================================================================== */

:root,
[data-bs-theme="dark"] {
  --osint-bg: #0b1329;
  --osint-bg-elevated: #162238;
  --osint-border: #2a3b53;
  --osint-text: #f8fafc;
  --osint-text-muted: #cbd5e1;
  --osint-text-dim: #94a3b8;
  --osint-accent: #38bdf8;
  --osint-accent-strong: #0ea5e9;
  --osint-healthy: #4ade80;
  --osint-degraded: #facc15;
  --osint-failed: #f87171;
  --osint-unknown: #94a3b8;

  /* Bootstrap 5 Theme Overrides */
  --bs-body-bg: var(--osint-bg);
  --bs-body-color: var(--osint-text);
  --bs-secondary-color: var(--osint-text-muted);
  --bs-secondary-color-rgb: 203, 213, 225;
  --bs-tertiary-color: var(--osint-text-dim);
  --bs-tertiary-color-rgb: 148, 163, 184;
  --bs-emphasis-color: #ffffff;
  --bs-border-color: var(--osint-border);
}

body {
  background: var(--osint-bg);
  color: var(--osint-text);
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Contrast & Typography Overrides (Resolves gray text blending into dark bg)
   -------------------------------------------------------------------------- */
.text-muted,
.text-secondary {
  color: var(--osint-text-muted) !important;
}

.text-muted a,
.text-secondary a {
  color: var(--osint-accent) !important;
}

.form-text {
  color: var(--osint-text-muted) !important;
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.breadcrumb-item,
.breadcrumb-item.active {
  color: var(--osint-text-muted);
}

.breadcrumb-item a {
  color: var(--osint-accent);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
}

.small.text-muted,
small.text-muted {
  color: var(--osint-text-muted) !important;
}

/* Definition lists (e.g. source details) */
dl dt.text-muted {
  color: var(--osint-text-dim) !important;
  font-weight: 600;
  letter-spacing: 0.02em;
}

dl dd {
  color: var(--osint-text);
}

/* Form controls */
.form-label {
  color: #f1f5f9;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.form-control,
.form-select {
  background-color: #0b1329 !important;
  border-color: var(--osint-border) !important;
  color: #f8fafc !important;
}

.form-control:focus,
.form-select:focus {
  background-color: #111d3a !important;
  border-color: var(--osint-accent) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 0.25rem rgba(56, 189, 248, 0.25) !important;
}

.form-control::placeholder {
  color: #64748b !important;
}

/* Code elements */
code,
.small code {
  color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.1);
  padding: 0.12rem 0.35rem;
  border-radius: 0.25rem;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

/* --------------------------------------------------------------------------
   App shell: sidebar + content column (desktop) / offcanvas (mobile)
   -------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--osint-bg-elevated);
  border-right: 1px solid var(--osint-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  background: var(--osint-bg-elevated);
  border-bottom: 1px solid var(--osint-border);
  padding: 0.55rem 1rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-content {
  padding: 1.25rem;
  flex: 1;
}

/* Persistent global footer (TSK-037/Branding) */
.app-footer {
  position: sticky;
  bottom: 0;
  z-index: 1010;
  background: rgba(16, 26, 46, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--osint-border);
  padding: 0.5rem 1.25rem;
  font-size: 0.82rem;
  color: var(--osint-text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.25);
}

.app-footer .footer-brand {
  color: var(--osint-text-muted);
}

.app-footer .footer-brand strong {
  color: #ffffff;
}

.app-footer .footer-powered {
  color: var(--osint-text-muted);
}

/* Brand header and logo */
.brand-sidebar-logo {
  transition: transform 0.2s ease, filter 0.2s ease;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.brand-sidebar-header a:hover .brand-sidebar-logo {
  transform: scale(1.03);
  filter: drop-shadow(0 3px 10px rgba(56, 189, 248, 0.3));
}

/* Nav links in sidebar */
.nav-pills .nav-link {
  color: #cbd5e1;
  font-weight: 500;
  padding: 0.55rem 0.85rem;
  border-radius: 0.65rem;
  transition: all 0.15s ease-in-out;
}

.nav-pills .nav-link:hover {
  color: #ffffff;
  background-color: rgba(56, 189, 248, 0.12);
}

.nav-pills .nav-link.active {
  color: #ffffff !important;
  background-color: var(--osint-accent-strong) !important;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

/* Wheel hub tile */
.wheel-section {
  text-decoration: none;
  color: var(--osint-text);
  border: 1px solid var(--osint-border);
  background: var(--osint-bg-elevated);
  border-radius: 1rem;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  height: 100%;
}

.wheel-section:hover,
.wheel-section:focus {
  color: var(--osint-text);
  border-color: var(--osint-accent-strong);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.18);
}

.wheel-section .icon {
  font-size: 1.6rem;
  line-height: 1;
}

.wheel-section .title {
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.wheel-section .blurb {
  font-size: 0.84rem;
  color: var(--osint-text-muted);
}

/* Status bar strip */
.status-bar {
  background: var(--osint-bg-elevated);
  border: 1px solid var(--osint-border);
  border-radius: 0.75rem;
  padding: 0.6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.9rem;
}

.status-bar .pill-label {
  color: var(--osint-text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-bar .pill-value {
  color: #ffffff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Health badges */
.health-badge {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25em 0.6em;
  border-radius: 999px;
}

.health-badge.healthy  { background: rgba(34,197,94,0.16);  color: var(--osint-healthy); }
.health-badge.degraded { background: rgba(250,204,21,0.16);  color: var(--osint-degraded); }
.health-badge.failed   { background: rgba(239,68,68,0.16);   color: var(--osint-failed); }
.health-badge.unknown  { background: rgba(148,163,184,0.16); color: var(--osint-unknown); }

/* Cards & Tables */
.card {
  background: var(--osint-bg-elevated);
  border: 1px solid var(--osint-border);
  color: var(--osint-text);
}

.table-dark {
  --bs-table-bg: var(--osint-bg-elevated);
  --bs-table-border-color: var(--osint-border);
  --bs-table-color: var(--osint-text);
}

.table-dark th {
  color: var(--osint-text-dim);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--osint-border);
}

.table-dark td {
  color: #e2e8f0;
}

/* Alert feed row hover */
.alert-row { cursor: pointer; }
.alert-row:hover { background: rgba(56, 189, 248, 0.09); }

/* Live dot for the WebSocket connection indicator */
.live-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  display: inline-block;
  background: var(--osint-unknown);
}
.live-dot.connected { background: var(--osint-healthy); }
.live-dot.reconnecting { background: var(--osint-degraded); }
.live-dot.disconnected { background: var(--osint-failed); }

/* Fresh-alert flash */
@keyframes osint-flash-in {
  from { background: rgba(56, 189, 248, 0.35); }
  to { background: transparent; }
}
.flash-new { animation: osint-flash-in 2.4s ease-out; }

/* CodeMirror + workbench */
.workbench-editor { height: 320px; border: 1px solid var(--osint-border); border-radius: 0.5rem; }
.results-scroll { max-height: 480px; overflow: auto; }

/* Visualization containers */
.viz-card { height: 100%; }
.viz-canvas { min-height: 260px; }

@media (max-width: 899.98px) {
  .app-sidebar { display: none; }
}
@media (min-width: 900px) {
  .offcanvas-sidebar { display: none; }
}

/* --------------------------------------------------------------------------
   No-sidebar App Shell & Landing Page Enhancements
   -------------------------------------------------------------------------- */
.app-shell--no-sidebar {
  display: block;
}

.app-shell--no-sidebar .app-main {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
}

.landing-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.landing-hero {
  position: relative;
  background: radial-gradient(circle at 50% 20%, rgba(56, 189, 248, 0.12) 0%, rgba(11, 19, 41, 0) 70%);
  border-radius: 1rem;
  padding: 3rem 1.5rem;
  margin-bottom: 2.5rem;
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

.landing-card {
  background: var(--osint-bg-elevated);
  border: 1px solid var(--osint-border);
  border-radius: 0.75rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.landing-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.landing-stat-number {
  font-size: 2.25rem;
  font-weight: 800;
  color: #38bdf8;
  line-height: 1.1;
}

.dept-pill {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0.28rem 0.65rem;
  margin: 0.2rem;
  border-radius: 0.375rem;
  background: rgba(22, 34, 56, 0.9);
  color: #cbd5e1;
  border: 1px solid rgba(42, 59, 83, 0.8);
  transition: all 0.15s ease;
}

.dept-pill:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #ffffff;
}

.dept-pill--highlight {
  border-color: rgba(56, 189, 248, 0.6);
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}