/* ==========================================================================
   Módulo TV / Pantalla - Citas del Día (Full HD 1920x1080 / 16:9)
   ========================================================================== */

:root {
  --tv-bg-gradient: radial-gradient(circle at 50% 0%, #111a33 0%, #080c16 75%, #050810 100%);
  --tv-card-bg: rgba(16, 24, 44, 0.85);
  --tv-card-border: rgba(255, 255, 255, 0.08);
  --tv-card-hover: rgba(25, 37, 66, 0.95);
  --tv-text-main: #f8fafc;
  --tv-text-muted: #94a3b8;
  --tv-accent-cyan: #06b6d4;
  --tv-accent-blue: #38bdf8;
  --tv-accent-green: #10b981;
  --tv-accent-amber: #f59e0b;
  --tv-accent-purple: #a855f7;
  --tv-plate-bg: #1e293b;
  --tv-plate-border: #475569;
  --tv-plate-text: #f1f5f9;
}

/* Ocultar scrollbars globales en modo TV */
body.tv-mode-active {
  overflow: hidden !important;
  background-color: #050810 !important;
}

body.tv-mode-active #app-navbar,
body.tv-mode-active #app-mode-tag,
body.tv-mode-active .position-fixed.bottom-0.end-0 {
  display: none !important;
}

body.tv-mode-active #app-wrapper {
  padding: 0 !important;
  margin: 0 !important;
  height: 100vh !important;
  max-height: 100vh !important;
}

body.tv-mode-active main {
  padding: 0 !important;
  margin: 0 !important;
  height: 100vh !important;
}

/* Contenedor principal de la vista */
#view-tv {
  transition: all 0.3s ease;
}

