/* ============================================
   VIRUSTRACK — DESIGN SYSTEM
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --bg-primary: #0a0f1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(22, 33, 55, 0.95);
  --bg-glass: rgba(15, 23, 42, 0.7);
  --border-color: rgba(255, 165, 80, 0.12);
  --border-accent: rgba(255, 165, 80, 0.3);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-label: #cbd5e1;
  --accent: #f59e0b;
  --accent-dim: rgba(245, 158, 11, 0.15);
  --signal-confirmed: #ef4444;
  --signal-cluster: #3b82f6;
  --signal-monitoring: #f59e0b;
  --signal-context: #10b981;
  --signal-confirmed-bg: rgba(239, 68, 68, 0.12);
  --signal-cluster-bg: rgba(59, 130, 246, 0.12);
  --signal-monitoring-bg: rgba(245, 158, 11, 0.12);
  --signal-context-bg: rgba(16, 185, 129, 0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --header-h: 56px;
  --ticker-h: 36px;
  --footer-h: 38px;
  --sidebar-w: 280px;
  --feed-w: 280px;
}

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

html { font-size: 14px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(245,158,11,0.25); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(245,158,11,0.45); }

/* ============================================
   HEADER
   ============================================ */
.header {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 1000;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__logo {
  width: 36px;
  height: 36px;
  background: radial-gradient(circle, var(--accent) 0%, #d97706 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px rgba(245,158,11,0.35);
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(245,158,11,0.35); }
  50% { box-shadow: 0 0 28px rgba(245,158,11,0.55); }
}

.header__title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.header__subtitle {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.header__stats {
  display: flex;
  align-items: center;
  gap: 32px;
}

.header__stat-group {
  text-align: center;
}

.header__stat-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  font-weight: 600;
}

.header__stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.header__stat-value small {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.header__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header__live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--signal-confirmed);
  letter-spacing: 1px;
}

