/* ==========================================================================
   Estilos Optimizados para Digital Signage en Smart TV (VIDAA OS)
   ========================================================================== */

/* Variables de tema — sobreescritas dinámicamente por JS */
:root {
  --banner-bg: rgba(14, 18, 28, 0.92);
  --accent-color: #00d2ff;
  --text-color: #ffffff;
  --ticker-text-color: #e2e8f0;
  --clock-color: #00d2ff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #000000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #ffffff;
}

/* Contenedor en pantalla completa */
.signage-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #000000;
}

/* ==========================================================================
   Elementos de Video (Double Buffering)
   ========================================================================== */
.video-element {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #000000;
  transition: opacity 0.25s ease-in-out;
  will-change: opacity, transform;
  transform: translateZ(0); /* Aceleración por hardware GPU */
  image-rendering: -webkit-optimize-contrast;
}

/* Modos de escala configurables */
.video-element.fit-fill { object-fit: fill; }
.video-element.fit-cover { object-fit: cover; }
.video-element.fit-contain { object-fit: contain; }

.video-element.active {
  opacity: 1;
  z-index: 2;
  pointer-events: auto;
}

.video-element.standby {
  opacity: 0;
  z-index: 1;
  pointer-events: none;
}

/* ==========================================================================
   Capa de Transición Suave y Congelado de Fotograma (Seamless Crossfade)
   Oculta completamente pantallas negras y ruedas de carga del televisor
   ========================================================================== */
.transition-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease-out, visibility 0.45s;
  will-change: opacity;
  transform: translateZ(0);
  image-rendering: -webkit-optimize-contrast;
}

.transition-canvas.active {
  opacity: 1;
  visibility: visible;
  transition: none !important; /* Congelado instantáneo del último fotograma */
}

/* ==========================================================================
   BANNER CORPORATIVO (LOGO + CINTILLO / TICKER + RELOJ EN VIVO)
   ========================================================================== */
.signage-banner {
  position: absolute;
  left: 0;
  width: 100vw;
  height: 64px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--banner-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.signage-banner.position-bottom {
  bottom: 0;
  top: auto;
  border-top: 2px solid var(--accent-color);
}

.signage-banner.position-top {
  top: 0;
  bottom: auto;
  border-bottom: 2px solid var(--accent-color);
}

.signage-banner.hidden {
  display: none !important;
}

/* 1. Sección de Marca / Logotipo */
.banner-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  max-width: 450px;
  padding-right: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.banner-logo {
  height: 48px;
  max-width: 180px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.banner-company-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #ffffff;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 2. Marquesina / Ticker de Noticias Deslizante */
.banner-ticker-container {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
  margin: 0 20px;
  position: relative;
}

.ticker-badge {
  background: var(--accent-color);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 4px;
  margin-right: 14px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.ticker-track {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}

.ticker-content {
  display: inline-block;
  padding-left: 100%;
  animation: marquee-scroll 28s linear infinite;
  font-size: 15px;
  font-weight: 500;
  color: var(--ticker-text-color);
  letter-spacing: 0.5px;
}

@keyframes marquee-scroll {
  0%   { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-100%, 0, 0); }
}

/* 3. Reloj Digital y Fecha */
.banner-clock-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
  padding-left: 18px;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  min-width: 140px;
}

.banner-clock-box.hidden {
  display: none !important;
}

.clock-time {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--clock-color);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.clock-date {
  font-size: 11px;
  color: #a0aec0;
  font-weight: 500;
  margin-top: 2px;
  text-transform: capitalize;
}

/* ==========================================================================
   Overlay de Estado y Carga Inicial
   ========================================================================== */
.status-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1a1a2e 0%, #0a0a10 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

.status-overlay.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  display: none !important;
  visibility: hidden !important;
}

.loader-content {
  text-align: center;
  max-width: 600px;
  padding: 40px;
}

.spinner {
  width: 64px;
  height: 64px;
  margin: 0 auto 24px auto;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top: 5px solid #00d2ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#status-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

#status-description {
  font-size: 16px;
  color: #a0aec0;
  margin-bottom: 24px;
  line-height: 1.5;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #00d2ff 0%, #3a7bd5 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 14px;
  font-weight: 500;
  color: #718096;
}

/* ==========================================================================
   Badge de Diagnóstico y Botón de Ajustes (Esquina Superior Derecha)
   ========================================================================== */
.diagnostics-badge {
  position: absolute;
  top: 18px;
  right: 24px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.3s ease, transform 0.2s ease;
}

.diagnostics-badge:hover,
.diagnostics-badge:focus {
  opacity: 1;
  transform: scale(1.04);
  border-color: #00d2ff;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #e53e3e;
}

.status-dot.online {
  background-color: #38a169;
  box-shadow: 0 0 8px rgba(56, 161, 105, 0.8);
}