/* Barra de controles administrativos (Modo Vista Previa) */
.tv-admin-toolbar {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* Marco de Vista Previa 16:9 */
.tv-preview-wrapper {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  background-color: #050810;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Cuando se activa la TV en Pantalla Completa o Modo Standalone */
.tv-preview-wrapper.tv-standalone {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 99999 !important;
}

/* Lienzo de Televisión 16:9 */
.tv-screen-canvas {
  width: 100%;
  height: 100%;
  background: var(--tv-bg-gradient);
  color: var(--tv-text-main);
  display: flex;
  flex-direction: column;
  padding: clamp(14px, 1.8vw, 28px);
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  user-select: none;
  position: relative;
  overflow: hidden;
}

/* --- Encabezado de la Pantalla de TV --- */
.tv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: clamp(10px, 1.2vw, 18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: clamp(12px, 1.4vw, 20px);
  flex-shrink: 0;
}

.tv-brand-block {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.2vw, 20px);
}

.tv-brand-logo {
  height: clamp(32px, 3.2vw, 48px);
  filter: brightness(0) invert(1);
}

.tv-brand-titles h1 {
  font-size: clamp(18px, 1.8vw, 28px);
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0;
  line-height: 1.1;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tv-brand-titles p {
  font-size: clamp(12px, 1vw, 15px);
  font-weight: 500;
  color: var(--tv-text-muted);
  margin: 2px 0 0 0;
}

.tv-live-pill {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  font-size: clamp(10px, 0.75vw, 13px);
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.tv-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: tvPulse 1.8s infinite ease-in-out;
}

@keyframes tvPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Bloque central: Reloj Digital y Fecha */
.tv-clock-block {
  text-align: center;
}

.tv-clock-time {
  font-size: clamp(24px, 2.8vw, 44px);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.tv-clock-date {
  font-size: clamp(11px, 0.95vw, 15px);
  font-weight: 500;
  color: #cbd5e1;
  text-transform: capitalize;
  margin-top: 4px;
}

/* Bloque derecho: Métricas KPI del Día */
.tv-kpi-block {
  display: flex;
  align-items: center;
  gap: clamp(8px, 0.9vw, 14px);
}

.tv-kpi-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: clamp(6px, 0.7vw, 10px) clamp(10px, 1.1vw, 16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: clamp(60px, 5.5vw, 85px);
}

.tv-kpi-val {
  font-size: clamp(18px, 1.8vw, 28px);
  font-weight: 800;
  line-height: 1;
}

.tv-kpi-lbl {
  font-size: clamp(9px, 0.75vw, 11px);
  font-weight: 600;
  color: var(--tv-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.tv-kpi-total .tv-kpi-val { color: var(--tv-accent-cyan); }
.tv-kpi-recibidas .tv-kpi-val { color: var(--tv-accent-green); }
.tv-kpi-proceso .tv-kpi-val { color: var(--tv-accent-amber); }
.tv-kpi-pendientes .tv-kpi-val { color: var(--tv-accent-blue); }

/* --- Cuadrícula de Citas (8 Tarjetas por Vista 2x4) --- */
.tv-cards-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tv-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: clamp(10px, 1.2vw, 18px);
  width: 100%;
  height: 100%;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tv-cards-grid.tv-transitioning {
  opacity: 0;
  transform: translateY(12px) scale(0.99);
}

/* Tarjeta individual de Cita */
.tv-card {
  background: var(--tv-card-bg);
  border: 1px solid var(--tv-card-border);
  border-radius: clamp(12px, 1.2vw, 18px);
  padding: clamp(10px, 1.2vw, 18px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(16px);
  transition: border-color 0.25s ease, transform 0.2s ease;
}

/* Borde lateral de estatus */
.tv-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  border-radius: 4px 0 0 4px;
}

.tv-card.tv-status-recibida::before { background: var(--tv-accent-green); }
.tv-card.tv-status-recibida { border-color: rgba(16, 185, 129, 0.35); }

.tv-card.tv-status-en_proceso::before { background: var(--tv-accent-amber); }
.tv-card.tv-status-en_proceso { border-color: rgba(245, 158, 11, 0.35); }

.tv-card.tv-status-pendiente::before { background: var(--tv-accent-blue); }
.tv-card.tv-status-pendiente { border-color: rgba(56, 189, 248, 0.3); }

.tv-card.tv-status-terminado::before { background: var(--tv-accent-purple); }
.tv-card.tv-status-terminado { border-color: rgba(168, 85, 247, 0.35); }

.tv-card.tv-status-cancelada::before { background: #64748b; }
.tv-card.tv-status-cancelada { border-color: rgba(100, 116, 139, 0.3); opacity: 0.6; }

/* Fila Superior de la Tarjeta (Hora y Estatus) */
.tv-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: clamp(6px, 0.7vw, 10px);
}

.tv-badge-hora {
  background: #ffffff;
  color: #0f172a;
  font-weight: 900;
  font-size: clamp(14px, 1.4vw, 22px);
  padding: clamp(3px, 0.35vw, 6px) clamp(8px, 0.8vw, 14px);
  border-radius: 8px;
  letter-spacing: -0.3px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.tv-badge-status {
  font-size: clamp(10px, 0.8vw, 13px);
  font-weight: 700;
  padding: clamp(3px, 0.3vw, 5px) clamp(8px, 0.7vw, 12px);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tv-status-recibida .tv-badge-status {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #34d399;
}

.tv-status-en_proceso .tv-badge-status {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.tv-status-pendiente .tv-badge-status {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #7dd3fc;
}

.tv-status-terminado .tv-badge-status {
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.5);
  color: #c084fc;
}

.tv-status-cancelada .tv-badge-status {
  background: rgba(100, 116, 139, 0.2);
  border: 1px solid rgba(100, 116, 139, 0.4);
  color: #94a3b8;
}

/* Cuerpo de la Tarjeta */
.tv-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(4px, 0.45vw, 8px);
  margin: clamp(2px, 0.3vw, 6px) 0;
}

.tv-card-client {
  font-size: clamp(14px, 1.4vw, 22px);
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.3px;
  text-transform: capitalize;
}

.tv-card-vehicle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tv-card-vehicle {
  font-size: clamp(12px, 1.1vw, 17px);
  font-weight: 600;
  color: #e2e8f0;
  text-transform: capitalize;
}

.tv-card-plate {
  background: var(--tv-plate-bg);
  border: 1px solid var(--tv-plate-border);
  color: var(--tv-plate-text);
  font-family: 'Courier New', Courier, monospace;
  font-weight: 800;
  font-size: clamp(11px, 0.95vw, 15px);
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.tv-card-service {
  font-size: clamp(10px, 0.85vw, 13px);
  color: #94a3b8;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pie de la Tarjeta (Asesor y Detalles de Recepción/Orden) */
.tv-card-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: clamp(6px, 0.6vw, 10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: clamp(10px, 0.8vw, 13px);
  color: #cbd5e1;
}

.tv-card-advisor {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: #f1f5f9;
}

.tv-card-advisor i {
  color: var(--tv-accent-cyan);
}

.tv-card-extra-info {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tv-badge-rec-time {
  color: #34d399;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
}

/* --- Pie de la Pantalla / Barra de Paginación --- */
.tv-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: clamp(8px, 0.9vw, 14px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: clamp(8px, 0.9vw, 14px);
  flex-shrink: 0;
}

.tv-page-indicator {
  font-size: clamp(11px, 0.9vw, 14px);
  font-weight: 600;
  color: var(--tv-text-muted);
}

.tv-progress-container {
  flex: 1;
  max-width: clamp(200px, 25vw, 400px);
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  overflow: hidden;
  margin: 0 20px;
}

.tv-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--tv-accent-cyan), var(--tv-accent-green));
  width: 0%;
  border-radius: 9999px;
  transition: width 0.1s linear;
}

.tv-footer-agency {
  font-size: clamp(10px, 0.85vw, 13px);
  color: #64748b;
  font-weight: 500;
}

/* Estado sin citas */
.tv-empty-state {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--tv-text-muted);
  padding: 40px;
}

.tv-empty-icon {
  font-size: clamp(40px, 4.5vw, 70px);
  color: rgba(255, 255, 255, 0.2);
  margin-bottom: 15px;
}

.tv-empty-title {
  font-size: clamp(18px, 1.8vw, 28px);
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
}

.tv-empty-desc {
  font-size: clamp(12px, 1.1vw, 16px);
  max-width: 500px;
}

/* Botón flotante para salir de Pantalla Completa */
.tv-floating-exit-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease, background-color 0.2s ease;
  pointer-events: none;
}

.tv-preview-wrapper.tv-standalone:hover .tv-floating-exit-btn,
.tv-preview-wrapper.tv-standalone.mouse-active .tv-floating-exit-btn {
  opacity: 1;
  pointer-events: auto;
}

.tv-floating-exit-btn:hover {
  background: rgba(220, 38, 38, 0.85);
  border-color: rgba(220, 38, 38, 1);
}
