/* ─── Camcastar Web — Laptop Layout ───────────────────────────────────────────── */

/* ─── Desktop: lock entire page to viewport, no scroll ───────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ─── Nav ─────────────────────────────────────────────────────────────────── */
.nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}
.brand-icon {
  font-size: 17px;
  color: var(--accent);
  line-height: 1;
}
.brand-name {
  font-family: var(--font-brand);
  font-size: 15px;
  letter-spacing: 0.25em;
  color: var(--text);
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  background: transparent;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  transition: all var(--t);
  cursor: pointer;
  border: none;
  font-family: var(--font-body);
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ─── Main Layout ─────────────────────────────────────────────────────────── */
.main-layout {
  flex: 1;
  min-height: 0;          /* critical: lets flex child shrink below content size */
  display: grid;
  grid-template-columns: 1fr 320px;
  overflow: hidden;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 7px 20px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-surface);
  line-height: 1;
}
.footer-link {
  color: var(--text-dim);
  text-decoration: none;
  transition: color var(--t);
}
.footer-link:hover { color: var(--accent-text); }

/* ─── Video Panel ─────────────────────────────────────────────────────────── */
.video-panel {
  position: relative;
  isolation: isolate;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Scanline texture */
.video-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 2;
}

#remote-video {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transform: scaleX(-1);
  transition: transform 0.3s ease;
}
#remote-video.no-mirror { transform: scaleX(1); }

/* ─── Viewfinder Overlay ──────────────────────────────────────────────────── */
.viewfinder-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.vf-corner {
  position: absolute;
  width: 22px; height: 22px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.6;
}
.vf-corner.tl { top: 14px; left: 14px;  border-width: 2px 0 0 2px; }
.vf-corner.tr { top: 14px; right: 14px; border-width: 2px 2px 0 0; }
.vf-corner.bl { bottom: 14px; left: 14px;  border-width: 0 0 2px 2px; }
.vf-corner.br { bottom: 14px; right: 14px; border-width: 0 2px 2px 0; }

.vf-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
}
.vf-center::before, .vf-center::after {
  content: '';
  position: absolute;
  background: rgba(0,170,255,0.4);
}
.vf-center::before { width: 1px; height: 100%; left: 50%; transform: translateX(-50%); }
.vf-center::after  { height: 1px; width: 100%; top: 50%; transform: translateY(-50%); }

/* ─── HUD ─────────────────────────────────────────────────────────────────── */
.video-hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.hud-top {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.hud-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 3px 7px;
  border-radius: var(--r-sm);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
}
.hud-badge.rec-badge {
  color: var(--red);
  border-color: rgba(255,53,53,0.4);
  background: rgba(255,53,53,0.12);
  display: flex;
  align-items: center;
  gap: 5px;
}
.hud-latency {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255,255,255,0.3);
}

/* ─── Video Action Buttons ────────────────────────────────────────────────── */

/* Restart Stream — pinned to left edge of video panel */
.restart-wrap {
  display: none;
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 10;
}
.restart-wrap.show { display: flex; }

/* Full-panel loading while stream reconnects */
.restart-stream-overlay {
  position: absolute;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 9, 14, 0.88);
  backdrop-filter: blur(8px);
  pointer-events: all;
}
.restart-stream-overlay.hidden {
  display: none !important;
}
.restart-stream-card {
  text-align: center;
  padding: 28px 36px;
  border-radius: var(--r);
  border: 1px solid rgba(0, 170, 255, 0.35);
  background: rgba(12, 16, 24, 0.95);
  max-width: 90%;
}
.restart-stream-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 3px solid rgba(0, 170, 255, 0.25);
  border-top-color: var(--accent, #00aaff);
  border-radius: 50%;
  animation: restart-spin 0.85s linear infinite;
}
@keyframes restart-spin {
  to { transform: rotate(360deg); }
}
.restart-stream-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}
.restart-stream-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
}

/* Mirror + Fullscreen — pinned to right edge */
.video-btn-row {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Shared button style — plain dark, no color change on click */
.video-action-btn {
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r);
  color: rgba(255, 255, 255, 0.8);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background var(--t), border-color var(--t);
  white-space: nowrap;
}
.video-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.35);
}
.video-action-btn:active,
.video-action-btn:focus {
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.18);
  outline: none;
}

.video-btn-hint {
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.4);
  text-transform: none;
}

#btn-restart-stream { display: flex; }

@media (max-width: 900px) {
  .restart-wrap { bottom: 10px; left: 10px; }
  .video-btn-row { bottom: 10px; right: 10px; gap: 6px; }
  .video-action-btn { padding: 7px 11px; font-size: 9px; }
  .video-btn-hint { display: none; }
}

