/* =========================================================
   Xpoofer Dashboard — Pastel Theme
   ========================================================= */

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

/* ---------------------------------------------------------
   CSS Custom Properties
   --------------------------------------------------------- */
:root {
  /* Backgrounds */
  --bg-page:    #f7f5f2;
  --bg-card:    #ffffff;
  --bg-nav:     #ede9f8;
  --bg-nav-active: #ddd6f7;
  --bg-elevated: #faf9f7;
  --bg-hover:   #f3f0fc;

  /* Accent */
  --accent:     #9b87d8;
  --accent-dark: #7c68c4;
  --accent-light: #c8b8f4;
  --accent-muted: rgba(155,135,216,0.12);

  /* Risk palette */
  --risk-critical: #e88b8b;
  --risk-high:     #e8b98b;
  --risk-medium:   #e8de8b;
  --risk-safe:     #8bd8a0;
  --risk-info:     #87b8d8;

  /* AS classification */
  --cat-spoofable:  #f4a5a5;
  --cat-mostly:     #f4c9a5;
  --cat-partly:     #f4f0a5;
  --cat-blocked:    #a5f4b8;

  /* Text */
  --text-primary:   #2d2a3e;
  --text-secondary: #7b7890;
  --text-muted:     #b4b2c0;
  --text-on-accent: #ffffff;

  /* Borders */
  --border:         #e8e4f0;
  --border-accent:  #c9c0e8;

  /* Chart palette */
  --c1: #c8a5e8;
  --c2: #a5c8e8;
  --c3: #a5e8c8;
  --c4: #e8c8a5;
  --c5: #e8a5b8;
  --c6: #b8e8a5;
  --c7: #e8e0a5;
  --c8: #a5b8e8;

  /* Shadows */
  --shadow-card: 0 2px 12px rgba(155,135,216,0.10);
  --shadow-hover: 0 4px 20px rgba(155,135,216,0.20);
  --shadow-nav: 2px 0 20px rgba(155,135,216,0.08);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Fonts */
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Nav */
  --nav-h: 60px;
}

/* ---------------------------------------------------------
   Reset
   --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img, svg { display: block; max-width: 100%; }

/* ---------------------------------------------------------
   Page Navigation — inside content area
   --------------------------------------------------------- */
#page-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 16px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}

.page-nav-brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-dark);
  letter-spacing: -0.3px;
  white-space: nowrap;
  padding-right: 16px;
  border-right: 1px solid var(--border-accent);
  margin-right: 8px;
}

.page-nav-links {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.nav-btn {
  padding: 6px 14px;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.15s ease;
}
.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-btn.active {
  background: var(--bg-nav-active);
  color: var(--accent-dark);
  font-weight: 600;
}

/* Round bar — shown below page-nav, only for dynamic views */
.view-round-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.round-bar-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.round-select {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 5px 10px;
  border: 1px solid var(--border-accent);
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
}
.round-select:focus { border-color: var(--accent); }

/* ---------------------------------------------------------
   Main Content Area
   --------------------------------------------------------- */
#main {
  padding: 32px 40px 60px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ---------------------------------------------------------
   Views (show/hide)
   --------------------------------------------------------- */
.view { display: none; }
.view.active { display: block; }

/* ---------------------------------------------------------
   Page Header
   --------------------------------------------------------- */
.page-header {
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.4px;
  margin-bottom: 6px;
}
.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 680px;
}

/* ---------------------------------------------------------
   Grid layouts
   --------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* ---------------------------------------------------------
   Cards
   --------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}
.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ---------------------------------------------------------
   KPI Stat Cards
   --------------------------------------------------------- */
.kpi-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  transition: box-shadow 0.15s;
}
.kpi-card:hover { box-shadow: var(--shadow-hover); }
.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -1px;
}
.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 6px;
}
.kpi-delta {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: 0.01em;
}
.kpi-card.accent-red   { border-left-color: var(--risk-critical); }
.kpi-card.accent-orange{ border-left-color: var(--risk-high); }
.kpi-card.accent-green { border-left-color: var(--risk-safe); }
.kpi-card.accent-blue  { border-left-color: var(--risk-info); }
.kpi-card.accent-yellow{ border-left-color: var(--risk-medium); }

