/* ============================================================
   OptiStreamAI — Design System & Layout
   AI-Powered Data Quality for U.S. Video Streaming
   Ronex Solutions LLC · Florida · 2026
   ============================================================ */

:root {
  --primary: #3B5BDB;
  --primary-2: #5C7CFA;
  --primary-soft: #EEF2FF;
  --bg: #F4F6FB;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --border-soft: #F1F3F8;
  --text: #1F2937;
  --text-muted: #6B7280;
  --text-faint: #9CA3AF;
  --green: #10B981;
  --green-soft: #ECFDF5;
  --orange: #F59E0B;
  --orange-soft: #FFFBEB;
  --red: #EF4444;
  --red-soft: #FEF2F2;
  --shadow: 0 1px 3px rgba(15,23,42,0.04), 0 4px 16px rgba(15,23,42,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ====================================================
   TOP NAVIGATION
   ==================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 28px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  display: inline-block;
  width: 26px; height: 26px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  position: relative;
}
.brand-logo::after {
  content: "O";
  color: white;
  font-weight: 700;
  font-size: 16px;
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -0.5px;
}
.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.2px;
}

.topnav { display: flex; gap: 36px; }
.topnav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}
.topnav a:hover { color: var(--text); }
.topnav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }
.env-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--orange-soft);
  color: #92400E;
  font-weight: 500;
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

/* ====================================================
   LAYOUT — FILTERS + MAIN CONTENT
   ==================================================== */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  min-height: calc(100vh - 56px - 40px);
}

.filters {
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.filters h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}
.filter-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
  display: block;
}
.filters select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #FFFFFF;
  font-size: 13px;
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.filters select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn-apply {
  margin-top: 8px;
  padding: 9px 12px;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s;
}
.btn-apply:hover { background: #2F4BC4; }
.filter-meta {
  margin-top: 20px;
  padding: 12px;
  background: var(--orange-soft);
  border-radius: 8px;
  font-size: 11px;
  color: #92400E;
  line-height: 1.5;
}
.filter-meta p { margin: 0 0 4px; }
.filter-meta p:last-child { margin-bottom: 0; }

.content {
  padding: 28px 32px;
  max-width: 1500px;
  width: 100%;
}

/* ====================================================
   PAGE HEADER
   ==================================================== */
.page-header { margin-bottom: 20px; }
.page-header h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.page-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ====================================================
   SUBNAV (Anomaly Detection inner tabs)
   ==================================================== */
.subnav {
  display: flex;
  gap: 28px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.subnav a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 0;
  border-bottom: 2px solid transparent;
}
.subnav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ====================================================
   KPI TILES
   ==================================================== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.kpi-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin: 2px 0;
}
.kpi-delta {
  font-size: 11px;
  font-weight: 500;
}
.kpi-delta.positive { color: var(--green); }
.kpi-delta.negative { color: var(--red); }
.kpi-delta.neutral { color: var(--text-faint); }

/* ====================================================
   CARDS
   ==================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.card-meta {
  font-size: 11px;
  color: var(--text-faint);
}

/* Split layout for Anomaly Detection / Incidents */
.split {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  margin-bottom: 18px;
}
.split .card { margin-bottom: 0; }

/* ====================================================
   CHARTS
   ==================================================== */
.chart-wrap {
  position: relative;
  height: 220px;
  width: 100%;
}
.legend {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* ====================================================
   DATA TABLES
   ==================================================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #F8FAFC; }
.data-table tbody tr:last-child td { border-bottom: none; }

.sev { font-weight: 600; }
.sev-critical, .sev-high { color: var(--red); }
.sev-medium { color: var(--orange); }
.sev-low { color: var(--green); }

.status { font-weight: 500; }
.status-investigating { color: var(--orange); }
.status-mitigated, .status-closed, .status-healthy { color: var(--green); }
.status-open, .status-triaged { color: var(--orange); }
.status-pending, .status-in-progress { color: var(--orange); }
.status-not-required { color: var(--text-faint); font-style: italic; }

/* ====================================================
   ANOMALY DETECTION — SIDEBAR
   ==================================================== */
.sidebar-card h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
}
.sidebar-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.sidebar-section:last-child { border-bottom: none; padding-bottom: 0; }
.sidebar-label {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 4px;
}
.sidebar-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li {
  display: grid;
  grid-template-columns: 100px 1fr 30px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  margin-bottom: 6px;
}
.bar {
  height: 6px;
  background: var(--border-soft);
  border-radius: 3px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 3px;
}

