/* ============================================================
   Camera Relay Dashboard – styles.css
   Design: professional dark theme, minimal, responsive
   ============================================================ */

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

:root {
  --bg:           #0a0b0d;
  --bg-surface:   #111318;
  --bg-elevated:  #181b22;
  --border:       #1f2330;
  --border-light: #262c3a;

  --text-primary:   #e8eaf0;
  --text-secondary: #8891a6;
  --text-muted:     #4b5268;

  --green:   #22c55e;
  --red:     #ef4444;
  --amber:   #f59e0b;
  --blue:    #3b82f6;

  --green-dim: rgba(34,197,94,.12);
  --red-dim:   rgba(239,68,68,.12);
  --amber-dim: rgba(245,158,11,.10);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-base: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --shadow-card: 0 1px 3px rgba(0,0,0,.5), 0 0 0 1px var(--border);
}

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

body {
  font-family: var(--font-base);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  /* Subtle grid texture */
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ── Utilities ────────────────────────────────────────────── */
.hidden { display: none !important; }
.mono   { font-family: var(--font-mono); font-size: .85rem; }

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
  background: rgba(10,11,13,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.camera-icon {
  width: 30px;
  height: 30px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

.topbar-title {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .15em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* ── Live badge ───────────────────────────────────────────── */
.live-badge {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .3rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  transition: all .3s ease;
}

.live-badge.is-online {
  color: var(--green);
  border-color: rgba(34,197,94,.35);
  background: var(--green-dim);
}

.live-badge.is-offline {
  color: var(--red);
  border-color: rgba(239,68,68,.35);
  background: var(--red-dim);
}

.live-badge.is-warning {
  color: var(--amber);
  border-color: rgba(245,158,11,.35);
  background: var(--amber-dim);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.live-badge.is-online .live-dot {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34,197,94,.6);
  animation: pulse 2s infinite;
}

.live-badge.is-offline .live-dot {
  background: var(--red);
}

.live-badge.is-warning .live-dot {
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(245,158,11,.6);
  animation: pulse-amber 2s infinite;
}

@keyframes pulse-amber {
  0%   { box-shadow: 0 0 0 0   rgba(245,158,11,.6); }
  70%  { box-shadow: 0 0 0 6px rgba(245,158,11,.0); }
  100% { box-shadow: 0 0 0 0   rgba(245,158,11,.0); }
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0   rgba(34,197,94,.6); }
  70%  { box-shadow: 0 0 0 6px rgba(34,197,94,.0); }
  100% { box-shadow: 0 0 0 0   rgba(34,197,94,.0); }
}

/* ── Main layout ──────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Player section ───────────────────────────────────────── */
.player-section {
  width: 100%;
}

.player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,.6);
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
}

.placeholder-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.placeholder-icon {
  color: var(--text-muted);
  opacity: .6;
}

.placeholder-text {
  font-size: .95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.placeholder-sub {
  font-size: .8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.yt-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Status section ───────────────────────────────────────── */
.status-section {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.status-item {
  background: var(--bg-surface);
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  transition: background .2s ease;
}

.status-item:hover {
  background: var(--bg-elevated);
}

.status-item--wide {
  grid-column: span 2;
}

.status-label {
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.status-value {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .45rem;
}

/* ── Status indicators ────────────────────────────────────── */
.indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
  transition: background .3s;
}

.indicator.ok      { background: var(--green); }
.indicator.warn    { background: var(--amber); }
.indicator.error   { background: var(--red);   }

/* ── Error banner ─────────────────────────────────────────── */
.error-banner {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1rem;
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius-md);
  color: #fca5a5;
  font-size: .82rem;
  font-family: var(--font-mono);
  line-height: 1.5;
  word-break: break-word;
}

.error-banner svg { flex-shrink: 0; color: var(--red); }

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 1rem 1.25rem;
  font-size: .75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.footer-sep { opacity: .4; }

.footer-link {
  color: var(--blue);
  text-decoration: none;
  opacity: .8;
  transition: opacity .2s;
}

.footer-link:hover { opacity: 1; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .status-item--wide {
    grid-column: span 2;
  }
  .topbar-title { display: none; }
}

@media (max-width: 380px) {
  .status-grid {
    grid-template-columns: 1fr;
  }
  .status-item--wide { grid-column: span 1; }
}

/* ── Login overlay ────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 40px 40px;
  padding: 1.5rem;
}

.login-overlay.fade-out {
  animation: fadeOut .35s ease forwards;
}

@keyframes fadeOut {
  to { opacity: 0; pointer-events: none; }
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem 2rem;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.04) inset,
    0 24px 60px rgba(0,0,0,.7);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: slideUp .35s cubic-bezier(.16,1,.3,1) both;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  width: 48px;
  height: 48px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  margin-bottom: -.25rem;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
  line-height: 1.2;
}

.login-subtitle {
  font-size: .82rem;
  color: var(--text-secondary);
  margin-top: -.75rem;
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.login-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.login-input-wrap {
  position: relative;
}

.login-input {
  width: 100%;
  padding: .72rem 2.6rem .72rem .9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: .95rem;
  letter-spacing: .08em;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.login-input::placeholder {
  color: var(--text-muted);
  letter-spacing: .04em;
}

.login-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.login-input.is-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239,68,68,.15);
  animation: shake .4s cubic-bezier(.36,.07,.19,.97);
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px);  }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px);  }
}

.toggle-pw {
  position: absolute;
  right: .7rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: .25rem;
  cursor: pointer;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  transition: color .2s;
  border-radius: 4px;
}

.toggle-pw:hover { color: var(--text-secondary); }

.login-error {
  font-size: .78rem;
  color: #fca5a5;
  padding: .5rem .75rem;
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius-sm);
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .78rem 1.25rem;
  background: var(--blue);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-base);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s, box-shadow .2s;
  box-shadow: 0 2px 12px rgba(59,130,246,.3);
  margin-top: .15rem;
}

.login-btn:hover {
  background: #2563eb;
  box-shadow: 0 4px 18px rgba(59,130,246,.45);
}

.login-btn:active { transform: scale(.98); }