.status-dot.offline {
  background-color: #dd6b20;
  box-shadow: 0 0 8px rgba(221, 107, 32, 0.8);
}

.settings-hint {
  font-size: 11px;
  color: #00d2ff;
  font-weight: 600;
  margin-left: 4px;
  background: rgba(0, 210, 255, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ==========================================================================
   MODAL DE CONFIGURACIÓN (Smart TV UI / D-Pad Navigable)
   ========================================================================== */
.settings-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.settings-modal.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.settings-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.settings-container {
  position: relative;
  z-index: 10;
  width: 90%;
  max-width: 820px;
  max-height: 90vh;
  background: #161822;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  background: #1e2230;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-header h2 {
  font-size: 22px;
  font-weight: 600;
  color: #ffffff;
}

.settings-subtitle {
  font-size: 13px;
  color: #8c9ba5;
  margin-top: 3px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: #a0aec0;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.btn-icon:hover, .btn-icon:focus {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.settings-body {
  padding: 24px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-card {
  background: #1c202e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 18px 20px;
}

.settings-card.highlight-card {
  border-color: rgba(0, 210, 255, 0.3);
  background: #1a2336;
}

.settings-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: #00d2ff;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Formularios */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group.half {
  flex: 1;
  margin-bottom: 0;
}

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.form-row:last-child {
  margin-bottom: 0;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e0;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: #0f111a;
  border: 1px solid #2d3748;
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.4;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #00d2ff;
  box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.25);
  background: #141724;
}

.form-help {
  font-size: 11px;
  color: #718096;
}

/* Sección de Caché */
.cache-info-box {
  display: flex;
  justify-content: space-between;
  background: #0f111a;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.cache-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cache-label {
  font-size: 12px;
  color: #a0aec0;
}

.cache-value {
  font-size: 14px;
  font-weight: 600;
  color: #48bb78;
}

/* Sistema / Diagnóstico */
.system-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  font-size: 12px;
  background: #0f111a;
  padding: 12px 16px;
  border-radius: 8px;
}

.sys-item {
  color: #cbd5e0;
}

.sys-label {
  color: #718096;
  font-weight: 500;
}

.sys-ua {
  word-break: break-all;
  font-size: 11px;
  color: #a0aec0;
}

/* Botones */
.button-group {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:focus {
  transform: scale(1.03);
  box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.4);
}

.btn-primary {
  background: linear-gradient(135deg, #00d2ff 0%, #0072ff 100%);
  color: #ffffff;
}

.btn-secondary {
  background: #2d3748;
  color: #e2e8f0;
}

.btn-secondary:hover, .btn-secondary:focus {
  background: #4a5568;
}

.btn-danger {
  background: #9b2c2c;
  color: #ffffff;
}

.btn-danger:hover, .btn-danger:focus {
  background: #c53030;
}

.btn-outline {
  background: transparent;
  border: 1px solid #4a5568;
  color: #a0aec0;
}

.btn-outline:hover, .btn-outline:focus {
  border-color: #cbd5e0;
  color: #ffffff;
}

.settings-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: #1e2230;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-actions {
  display: flex;
  gap: 12px;
}

/* ==========================================================================
   PANTALLA DE REPOSO / APAGADO (Ahorro de energía en Smart TV)
   ========================================================================== */
.standby-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #000000;
  z-index: 999999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease;
  pointer-events: auto;
  user-select: none;
}

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

.standby-screen.mode-black .standby-ambient-box {
  display: none !important;
}

.standby-ambient-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  transition: opacity 0.3s ease;
  text-align: center;
  animation: standbyFloat 12s ease-in-out infinite alternate;
}

@keyframes standbyFloat {
  0% { transform: translate(-10px, -10px); }
  50% { transform: translate(10px, 5px); }
  100% { transform: translate(-5px, 10px); }
}

.standby-logo {
  max-width: 140px;
  max-height: 70px;
  object-fit: contain;
  margin-bottom: 20px;
  filter: grayscale(80%) brightness(0.6);
}

.standby-clock-time {
  font-size: 5rem;
  font-weight: 200;
  font-family: monospace, sans-serif;
  color: #e2e8f0;
  letter-spacing: 2px;
  line-height: 1;
}

.standby-clock-date {
  font-size: 1.25rem;
  font-weight: 400;
  color: #718096;
  margin-top: 10px;
  text-transform: capitalize;
}

.standby-badge {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: #4a5568;
  margin-top: 25px;
  border: 1px solid #2d3748;
  padding: 4px 14px;
  border-radius: 20px;
  text-transform: uppercase;
}

/* ==========================================================================
   MÚLTIPLES LOGOS EN EL BANNER (hasta 3 logos GIF/PNG/SVG)
   ========================================================================== */
.banner-logos-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner-logo-item {
  height: 48px;
  max-width: 140px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  flex-shrink: 0;
}

.banner-logo-separator {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

