/* ========================================================
   D'Alert – Global Design System
   Dark blue-black theme, Inter font, micro-animations
   ======================================================== */

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

:root {
  --bg: #080c14;
  --surface: #0d1320;
  --surface-2: #131a2e;
  --border: #1e2d4d;
  --accent: #1de9b6;
  --accent-2: #2979ff;
  --danger: #e53935;
  --warn: #ffb300;
  --ok: #00c853;
  --text: #e8eaf6;
  --text-dim: #7986cb;
  --hud-font: 'Inter', sans-serif;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--hud-font);
  overflow-x: hidden;
}

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

/* ── Landing Page ─────────────────────────────────────── */
body.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Animated dot grid background */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    radial-gradient(circle, rgba(29, 233, 182, .10) 1px, transparent 1px);
  background-size: 32px 32px;
  animation: drift 40s linear infinite;
}

@keyframes drift {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 320px 320px;
  }
}

/* Floating orbs */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}

.orb-1 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(41, 121, 255, .28), transparent 70%);
  top: -100px;
  left: -80px;
  animation: orb-drift 18s ease-in-out infinite alternate;
}

.orb-2 {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(29, 233, 182, .22), transparent 70%);
  bottom: -80px;
  right: -60px;
  animation: orb-drift 22s ease-in-out infinite alternate-reverse;
}

@keyframes orb-drift {
  from {
    transform: translate(0, 0);
  }

  to {
    transform: translate(40px, 30px);
  }
}

.hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  padding: 32px 20px;
  max-width: 680px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 2.6rem;
  filter: drop-shadow(0 0 14px var(--accent));
}

.brand-name {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #e8eaf6, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.accent {
  -webkit-text-fill-color: var(--accent);
}

.tagline {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.subtitle {
  font-size: .95rem;
  color: var(--text-dim);
  line-height: 1.7;
}

/* Feature pills */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 4px 0;
}

.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: border-color .2s, color .2s;
}

.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* CTA Button */
.btn-start {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 16px 42px;
  border-radius: 50px;
  box-shadow: 0 0 32px rgba(29, 233, 182, .35);
  transition: transform .2s, box-shadow .2s;
  margin-top: 8px;
}

.btn-start:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 0 52px rgba(29, 233, 182, .55);
}

.btn-icon {
  font-size: 1rem;
}

.hint {
  font-size: .78rem;
  color: var(--text-dim);
}

/* Footer */
.footer {
  position: fixed;
  bottom: 16px;
  font-size: .72rem;
  color: #3d4f6b;
  z-index: 1;
  letter-spacing: .3px;
}

/* ── Monitor Page ──────────────────────────────────────── */
body.monitor-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon-sm {
  font-size: 1.4rem;
  filter: drop-shadow(0 0 8px var(--accent));
}

.brand-name-sm {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, #e8eaf6, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Status badge */
.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 6px 18px;
  font-size: .85rem;
  font-weight: 600;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background .3s;
}

.status-dot.dot-ok {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.status-dot.dot-danger {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: pulse-dot .7s ease-in-out infinite alternate;
}

@keyframes pulse-dot {
  from {
    opacity: 1;
  }

  to {
    opacity: .3;
  }
}

/* Back / Exit button */
.btn-back {
  background: #b91c1c;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 10px 22px;
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: background .2s, box-shadow .2s, transform .15s;
}

.btn-back:hover {
  background: #ef4444;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.55);
  transform: translateY(-1px);
}

/* Layout */
.monitor-layout {
  display: flex;
  flex: 1;
  gap: 0;
  padding: 28px;
  align-items: flex-start;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
}

/* Video section */
.video-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.video-wrap {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, .5);
  transition: border-color .2s, box-shadow .2s;
}

.video-wrap.wrap-danger {
  border-color: var(--danger);
  box-shadow: 0 0 40px rgba(229, 57, 53, .5);
  animation: border-flash .5s ease-in-out infinite alternate;
}

@keyframes border-flash {
  from {
    box-shadow: 0 0 20px rgba(229, 57, 53, .4);
  }

  to {
    box-shadow: 0 0 60px rgba(229, 57, 53, .9);
  }
}

.video-feed {
  display: block;
  width: 640px;
  height: 480px;
  object-fit: cover;
}

/* Drowsy overlay text */
.drowsy-overlay {
  display: none;
  position: absolute;
  inset: 0;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 24px;
  pointer-events: none;
}

.drowsy-label {
  background: rgba(180, 0, 0, .75);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 10px 32px;
  border-radius: 8px;
  animation: label-pulse .6s ease-in-out infinite alternate;
  letter-spacing: 1px;
}

@keyframes label-pulse {
  from {
    opacity: 1;
  }

  to {
    opacity: .6;
  }
}

.feed-caption {
  font-size: .75rem;
  color: var(--text-dim);
  letter-spacing: .3px;
}

/* ── Stats Sidebar ─────────────────────────────────────── */
.stats-sidebar {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* Alert card */
.alert-card {
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background .3s, border-color .3s;
}

.alert-card.alert-danger {
  background: rgba(229, 57, 53, .12);
  border-color: var(--danger);
  animation: card-pulse .6s ease-in-out infinite alternate;
}

.alert-card.alert-ok {
  background: rgba(0, 200, 83, .08);
  border-color: rgba(0, 200, 83, .4);
}

@keyframes card-pulse {
  from {
    box-shadow: none;
  }

  to {
    box-shadow: 0 0 24px rgba(229, 57, 53, .4);
  }
}

.alert-icon {
  font-size: 2rem;
  margin-bottom: 6px;
}

.alert-label {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.alert-sub {
  font-size: .78rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.alert-card.alert-danger .alert-label {
  color: var(--danger);
}

.alert-card.alert-ok .alert-label {
  color: var(--ok);
}

/* Metric rows */
.metric-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-label {
  font-size: .78rem;
  color: var(--text-dim);
  width: 60px;
  flex-shrink: 0;
}

.metric-value {
  font-size: .82rem;
  font-weight: 600;
  width: 56px;
  text-align: right;
  flex-shrink: 0;
}

.metric-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.metric-bar {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .25s ease, background .3s;
}

/* Counter grid */
.counter-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.counter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.counter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 6px;
  text-align: center;
  transition: border-color .3s, background .3s;
}

.counter-card.cc-danger {
  background: rgba(229, 57, 53, .15);
  border-color: var(--danger);
}

.counter-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}

.counter-desc {
  font-size: .68rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.counter-card.cc-danger .counter-num {
  color: var(--danger);
}

/* Triggers */
.trigger-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(229, 57, 53, .10);
  border: 1px solid rgba(229, 57, 53, .4);
  border-radius: 8px;
  padding: 8px 14px;
}

.trigger-label {
  font-size: .78rem;
  color: var(--text-dim);
}

.trigger-val {
  font-size: .82rem;
  font-weight: 700;
  color: var(--danger);
}

/* FPS */
.fps-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.fps-label {
  font-size: .78rem;
  color: var(--text-dim);
}

.fps-val {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 800px) {
  .video-feed {
    width: 100%;
    height: auto;
  }

  .video-wrap {
    width: 100%;
  }

  .stats-sidebar {
    width: 100%;
  }

  .monitor-layout {
    padding: 16px;
  }
}