.header__live-dot {
  width: 7px;
  height: 7px;
  background: var(--signal-confirmed);
  border-radius: 50%;
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.header__updated {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.header__settings {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}

.header__settings:hover {
  border-color: var(--border-accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ============================================
   NEWS TICKER
   ============================================ */
.ticker {
  height: var(--ticker-h);
  background: rgba(245, 158, 11, 0.06);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  overflow: hidden;
  position: relative;
}

.ticker__badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 100%;
  background: rgba(239, 68, 68, 0.1);
  border-right: 1px solid var(--border-color);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--signal-confirmed);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  z-index: 2;
}

.ticker__badge-dot {
  width: 6px;
  height: 6px;
  background: var(--signal-confirmed);
  border-radius: 50%;
  animation: blink 1.2s ease-in-out infinite;
}

.ticker__badge a {
  color: var(--signal-confirmed);
  margin-left: 4px;
}

.ticker__track {
  display: flex;
  animation: tickerScroll 60s linear infinite;
  white-space: nowrap;
}

.ticker__track:hover { animation-play-state: paused; }

@keyframes tickerScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker__item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 28px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.ticker__item-date {
  color: var(--text-muted);
  font-weight: 500;
}

.ticker__item-source {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
}

.ticker__item-text { color: var(--text-primary); font-weight: 400; }

.ticker__item-tag {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.ticker__item-tag--live {
  background: rgba(239, 68, 68, 0.2);
  color: var(--signal-confirmed);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.ticker__item-tag--update {
  background: rgba(59, 130, 246, 0.15);
  color: var(--signal-cluster);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
.main {
  display: flex;
  height: calc(100vh - var(--header-h) - var(--ticker-h) - var(--footer-h));
}

/* --- Left Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__section {
  padding: 14px 16px 8px;
}

.sidebar__title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Search */
.search {
  position: relative;
  margin-bottom: 4px;
}

.search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.search__input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  outline: none;
  transition: var(--transition);
}

.search__input::placeholder { color: var(--text-muted); }
.search__input:focus { border-color: var(--border-accent); background: rgba(15,23,42,0.9); }

/* Signal Filter Cards */
.signal-filters { display: flex; flex-direction: column; gap: 4px; }

.signal-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  user-select: none;
}

.signal-card:hover { background: var(--bg-card-hover); }
.signal-card.active { border-color: var(--border-accent); background: var(--bg-card-hover); }

.signal-card__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.signal-card__dot--confirmed { background: var(--signal-confirmed); box-shadow: 0 0 8px rgba(239,68,68,0.4); }
.signal-card__dot--cluster { background: var(--signal-cluster); box-shadow: 0 0 8px rgba(59,130,246,0.4); }
.signal-card__dot--monitoring { background: var(--signal-monitoring); box-shadow: 0 0 8px rgba(245,158,11,0.4); }
.signal-card__dot--context { background: var(--signal-context); box-shadow: 0 0 8px rgba(16,185,129,0.4); }

.signal-card__label {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-label);
}

.signal-card__count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.signal-card.dimmed { opacity: 0.35; }

/* Reports */
.reports {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 12px;
}

.reports__header {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  padding: 10px 0 8px;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 2;
}

.report-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: var(--transition);
}

.report-item:hover { padding-left: 6px; }

.report-item__location {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.report-item__summary {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.report-item__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.report-item__date {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.report-item__type-badge {
  font-size: 0.58rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.report-item__type-badge--confirmed { background: var(--signal-confirmed-bg); color: var(--signal-confirmed); }
.report-item__type-badge--cluster { background: var(--signal-cluster-bg); color: var(--signal-cluster); }
.report-item__type-badge--monitoring { background: var(--signal-monitoring-bg); color: var(--signal-monitoring); }
.report-item__type-badge--context { background: var(--signal-context-bg); color: var(--signal-context); }

/* Sidebar Disclaimer */
.sidebar__disclaimer {
  padding: 10px 16px;
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border-color);
  background: rgba(10, 15, 26, 0.5);
}

.sidebar__disclaimer a { color: var(--accent); font-weight: 500; }

/* ============================================
   MAP CONTAINER
   ============================================ */
.map-container {
  flex: 1;
  position: relative;
  min-width: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 20px;
  left: 16px;
  z-index: 800;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
}

.map-legend__title {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.map-legend__items { display: flex; flex-direction: column; gap: 7px; }

.map-legend__item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.map-legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Custom Leaflet popup */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-popup-tip { background: var(--bg-card) !important; }

.leaflet-popup-content {
  margin: 14px 16px !important;
  font-family: var(--font-sans) !important;
  font-size: 0.8rem !important;
  line-height: 1.55 !important;
}

.popup__title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.popup__type {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.popup__detail { color: var(--text-secondary); font-size: 0.78rem; margin-bottom: 3px; }
.popup__source { color: var(--text-muted); font-size: 0.68rem; margin-top: 6px; font-style: italic; }

/* Pulse animation for markers */
@keyframes markerPulse {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.5); opacity: 0.3; }
  100% { transform: scale(2); opacity: 0; }
}

.leaflet-control-zoom a {
  background: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-card-hover) !important;
  color: var(--accent) !important;
}

/* Marker cluster override */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background: rgba(245,158,11,0.2) !important;
}

.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: rgba(245,158,11,0.6) !important;
  color: #fff !important;
  font-family: var(--font-mono) !important;
  font-weight: 700 !important;
}

/* ============================================
   RIGHT FEED SIDEBAR
   ============================================ */
.feed {
  width: var(--feed-w);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.feed__header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.feed__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.feed__subtitle {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.feed__subtitle span { color: var(--text-secondary); font-weight: 500; }

.feed__items {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.feed-item {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: var(--transition);
  cursor: pointer;
}

.feed-item:hover { background: var(--bg-card-hover); }

.feed-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.feed-item__source {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feed-item__source > div {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.feed-item__source-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.feed-item__source-handle {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.feed-item__verified {
  width: 14px;
  height: 14px;
  background: var(--signal-cluster);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #fff;
}

.feed-item__time {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.feed-item__text {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.feed-item__text a { color: var(--signal-cluster); }

.feed-item__footer {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.feed-item__stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.feed-item__map-match {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 500;
}

/* ============================================
   FOOTER DISCLAIMER
   ============================================ */
.footer {
  background: rgba(10, 15, 26, 0.9);
  border-top: 1px solid var(--border-color);
  padding: 10px 24px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  z-index: 100;
}

.footer__label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  flex-shrink: 0;
  padding-top: 1px;
}

.footer__text {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.footer__text a { color: var(--accent); font-weight: 500; }

/* ============================================
   LOADING SPINNER
   ============================================ */
.feed-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.feed-loading__spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE — TABLET (≤ 1024px)
   ============================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; --feed-w: 240px; }
  .header__stats { gap: 16px; }
}

/* ============================================
   RESPONSIVE — SMALL TABLET (≤ 900px)
   ============================================ */
@media (max-width: 900px) {
  .feed { display: none; }
  :root { --sidebar-w: 260px; }
}

/* ============================================
   RESPONSIVE — MOBILE (≤ 768px)
   ============================================ */
@media (max-width: 768px) {
  body { overflow: auto; height: auto; }

  .header {
    height: auto;
    min-height: var(--header-h);
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 4px;
  }
  .header__stats { display: none; }
  .header__subtitle { display: none; }
  .header__logo { width: 30px; height: 30px; font-size: 15px; }
  .header__title { font-size: 1rem; }
  .header__right { gap: 10px; }
  .header__updated { font-size: 0.62rem; }

  .ticker {
    height: auto;
    min-height: 32px;
    padding: 6px 0;
  }
  .ticker__badge { padding: 0 10px; font-size: 0.6rem; letter-spacing: 1px; }

  /* Stacked single-column layout */
  .main {
    flex-direction: column;
    height: auto;
    min-height: 0;
  }

  /* Map — full width, fixed height */
  .map-container {
    width: 100%;
    height: 55vh;
    min-height: 280px;
    flex-shrink: 0;
    order: 1;
  }

  .map-legend {
    bottom: 8px;
    left: 8px;
    padding: 10px 14px;
  }
  .map-legend__title { font-size: 0.55rem; margin-bottom: 6px; }
  .map-legend__item { font-size: 0.72rem; gap: 6px; }
  .map-legend__dot { width: 8px; height: 8px; }

  /* Sidebar — full width, stacked below map */
  .sidebar {
    display: flex;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--border-color);
    overflow: visible;
    order: 2;
  }

  /* Filter cards → 2x2 grid */
  .signal-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .signal-card { padding: 12px; }

  /* Reports — natural scroll */
  .reports {
    overflow: visible;
    max-height: none;
    padding: 0 16px 16px;
  }

  .report-item {
    padding: 14px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    border-bottom: 1px solid var(--border-color);
  }
  .report-item:hover { padding-left: 16px; }
  .report-item__location { font-size: 0.88rem; }
  .report-item__summary { font-size: 0.76rem; }

  .sidebar__disclaimer { text-align: center; padding: 14px 20px; }

  /* Feed — show on mobile, stacked below */
  .feed {
    display: flex;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    overflow: visible;
    order: 3;
  }
  .feed__items {
    overflow: visible;
    max-height: none;
  }

  /* Footer */
  .footer {
    flex-direction: column;
    padding: 14px 16px;
    gap: 6px;
    text-align: center;
  }
  .footer__label { text-align: center; width: 100%; }
}

/* ============================================
   RESPONSIVE — SMALL MOBILE (≤ 480px)
   ============================================ */
@media (max-width: 480px) {
  .header { padding: 8px 12px; }
  .header__logo { width: 26px; height: 26px; font-size: 13px; }
  .header__title { font-size: 0.92rem; }
  .header__brand { gap: 8px; }
  .header__live { font-size: 0.6rem; }

  .map-container { height: 45vh; min-height: 240px; }

  .sidebar__section { padding: 10px 12px 6px; }
  .signal-card { padding: 10px; }
  .signal-card__label { font-size: 0.76rem; }
  .signal-card__count { font-size: 0.78rem; }

  .search__input { padding: 8px 10px 8px 32px; font-size: 0.78rem; }

  .reports { padding: 0 12px 12px; }
  .report-item { padding: 12px; }
  .report-item__location { font-size: 0.82rem; }

  .feed-item { padding: 12px; }
  .feed-item__text { font-size: 0.76rem; }
  .feed-item__footer { gap: 10px; font-size: 0.65rem; }
}