/* ---------------------------------------------------------
   Callout / Highlight Box
   --------------------------------------------------------- */
.callout {
  border-radius: var(--r-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
}
.callout-warning {
  background: #fff8f0;
  border: 1px solid #f4c9a5;
  color: #8a5a20;
}
.callout-info {
  background: #f0f4ff;
  border: 1px solid var(--border-accent);
  color: #3a4a8a;
}
.callout-danger {
  background: #fff0f0;
  border: 1px solid var(--cat-spoofable);
  color: #8a2020;
}
.callout-success {
  background: #f0fff4;
  border: 1px solid var(--cat-blocked);
  color: #1a6a35;
}
.callout strong { font-weight: 700; }

/* ---------------------------------------------------------
   Chart containers
   --------------------------------------------------------- */
.chart-wrap {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}
.chart-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.chart-container {
  width: 100%;
  position: relative;
}

/* ---------------------------------------------------------
   Section spacing
   --------------------------------------------------------- */
.section { margin-bottom: 28px; }
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ---------------------------------------------------------
   Sub-tabs (within a view)
   --------------------------------------------------------- */
.subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.subtab-btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  margin-bottom: -2px;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.subtab-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.subtab-btn.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

/* ---------------------------------------------------------
   iFrame embed
   --------------------------------------------------------- */
.map-iframe-wrap {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  position: relative;
}
.map-iframe-wrap iframe {
  width: 100%;
  height: 480px;
  border: none;
  display: block;
}
.map-iframe-caption {
  padding: 8px 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

/* ---------------------------------------------------------
   DataTables overrides
   --------------------------------------------------------- */
.dataTables_wrapper { font-size: 0.85rem; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border-accent);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  border-color: var(--accent);
}
table.dataTable thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  border-bottom: 2px solid var(--border) !important;
  padding: 10px 12px;
}
table.dataTable tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.dataTable tbody tr:hover td { background: var(--bg-hover); }
table.dataTable { border-collapse: collapse; width: 100%; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--r-sm);
  padding: 3px 8px;
  color: var(--text-secondary) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
.dataTables_wrapper .dataTables_info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------------------------------------------------------
   Badges
   --------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.badge-spoofable  { background: var(--cat-spoofable); color: #7a2020; }
.badge-mostly     { background: var(--cat-mostly); color: #7a4a10; }
.badge-partly     { background: var(--cat-partly); color: #6a6010; }
.badge-blocked    { background: var(--cat-blocked); color: #1a5a30; }
.badge-accent     { background: var(--accent-muted); color: var(--accent-dark); }
.badge-danger     { background: #ffe0e0; color: #9b2020; }
.badge-info       { background: #e0edff; color: #204a9b; }

/* ---------------------------------------------------------
   Progress / mini bar
   --------------------------------------------------------- */
.mini-bar-wrap { width: 100%; background: var(--border); border-radius: 4px; height: 6px; }
.mini-bar { height: 6px; border-radius: 4px; background: var(--accent); }

/* ---------------------------------------------------------
   Hero (Overview)
   --------------------------------------------------------- */
.hero {
  background: linear-gradient(135deg, #f0ecfa 0%, #e8f0fc 50%, #eafaf2 100%);
  border-radius: var(--r-xl);
  padding: 36px 40px;
  margin-bottom: 28px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(155,135,216,0.15), transparent 70%);
  pointer-events: none;
}
.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.6px;
  margin-bottom: 10px;
}
.hero h1 em {
  font-style: normal;
  color: var(--accent-dark);
}
.hero p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 680px;
  line-height: 1.7;
}
.hero-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.hero-meta {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--border-accent);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-dark);
}

/* ---------------------------------------------------------
   Nav shortcut cards
   --------------------------------------------------------- */
.nav-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.nav-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.nav-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border-accent);
  transform: translateY(-1px);
}
.nav-card-icon {
  font-size: 1.5rem;
  margin-bottom: 10px;
}
.nav-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.nav-card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ---------------------------------------------------------
   Table — simple (non-DataTables)
   --------------------------------------------------------- */
.simple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.simple-table th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 9px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}
.simple-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.simple-table tbody tr:hover td { background: var(--bg-hover); }
.mono { font-family: var(--font-mono); }