@media (max-width: 480px) {
  .restart-wrap { bottom: 8px; left: 8px; }
  .video-btn-row { bottom: 8px; right: 8px; gap: 5px; }
  .video-action-btn { padding: 6px 9px; }
}
/* ─── QR Screen ───────────────────────────────────────────────────────────── */
.qr-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  z-index: 5;
  transition: opacity 0.4s ease;
  padding: 20px;
}
.qr-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.qr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.qr-title {
  font-family: var(--font-brand);
  font-size: 9px;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.qr-code-wrap {
  padding: 14px;
  background: #fff;
  border-radius: var(--r);
  display: inline-flex;
}

.qr-hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* Wi-Fi note — amber, clearly visible */
.qr-wifi-note {
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  color: #ffaa00;
  line-height: 1.6;
  padding: 10px 14px;
  background: rgba(255,170,0,0.1);
  border: 1px solid rgba(255,170,0,0.4);
  border-radius: var(--r-sm);
  letter-spacing: 0.01em;
}

/* ─── Controls Panel ──────────────────────────────────────────────────────── */
.controls-panel {
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.control-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.control-section:last-of-type {
  border-bottom: none;
}

/* ─── Record Button ───────────────────────────────────────────────────────── */
.record-main-btn {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-brand);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t);
  margin-bottom: 0;
}
.record-main-btn:not(:disabled):hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-dim);
}
.record-main-btn.recording {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-dim);
}

.rec-timer {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.15em;
  color: var(--red);
  text-align: center;
  padding: 10px 0 0;
  display: none;
}
.rec-timer.active { display: block; }

/* ─── Stats Row ───────────────────────────────────────────────────────────── */
.stats-row {
  flex-shrink: 0;
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.stat-item {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-label {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  transition: color var(--t);
}
.stat-value.live { color: var(--accent-text); }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — tablet and mobile: scrollable, QR on top, controls below
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {

  /* Allow page to scroll on small screens */
  html, body {
    height: auto;
    overflow: auto;
  }

  body {
    min-height: 100vh;
  }

  .nav {
    height: 48px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .nav-links { display: none; }

  .main-layout {
    display: flex;
    flex-direction: column;
    overflow: visible;
    min-height: unset;
  }

  /* Video / QR panel: fixed aspect ratio on mobile */
  .video-panel {
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: unset;
    flex-shrink: 0;
  }

  /* Controls stack below */
  .controls-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    overflow-y: visible;
    flex-shrink: 0;
  }

  .control-section {
    padding: 14px 16px;
  }

  .stats-row {
    position: sticky;
    bottom: 0;
    z-index: 10;
  }

  .site-footer {
    padding: 10px 16px;
    font-size: 10px;
  }

  .video-btn-row {
    bottom: 10px;
    right: 10px;
    gap: 6px;
  }
  .video-action-btn {
    padding: 7px 11px;
    font-size: 9px;
  }
}

@media (max-width: 480px) {
  .video-panel {
    aspect-ratio: 4 / 3;
  }

  .qr-card {
    padding: 20px 16px;
    gap: 14px;
  }

  .qr-code-wrap {
    padding: 10px;
  }

  .video-btn-row {
    bottom: 8px;
    right: 8px;
    gap: 5px;
  }
  .video-action-btn {
    padding: 6px 9px;
    font-size: 9px;
  }
}

/* ─── Modals ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(7, 9, 14, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px);
  transition: transform 0.2s ease;
}
.modal-overlay.open .modal-box {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-brand);
  font-size: 11px;
  letter-spacing: 0.25em;
  color: var(--text);
}
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--t);
}
.modal-close:hover {
  border-color: var(--border-bright);
  color: var(--text);
}

.modal-body {
  overflow-y: auto;
  padding: 24px 20px;
  flex: 1;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-step-list { display: flex; flex-direction: column; }

.modal-step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.modal-step:last-child { border-bottom: none; }

.modal-step-num {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--accent-text);
  background: var(--accent-dim);
  border: 1px solid rgba(0,170,255,0.2);
  border-radius: var(--r-sm);
  padding: 3px 8px;
  height: fit-content;
  flex-shrink: 0;
  margin-top: 1px;
}

.modal-step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.modal-step-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
}
.modal-step-desc strong { color: var(--text); font-weight: 600; }

.modal-note-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--accent-dim);
  border: 1px solid rgba(0,170,255,0.2);
  border-radius: var(--r-sm);
  font-size: 11px;
  color: var(--accent-text);
  line-height: 1.6;
}
.modal-warn-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--amber-dim);
  border: 1px solid rgba(255,170,0,0.3);
  border-radius: var(--r-sm);
  font-size: 11px;
  color: var(--amber);
  line-height: 1.6;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}
.modal-table td {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: top;
}
.modal-table td:first-child {
  color: var(--text);
  font-weight: 500;
  width: 110px;
  padding-right: 16px;
}
.modal-table tr:last-child td { border-bottom: none; }

.modal-divider {
  font-family: var(--font-brand);
  font-size: 9px;
  letter-spacing: 0.25em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 20px 0 4px;
  border-bottom: 1px solid var(--border);
}

.modal-about-body {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.9;
}
.modal-about-body p { margin-bottom: 20px; }
.modal-about-body strong { color: var(--text); font-weight: 600; }

@media (max-width: 600px) {
  .modal-overlay { padding: 12px; }
  .modal-box { max-height: 92vh; }
  .modal-body { padding: 16px; }
}