/* Buttons in sidebar */
.btn-primary, .btn-secondary {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s;
  margin-right: 6px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #2F4BC4; }
.btn-secondary { background: white; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }

/* ====================================================
   CORRELATION MAP (Incidents)
   ==================================================== */
.corr-map {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0;
  padding: 18px 4px;
  overflow-x: auto;
}
.corr-node {
  padding: 9px 12px;
  border: 1.5px solid;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: white;
  white-space: nowrap;
  flex-shrink: 0;
}
.corr-node.ok { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.corr-node.warn { color: var(--orange); border-color: var(--orange); background: var(--orange-soft); }
.corr-node.crit { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.corr-arrow {
  flex: 1 1 auto;
  min-width: 14px;
  max-width: 36px;
  height: 2px;
  background: var(--text-muted);
  position: relative;
  margin: 0 4px;
}
.corr-arrow::after {
  content: "";
  position: absolute;
  right: -1px; top: -3px;
  border-left: 6px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

/* ====================================================
   INGESTION LOGS
   ==================================================== */
.logs {
  background: #0F172A;
  color: #E2E8F0;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 12px;
  padding: 14px 18px;
  border-radius: 8px;
  line-height: 1.7;
  max-height: 240px;
  overflow-y: auto;
}
.log-line { white-space: nowrap; }
.log-time { color: #94A3B8; margin-right: 12px; }
.log-msg.ok { color: #4ADE80; }
.log-msg.warn { color: #FBBF24; }
.log-msg.crit { color: #F87171; }
.log-msg.info { color: #93C5FD; }

/* ====================================================
   FEEDBACK TIMELINE
   ==================================================== */
.timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  position: relative;
  padding: 24px 0 16px;
}
.timeline::before {
  content: "";
  position: absolute;
  top: 48px;
  left: 12%;
  right: 12%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.timeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}
.t-time {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.t-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid white;
  box-shadow: 0 0 0 2px var(--primary);
  margin-bottom: 12px;
}
.t-label {
  font-size: 13px;
  font-weight: 600;
}
.t-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ====================================================
   FOOTER
   ==================================================== */
.appfooter {
  height: 40px;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  font-size: 11px;
  color: var(--text-faint);
}

/* ====================================================
   DEMO TOUR (auto-walk through views with captions)
   ==================================================== */
.btn-tour {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: 0 1px 2px rgba(59,91,219,0.3);
  transition: transform 0.1s, box-shadow 0.2s;
}
.btn-tour:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(59,91,219,0.4);
}
.btn-tour.running {
  background: linear-gradient(135deg, #DC2626, #EF4444);
}

#tour-overlay {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1000;
  pointer-events: none;
}
.tour-progress {
  height: 3px;
  background: rgba(15,23,42,0.1);
}
#tour-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.3s linear;
}
.tour-caption {
  background: linear-gradient(180deg, rgba(15,23,42,0.94), rgba(15,23,42,0.98));
  color: white;
  padding: 18px 32px 22px;
  display: flex;
  align-items: center;
  gap: 24px;
  pointer-events: auto;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}
.tour-time {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 13px;
  color: #94A3B8;
  flex-shrink: 0;
  min-width: 80px;
}
.tour-text {
  font-size: 16px;
  line-height: 1.5;
  flex: 1;
  font-weight: 500;
  letter-spacing: 0.1px;
  opacity: 0;
  animation: tourFade 0.4s ease forwards;
}
.tour-text.swap { animation: none; opacity: 0; transform: translateY(4px); }
@keyframes tourFade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tour-stop {
  background: rgba(255,255,255,0.08);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.tour-stop:hover { background: rgba(255,255,255,0.16); }

/* During tour, dim filters sidebar slightly so attention is on content */
body.tour-running .filters { opacity: 0.4; pointer-events: none; transition: opacity 0.3s; }
body.tour-running .topnav a { pointer-events: none; }

/* ====================================================
   RESPONSIVE TWEAKS (1280px target)
   ==================================================== */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