/* ---------------------------------------------------------
   Loading spinner
   --------------------------------------------------------- */
.loading-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------------------------------------------------------
   Scrollbar (WebKit)
   --------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent-light); border-radius: 3px; }

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  #main { padding: 16px 14px 40px; }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 1.4rem; }
}
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.6rem; }
  .nav-links { gap: 0; }
  .nav-btn { padding: 6px 10px; font-size: 0.8rem; }
  .map-iframe-wrap iframe { height: 320px; }
}

/* =========================================================
   COLOR SCHEME OVERRIDES
   Switch by setting data-theme on <html>:
     <html lang="en" data-theme="rose">   → Rose
     <html lang="en" data-theme="ocean">  → Ocean
     <html lang="en" data-theme="dusk">   → Dusk (dark)
     <html lang="en">                     → Lavender (default)
   ========================================================= */

/* ---- THEME: ROSE ---- */
html[data-theme="rose"] {
  --bg-page:       #fdf5f6;
  --bg-card:       #ffffff;
  --bg-nav:        #f8e8ea;
  --bg-nav-active: #f4d0d5;
  --bg-elevated:   #fdf8f8;
  --bg-hover:      #fce8ea;
  --accent:        #d87f8a;
  --accent-dark:   #c4606e;
  --accent-light:  #f4b8c0;
  --accent-muted:  rgba(216,127,138,0.12);
  --border:        #f0e4e6;
  --border-accent: #e8c0c8;
  --shadow-card:   0 2px 12px rgba(216,127,138,0.10);
  --shadow-hover:  0 4px 20px rgba(216,127,138,0.18);
  --c1: #f4b8c0; --c2: #f4d4b8; --c3: #b8f4d4;
  --c4: #b8d4f4; --c5: #d4b8f4; --c6: #f4f4b8;
  --c7: #f4b8e8; --c8: #b8f4b8;
}

/* ---- THEME: OCEAN ---- */
html[data-theme="ocean"] {
  --bg-page:       #f4f7fb;
  --bg-card:       #ffffff;
  --bg-nav:        #e4eff8;
  --bg-nav-active: #cce0f4;
  --bg-elevated:   #f8fafd;
  --bg-hover:      #e8f2fc;
  --accent:        #5b9bd8;
  --accent-dark:   #3d7fc0;
  --accent-light:  #a0c8f0;
  --accent-muted:  rgba(91,155,216,0.12);
  --border:        #dce8f4;
  --border-accent: #b8d4ec;
  --shadow-card:   0 2px 12px rgba(91,155,216,0.10);
  --shadow-hover:  0 4px 20px rgba(91,155,216,0.18);
  --c1: #a0c8f0; --c2: #a0f0e0; --c3: #f0d4a0;
  --c4: #c0a0f0; --c5: #f0a0b8; --c6: #a0f0b0;
  --c7: #f0f0a0; --c8: #a0b8f0;
}

/* ---- THEME: DUSK (dark) ---- */
html[data-theme="dusk"] {
  --bg-page:        #181626;
  --bg-card:        #252238;
  --bg-nav:         #1e1b30;
  --bg-nav-active:  #302c4c;
  --bg-elevated:    #2a2740;
  --bg-hover:       #302c50;
  --accent:         #a08ce8;
  --accent-dark:    #c4b0ff;
  --accent-light:   #7060c0;
  --accent-muted:   rgba(160,140,232,0.18);
  --text-primary:   #ece8f8;
  --text-secondary: #9894b0;
  --text-muted:     #6860a0;
  --border:         #302c50;
  --border-accent:  #4840a0;
  --shadow-card:    0 2px 12px rgba(0,0,0,0.40);
  --shadow-hover:   0 4px 20px rgba(0,0,0,0.50);
  --c1: #b0a0f0; --c2: #90c0f0; --c3: #90f0d0;
  --c4: #f0d090; --c5: #f090b0; --c6: #90f0a0;
  --c7: #f0f090; --c8: #90b0f0;
  --risk-critical: #f0a0a0;
  --risk-high:     #f0c890;
  --risk-medium:   #f0ec90;
  --risk-safe:     #90f0a8;
  --risk-info:     #90c8f0;
}
