/* NexWatch Status Portal - TTC DEV */

:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-raised: #191919;
  --surface-hover: #1e1e1e;
  --border: #222222;
  --border-light: #2a2a2a;
  --text: #e5e5e5;
  --text-muted: #888888;
  --text-dim: #555555;
  --accent-green: #22c55e;
  --accent-green-bg: rgba(34, 197, 94, 0.08);
  --accent-green-border: rgba(34, 197, 94, 0.2);
  --accent-yellow: #f59e0b;
  --accent-yellow-bg: rgba(245, 158, 11, 0.08);
  --accent-yellow-border: rgba(245, 158, 11, 0.2);
  --accent-red: #ef4444;
  --accent-red-bg: rgba(239, 68, 68, 0.08);
  --accent-red-border: rgba(239, 68, 68, 0.2);
  --accent-blue: #3b82f6;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
  --transition: 150ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---- HEADER ---- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-sub {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.refresh-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.refresh-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse-dot 2s ease-in-out infinite;
}

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

/* ---- STATUS BANNER ---- */

.status-banner {
  max-width: 1280px;
  margin: 24px auto 0;
  padding: 0 24px;
}

.banner-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid;
  font-weight: 600;
  font-size: 0.9375rem;
}

.banner-card.operational {
  background: var(--accent-green-bg);
  border-color: var(--accent-green-border);
  color: var(--accent-green);
}

.banner-card.degraded {
  background: var(--accent-yellow-bg);
  border-color: var(--accent-yellow-border);
  color: var(--accent-yellow);
}

.banner-card.major-outage {
  background: var(--accent-red-bg);
  border-color: var(--accent-red-border);
  color: var(--accent-red);
}

.banner-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.banner-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8125rem;
  font-weight: 400;
}

.incident-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid var(--accent-red-border);
}

.incident-badge.none {
  background: var(--surface-raised);
  color: var(--text-muted);
  border-color: var(--border);
}

/* ---- CONTROLS BAR ---- */

.controls {
  max-width: 1280px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  transition: border-color var(--transition);
  outline: none;
}

.search-box input:focus {
  border-color: var(--border-light);
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.filter-group {
  display: flex;
  gap: 4px;
}

.filter-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.filter-btn.active {
  background: var(--surface-raised);
  color: #fff;
  border-color: var(--border-light);
}

.station-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* ---- STATION GRID ---- */

.station-grid {
  max-width: 1280px;
  margin: 20px auto 0;
  padding: 0 24px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.station-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.station-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-callsign {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.card-market {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.status-dot.operational { background: var(--accent-green); box-shadow: 0 0 8px rgba(34, 197, 94, 0.4); }
.status-dot.degraded { background: var(--accent-yellow); box-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }
.status-dot.down { background: var(--accent-red); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); animation: pulse-red 1.5s ease-in-out infinite; }
.status-dot.unknown { background: var(--text-dim); }

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.6); }
}

.card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.stat-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-value.good { color: var(--accent-green); }
.stat-value.warn { color: var(--accent-yellow); }
.stat-value.bad { color: var(--accent-red); }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.card-footer-link {
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--transition);
}

.card-footer-link:hover {
  color: #fff;
}

/* ---- EMPTY STATE ---- */

.empty-state {
  max-width: 1280px;
  margin: 60px auto;
  padding: 0 24px;
  text-align: center;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-dim);
  margin: 0 auto 16px;
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto;
}

/* ---- DEMO BANNER ---- */

.demo-banner {
  max-width: 1280px;
  margin: 16px auto 0;
  padding: 0 24px;
}

.demo-banner-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  font-size: 0.8125rem;
  color: var(--accent-blue);
}

/* ---- STATION DETAIL PAGE ---- */

.detail-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 20px 0 24px;
  transition: color var(--transition);
}

.back-link:hover {
  color: #fff;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}

.detail-title {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.detail-market {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.detail-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.detail-status-badge.operational {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid var(--accent-green-border);
}

.detail-status-badge.degraded {
  background: var(--accent-yellow-bg);
  color: var(--accent-yellow);
  border: 1px solid var(--accent-yellow-border);
}

.detail-status-badge.down {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid var(--accent-red-border);
}

.detail-status-badge.unknown {
  background: var(--surface-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ---- METRIC CARDS ---- */

.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.metric-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.metric-value.good { color: var(--accent-green); }
.metric-value.warn { color: var(--accent-yellow); }
.metric-value.bad { color: var(--accent-red); }

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ---- SECTIONS ---- */

.section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ---- RESPONSE TIME CHART ---- */

.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow-x: auto;
}

.chart-container svg {
  width: 100%;
  height: auto;
}

.chart-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 0.875rem;
}

/* ---- LIGHTHOUSE SCORES ---- */

.lighthouse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.lh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}

.lh-score {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lh-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- INCIDENT TIMELINE ---- */

.incident-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.incident-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.incident-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.incident-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
}

.severity-tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.severity-tag.critical {
  background: var(--accent-red-bg);
  color: var(--accent-red);
}

.severity-tag.high {
  background: rgba(249, 115, 22, 0.1);
  color: #f97316;
}

.severity-tag.medium {
  background: var(--accent-yellow-bg);
  color: var(--accent-yellow);
}

.severity-tag.low {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-blue);
}

.incident-status-line {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.incident-status-label {
  font-weight: 600;
}

.incident-status-label.resolved { color: var(--accent-green); }
.incident-status-label.investigating { color: var(--accent-yellow); }
.incident-status-label.detected { color: var(--accent-red); }
.incident-status-label.acknowledged { color: var(--accent-blue); }

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 12px;
  padding-left: 16px;
  border-left: 2px solid var(--border);
}

.timeline-event {
  position: relative;
  padding: 0 0 16px 16px;
}

.timeline-event:last-child {
  padding-bottom: 0;
}

.timeline-event::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-light);
}

.timeline-event.active::before {
  background: var(--accent-green);
  border-color: var(--accent-green);
}

.timeline-time {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.timeline-text {
  font-size: 0.8125rem;
  color: var(--text);
  margin-top: 2px;
}

/* ---- LOADING / SKELETON ---- */

.loading-container {
  max-width: 1280px;
  margin: 40px auto;
  padding: 0 24px;
  text-align: center;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

.loading-text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ---- FOOTER ---- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 24px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-link {
  color: var(--text-muted);
  transition: color var(--transition);
}

.footer-link:hover {
  color: #fff;
}

/* ---- RESPONSIVE ---- */

@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
  }

  .header-meta {
    width: 100%;
    justify-content: flex-start;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: none;
  }

  .filter-group {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .station-count {
    margin-left: 0;
  }

  .station-grid {
    grid-template-columns: 1fr;
  }

  .detail-header {
    flex-direction: column;
  }

  .metric-row {
    grid-template-columns: 1fr 1fr;
  }

  .brand-name {
    font-size: 1.25rem;
  }

  .detail-title {
    font-size: 1.5rem;
  }

  .footer-inner {
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .metric-row {
    grid-template-columns: 1fr;
  }

  .lighthouse-grid {
    grid-template-columns: 1fr 1fr;
  }

  .banner-right {
    display: none;
  }
}
