@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-black: #000000;
  --bg-surface: #0a0a0a;
  --bg-elevated: #121212;
  --bg-subtle: #18181b;

  --border-subtle: #27272a;
  --border-strong: #3f3f46;

  --text-main: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --status-live: #22c55e;
  --status-lag: #eab308;
  --status-error: #ef4444;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-black);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================
   VIEWER - PANTALLA COMPLETA
   ========================================================== */
.viewer-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background-color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000000;
  display: block;
}

/* Pantalla de Espera Formal */
.waiting-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #000000;
  z-index: 10;
  text-align: center;
  padding: 32px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.waiting-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.standby-line {
  width: 48px;
  height: 2px;
  background: #27272a;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.standby-line::after {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 50%;
  height: 100%;
  background: #ffffff;
  animation: sweep 2s infinite ease-in-out;
}

@keyframes sweep {
  0% { left: -50%; }
  100% { left: 100%; }
}

.waiting-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffffff;
  margin-bottom: 8px;
}

.waiting-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  max-width: 400px;
  margin-bottom: 24px;
}

.waiting-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse-dot 2s infinite;
}

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

/* ==========================================================
   OVERLAY DEL REPRODUCTOR
   ========================================================== */
.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s ease;
  z-index: 20;
}

.player-overlay.idle {
  opacity: 0;
}

.player-overlay * {
  pointer-events: auto;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 10, 10, 0.9);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.brand-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-main);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  background: #18181b;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.live-pill.live-active {
  background: rgba(34, 197, 94, 0.1);
  color: var(--status-live);
  border-color: rgba(34, 197, 94, 0.25);
}

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

.live-pill.live-active .live-dot {
  background: var(--status-live);
}

.viewers-count {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.overlay-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  background: rgba(10, 10, 10, 0.9);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-sans);
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
}

.ctrl-btn:hover {
  background: #18181b;
  color: #ffffff;
  border-color: var(--border-strong);
}

.unmute-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #0a0a0a;
  border: 1px solid var(--border-strong);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  z-index: 25;
}

.unmute-banner.hidden {
  display: none;
}

/* ==========================================================
   WIDGET FLOTANTE MINIMALISTA (NADA INVASIVO)
   ========================================================== */
.floating-status-pill {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  background: #000000;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  cursor: move;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
}

.floating-status-pill.state-live {
  border-color: #27272a;
}

.floating-status-pill.state-live .status-indicator {
  background: var(--status-live);
}

.floating-status-pill.state-lag .status-indicator {
  background: var(--status-lag);
}

.floating-status-pill.state-error .status-indicator {
  background: var(--status-error);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-text-wrap {
  display: flex;
  flex-direction: column;
}

.status-main-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.status-sub-stats {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.pill-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  border-left: 1px solid var(--border-subtle);
  padding-left: 8px;
}

.pill-mini-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-mono);
}

.pill-mini-btn:hover {
  color: #ffffff;
  background: #18181b;
}

.floating-status-pill.collapsed {
  padding: 6px 10px;
  gap: 8px;
}

.floating-status-pill.collapsed .status-sub-stats,
.floating-status-pill.collapsed .pill-controls {
  display: none;
}

/* ==========================================================
   PANEL ADMINISTRADOR - ESTILO FORMAL Y FONDO NEGRO
   ========================================================== */
.admin-page-body {
  background-color: var(--bg-black);
  min-height: 100vh;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.admin-header {
  width: 100%;
  max-width: 1120px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-title-wrap h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: #ffffff;
}

.admin-title-wrap p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.admin-grid {
  width: 100%;
  max-width: 1120px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}

/* Auth Card */
.auth-card {
  max-width: 380px;
  width: 100%;
  margin: 100px auto 0;
  text-align: left;
}

.auth-input-group {
  margin: 20px 0 16px;
}

.auth-input-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.input-field {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-black);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.input-field:focus {
  border-color: #ffffff;
}

.primary-btn {
  width: 100%;
  padding: 10px 16px;
  background: #ffffff;
  color: #000000;
  border: 1px solid #ffffff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-btn:hover {
  background: #e4e4e7;
  border-color: #e4e4e7;
}

.stop-btn {
  background: transparent;
  color: var(--status-error);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.stop-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--status-error);
  color: var(--status-error);
}

.secondary-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.secondary-btn:hover {
  color: #ffffff;
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

/* Modos de Captura */
.source-selection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.source-card {
  background: var(--bg-black);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.source-card:hover {
  border-color: var(--border-strong);
}

.source-card.active {
  border-color: #ffffff;
  background: var(--bg-elevated);
}

.source-title {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 4px;
}

.source-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Contenedor de Preview y Recorte */
.preview-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cropper-overlay {
  position: absolute;
  inset: 0;
  display: none;
  cursor: crosshair;
}

.cropper-overlay.active {
  display: block;
}

.crop-box {
  position: absolute;
  border: 1px solid #ffffff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75);
  cursor: move;
}

.crop-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #000000;
  border: 1px solid #ffffff;
}

.handle-nw { top: -4px; left: -4px; cursor: nwse-resize; }
.handle-ne { top: -4px; right: -4px; cursor: nesw-resize; }
.handle-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.handle-se { bottom: -4px; right: -4px; cursor: nwse-resize; }

.crop-coords-tag {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: #000000;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 2px;
  pointer-events: none;
}

/* Estadísticas formales */
.stats-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.stat-item {
  background: var(--bg-black);
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.stat-item-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.stat-item-val {
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: #ffffff;
}

.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #18181b;
  border: 1px solid var(--border-strong);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10000;
}

.toast-msg.show {
  opacity: 1;
  transform: translate(-50%, -6px);
}
