/**
 * styles.css
 * -----------------------------------------------------------------------------
 * Estilos de PicPicPic.
 *
 * Características:
 *  - 6 temas: claro, oscuro, automático, sepia, alto contraste, océano
 *  - Botones: verde para acciones positivas, rojo para negativas
 *  - Bloqueo de pull-to-refresh y swipes laterales (overflow locking)
 *  - Responsive: layout distinto para móvil / tablet / escritorio
 *  - Tamaño mínimo de fuente 16px en inputs (evita zoom en iOS)
 *  - PWA-friendly: safe-area-insets, fullscreen, etc.
 *  - Sin minificación, legible y comentado en español.
 * -----------------------------------------------------------------------------
 */

/* ===========================================================================
   VARIABLES POR TEMA
   =========================================================================== */

:root {
  /* Tema claro (por defecto) */
  --pp-bg: #f5f5f7;
  --pp-fg: #1d1d1f;
  --pp-fg-suave: #6e6e73;
  --pp-surface: #ffffff;
  --pp-surface-2: #f0f0f3;
  --pp-border: #d2d2d7;
  --pp-accent: #0071e3;
  --pp-accent-fg: #ffffff;
  --pp-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --pp-shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.16);
  --pp-radio: 14px;
  --pp-transicion: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tema oscuro */
[data-tema="oscuro"] {
  --pp-bg: #0a0a0c;
  --pp-fg: #f5f5f7;
  --pp-fg-suave: #98989d;
  --pp-surface: #1c1c1e;
  --pp-surface-2: #2c2c2e;
  --pp-border: #38383a;
  --pp-accent: #0a84ff;
  --pp-accent-fg: #ffffff;
  --pp-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --pp-shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* Tema automático: respeta prefers-color-scheme cuando no hay data-tema */
@media (prefers-color-scheme: dark) {
  [data-tema="auto"] {
    --pp-bg: #0a0a0c;
    --pp-fg: #f5f5f7;
    --pp-fg-suave: #98989d;
    --pp-surface: #1c1c1e;
    --pp-surface-2: #2c2c2e;
    --pp-border: #38383a;
    --pp-accent: #0a84ff;
    --pp-accent-fg: #ffffff;
    --pp-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --pp-shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.6);
  }
}
@media (prefers-color-scheme: light) {
  [data-tema="auto"] {
    /* Hereda del :root */
  }
}

/* Tema sepia */
[data-tema="sepia"] {
  --pp-bg: #f4ecd8;
  --pp-fg: #5b4636;
  --pp-fg-suave: #8a7a66;
  --pp-surface: #faf3e0;
  --pp-surface-2: #ede0c8;
  --pp-border: #d4c4a8;
  --pp-accent: #a0522d;
  --pp-accent-fg: #ffffff;
  --pp-shadow: 0 4px 24px rgba(91, 70, 54, 0.12);
  --pp-shadow-strong: 0 8px 32px rgba(91, 70, 54, 0.2);
}

/* Tema alto contraste */
[data-tema="alto-contraste"] {
  --pp-bg: #000000;
  --pp-fg: #ffffff;
  --pp-fg-suave: #f0f0f0;
  --pp-surface: #000000;
  --pp-surface-2: #1a1a1a;
  --pp-border: #ffffff;
  --pp-accent: #ffff00;
  --pp-accent-fg: #000000;
  --pp-shadow: none;
  --pp-shadow-strong: 0 0 0 2px #ffffff;
  --pp-radio: 4px;
}

/* Tema océano */
[data-tema="oceano"] {
  --pp-bg: #001f3f;
  --pp-fg: #e0f7fa;
  --pp-fg-suave: #80deea;
  --pp-surface: #003366;
  --pp-surface-2: #004080;
  --pp-border: #0066cc;
  --pp-accent: #00bcd4;
  --pp-accent-fg: #001f3f;
  --pp-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --pp-shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* ===========================================================================
   RESET BÁSICO
   =========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--pp-bg);
  color: var(--pp-fg);
  font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
}

/* Evitar zoom en inputs iOS (mínimo 16px) */
input, textarea, select {
  font-size: 16px;
}

/* Inputs de hora: asegurar 16px mínimo */
input[type="time"], input[type="date"] {
  font-size: 16px;
  padding: 0.5rem 0.6rem;
}

/* Botones no seleccionables */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ===========================================================================
   LAYOUT PRINCIPAL
   =========================================================================== */

#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.pantalla {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.pantalla.activa {
  display: flex;
}

/* ===========================================================================
   PANTALLA PRINCIPAL: imagen a pantalla completa
   =========================================================================== */

#pantalla-principal {
  background: #000;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#imagen-principal {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Mensaje cuando no hay carpeta configurada */
.mensaje-sin-carpeta {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  z-index: 1;
}

.mensaje-sin-carpeta svg {
  width: 96px;
  height: 96px;
  margin-bottom: 1.5rem;
  opacity: 0.6;
}

.mensaje-sin-carpeta h2 {
  font-size: 1.5rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.mensaje-sin-carpeta p {
  font-size: 1rem;
  opacity: 0.7;
  max-width: 28rem;
}

/* Indicador de vigilancia activa (sutil, esquina superior izquierda) */
.indicador-vigilancia {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  left: max(1rem, env(safe-area-inset-left));
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: rgba(0, 0, 0, 0.55);
  color: #4ade80;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
  pointer-events: none;
}

.indicador-vigilancia.visible {
  display: flex;
}

.indicador-vigilancia .punto {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulso 2s ease-in-out infinite;
}

@keyframes pulso {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ===========================================================================
   FABs (Floating Action Buttons)
   =========================================================================== */

.fab-container {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 10;
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  transition: opacity var(--pp-transicion), transform var(--pp-transicion);
}

.fab-container.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--pp-surface);
  color: var(--pp-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--pp-shadow-strong);
  transition: transform var(--pp-transicion), background var(--pp-transicion);
}

.fab:hover, .fab:active {
  transform: scale(1.08);
}

.fab svg {
  width: 24px;
  height: 24px;
}

.fab-bateria {
  background: #2c2c2e;
  color: #ffffff;
}

/* ===========================================================================
   PANTALLA NEGRA (modo batería)
   =========================================================================== */

#pantalla-negra {
  background: #000;
  cursor: pointer;
  z-index: 100;
}

#pantalla-negra .hint {
  position: absolute;
  bottom: max(2rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.15);
  font-size: 0.8rem;
  pointer-events: none;
}

/* ===========================================================================
   PANELES (popups) — Overlay self-contained con scroll propio
   TODO el panel tiene fondo sólido continuo, sin huecos transparentes.
   =========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  z-index: 200;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.overlay.visible {
  display: block;
}

/* El panel es un contenedor con fondo sólido continuo.
   NO usar overflow:hidden porque impide el scroll del overlay.
   El fondo sólido de cada sección (cabecera, cuerpo, pie, pie-version)
   cubre todo sin huecos. */
.panel {
  background: var(--pp-surface);
  color: var(--pp-fg);
  border-radius: var(--pp-radio);
  box-shadow: var(--pp-shadow-strong);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .panel {
    max-width: 640px;
  }
}

/* Cabecera: fondo sólido */
.panel-cabecera {
  background: var(--pp-surface);
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--pp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--pp-radio) var(--pp-radio) 0 0;
}

.panel-cabecera h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Cuerpo: fondo sólido, sin margen inferior que crearía hueco */
.panel-cuerpo {
  background: var(--pp-surface);
  padding: 1.5rem 1.5rem 0.75rem;
}

/* Pie: fondo sólido, sin margen superior que crearía hueco */
.panel-pie {
  background: var(--pp-surface);
  padding: 0.25rem 1.5rem 1rem;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  border-radius: 0 0 var(--pp-radio) var(--pp-radio);
}

/* Pie del secreto: botones lado a lado, centrados */
.panel-pie-secreto {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  padding-top: 0.75rem;
}

.panel-pie-secreto .btn {
  flex: 0 1 30%;
  min-width: 140px;
  text-align: center;
}

/* Pie de versión: fondo sólido, dentro del panel */
.pie-version {
  background: var(--pp-surface);
  text-align: center;
  padding: 0.25rem 1rem 0.75rem;
  margin-top: 0;
  color: var(--pp-fg-suave);
  font-size: 0.7rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.pie-version a {
  color: var(--pp-fg-suave);
  text-decoration: underline;
}

.pie-version a:hover {
  opacity: 0.8;
}

/* Aviso legal y recomendaciones: fondo sólido heredado del panel */
.aviso-legal,
.recomendaciones-nav {
  background: var(--pp-surface-2);
}

/* En móvil: panel a pantalla completa */
@media (max-width: 480px) {
  .panel-pie-secreto {
    flex-direction: column;
    gap: 0.5rem;
  }
  .panel-pie-secreto .btn {
    width: 80%;
    font-size: 0.85rem;
  }
  .panel {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
  }
  .overlay {
    padding: 0;
  }
  .panel-cabecera {
    border-radius: 0;
  }
  .panel-pie {
    border-radius: 0;
  }
}

/* ===========================================================================
   FORMULARIOS
   =========================================================================== */

.campo {
  margin-bottom: 1.5rem;
}

/* Labels de campos: tamaño uniforme y en negrita */
.campo > label {
  display: block;
  font-weight: 700;                    /* Negrita para rótulos */
  margin-bottom: 0.5rem;
  font-size: 1rem;                      /* Tamaño uniforme para todos */
  line-height: 1.4;
  color: var(--pp-fg);
}

.campo > label .icono-label {
  display: inline-flex;
  vertical-align: middle;
  margin-right: 0.4rem;
}

.campo > label .icono-label svg {
  width: 18px;
  height: 18px;
}

/* Ajustes específicos de tamaño de iconos */
/* Icono de "Tema" y "Carpeta de imágenes" en .campo: 5% más grande = 18.9px */
#ic-tema svg, #ic-carpeta-config svg {
  width: 19px;
  height: 19px;
}

/* Icono de "Pantalla siempre activa" en .fila-switch: 10% más pequeño que el resto */
.fila-switch .icono-label svg {
  width: 16px;                        /* 18px - 10% ≈ 16px */
  height: 16px;
}

/* Comentarios de ayuda: gris y tamaño pequeño (sin negrita) */
.campo-ayuda {
  font-size: 0.85rem;
  font-weight: 400;                     /* Sin negrita */
  color: var(--pp-fg-suave);
  margin-top: 0.4rem;
  line-height: 1.4;
}

select, input[type="text"], input[type="number"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--pp-border);
  border-radius: 8px;
  background: var(--pp-surface-2);
  color: var(--pp-fg);
  font-size: 16px;                  /* 16px mínimo para evitar zoom iOS */
  font-family: inherit;
  transition: border var(--pp-transicion);
}

select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--pp-accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
}

/* Slider de tamaño de fuente */
input[type="range"] {
  width: 100%;
  height: 32px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--pp-border);
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--pp-accent);
  margin-top: -10px;
  border: none;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--pp-border);
  border-radius: 2px;
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--pp-accent);
  border: none;
}

.valor-slider {
  display: inline-block;
  margin-left: 0.75rem;
  font-weight: 500;
  color: var(--pp-accent);
}

/* Icono de información (tooltip) */
.icono-info {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.4rem;
  color: var(--pp-fg-suave);
  cursor: help;
}

.icono-info svg {
  width: 16px;
  height: 16px;
}

/* Switch personalizado */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider-bg {
  position: absolute;
  inset: 0;
  background: var(--pp-border);
  border-radius: 999px;
  transition: background var(--pp-transicion);
}

.switch .slider-bg::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  transition: transform var(--pp-transicion);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.switch input:checked + .slider-bg {
  background: #34c759;              /* Verde cuando activado */
}

.switch input:checked + .slider-bg::before {
  transform: translateX(22px);
}

.fila-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  margin-bottom: 2rem;                 /* Más espacio antes del selector de carpeta */
}

.fila-switch .texto {
  flex: 1;
}

.fila-switch .texto strong {
  display: block;
  font-weight: 700;                    /* Negrita para el rótulo del switch */
  font-size: 1rem;                     /* Tamaño uniforme con el resto de labels */
  line-height: 1.4;
  color: var(--pp-fg);
}

.fila-switch .texto small {
  display: block;
  color: var(--pp-fg-suave);
  font-size: 0.85rem;
  font-weight: 400;                    /* Sin negrita */
  margin-top: 0.25rem;
  line-height: 1.4;
}

/* ===========================================================================
   BOTONES
   =========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: transform var(--pp-transicion), opacity var(--pp-transicion), background var(--pp-transicion);
  white-space: nowrap;
  min-height: 44px;                /* Mínimo recomendado para táctil */
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn svg {
  width: 18px;
  height: 18px;
}

/* Botón primario (positivo: guardar, aceptar) - VERDE con texto blanco */
.btn-positivo {
  background: #34c759;
  color: #ffffff;
}

.btn-positivo:hover {
  background: #2db84e;
}

/* Botón negativo (cancelar, borrar) - ROJO con texto blanco */
.btn-negativo {
  background: #ff3b30;
  color: #ffffff;
}

.btn-negativo:hover {
  background: #e02e25;
}

/* Botón secundario (neutral) */
.btn-secundario {
  background: var(--pp-surface-2);
  color: var(--pp-fg);
  border: 1px solid var(--pp-border);
}

.btn-secundario:hover {
  background: var(--pp-border);
}

/* Botón icono circular (para cerrar paneles) */
.btn-icono {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pp-surface-2);
  color: var(--pp-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icono:hover {
  background: var(--pp-border);
}

.btn-icono svg {
  width: 20px;
  height: 20px;
}

/* Botón cerrar 15% más grande */
.btn-cerrar-grande {
  width: 46px;
  height: 46px;
}

.btn-cerrar-grande svg {
  width: 23px;
  height: 23px;
}

/* Botón expandir a ancho completo */
.btn-bloque {
  width: 100%;
}

/* Botón grande para acciones principales del panel secreto */
.btn-grande {
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
}


/* ===========================================================================
   svgOjo INLINE (discreto, en el pie junto al título/versión)
   - Tamaño muy pequeño: alto de una letra P mayúscula (~12px)
   - Sin tooltip, sin hover, sin focus visible
   - tabindex="-1" para saltarlo al tabular
   =========================================================================== */

.ojo-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--pp-fg-suave);
  cursor: default;
  vertical-align: middle;
  /* Sin transiciones ni efectos */
  outline: none !important;
  -webkit-tap-highlight-color: transparent;
}

.ojo-inline svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.5;             /* Más grueso para que sea visible a tamaño pequeño */
}

/* Sin hover: no cambia de color */
.ojo-inline:hover {
  color: var(--pp-fg-suave);
  transform: none;
}

/* Sin focus visible: el foco no se detiene aquí */
.ojo-inline:focus,
.ojo-inline:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* ===========================================================================
   PANEL SECRETO: estado de vigilancia
   =========================================================================== */

.estado-vigilancia {
  background: var(--pp-surface-2);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.estado-vigilancia .punto-estado {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--pp-fg-suave);
  flex-shrink: 0;
}

.estado-vigilancia.activa .punto-estado {
  background: #34c759;
  animation: pulso 2s ease-in-out infinite;
}

.estado-vigilancia .info {
  flex: 1;
}

.estado-vigilancia .info strong {
  display: block;
  font-weight: 500;
}

.estado-vigilancia .info small {
  display: block;
  color: var(--pp-fg-suave);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

/* ===========================================================================
   CALCULADORA DE ESPACIO
   =========================================================================== */

.calculo-espacio {
  background: var(--pp-surface-2);
  border-radius: 10px;
  padding: 1rem;
  margin-top: 0.5rem;
}

.calculo-espacio .fila {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}

.calculo-espacio .fila.total {
  border-top: 1px solid var(--pp-border);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  font-weight: 600;
  font-size: 1rem;
}

.calculo-espacio .fila .valor {
  font-weight: 500;
}

.calculo-espacio.suficiente .valor-grande {
  color: #34c759;
}

.calculo-espacio.insuficiente .valor-grande {
  color: #ff3b30;
}

.formula-info {
  font-size: 0.8rem;
  color: var(--pp-fg-suave);
  margin-top: 0.5rem;
  font-style: italic;
}

/* ===========================================================================
   AVISO LEGAL (panel secreto)
   =========================================================================== */

.aviso-legal {
  background: rgba(255, 59, 48, 0.08);
  border-left: 3px solid #ff3b30;
  border-radius: 6px;
  padding: 1rem 1rem 1rem 1.25rem;
  margin: 1rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--pp-fg);
}

.aviso-legal strong {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #ff3b30;
}

/* Recomendaciones de navegadores */
.recomendaciones-nav {
  background: var(--pp-surface-2);
  border-radius: 6px;
  padding: 1rem;
  margin: 1rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

.recomendaciones-nav strong {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.recomendaciones-nav ul {
  list-style: none;
  padding: 0;
}

.recomendaciones-nav li {
  padding: 0.3rem 0;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.recomendaciones-nav li svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--pp-accent);
}

.recomendaciones-nav li.ios {
  color: #ff9500;
}

.recomendaciones-nav li.ios svg {
  color: #ff9500;
}

/* ===========================================================================
   REVISIÓN DE IMÁGENES — Reproductor tipo vídeo
   =========================================================================== */

.revision-player-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Área de imagen con timestamp superpuesto */
.revision-player-area {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.revision-player-area img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Timestamp superpuesto en esquina superior derecha */
.revision-timestamp {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 2;
}

/* Barra temporal */
.revision-timeline input[type="range"] {
  width: 100%;
  height: 28px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.revision-timeline input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--pp-border);
  border-radius: 3px;
}

.revision-timeline input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--pp-accent);
  margin-top: -6px;
  border: 2px solid #fff;
}

.revision-timeline input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--pp-border);
  border-radius: 3px;
}

.revision-timeline input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--pp-accent);
  border: 2px solid #fff;
}

/* Controles de reproducción */
.revision-controles {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rev-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pp-surface-2);
  color: var(--pp-fg);
  border: 1px solid var(--pp-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--pp-transicion);
  flex-shrink: 0;
}

.rev-btn:hover {
  background: var(--pp-border);
}

.rev-btn:active {
  transform: scale(0.95);
}

.rev-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;                /* Asegurar fill en móvil */
  stroke: currentColor;
}

.rev-btn-grande {
  width: 52px;
  height: 52px;
  background: var(--pp-accent);
  color: var(--pp-accent-fg);
  border: none;
}

.rev-btn-grande:hover {
  opacity: 0.9;
  background: var(--pp-accent);
}

.rev-btn-grande svg {
  width: 22px;
  height: 22px;
}

.rev-btn.activo {
  background: var(--pp-accent);
  color: var(--pp-accent-fg);
  border-color: var(--pp-accent);
}

.rev-separador {
  width: 1px;
  height: 28px;
  background: var(--pp-border);
  margin: 0 0.3rem;
}

.rev-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--pp-border);
  border-radius: 6px;
  background: var(--pp-surface-2);
  color: var(--pp-fg);
  font-size: 0.85rem;
  font-family: inherit;
}

.rev-toggle {
  width: auto;
  border-radius: 20px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Selector de fecha/hora */
.revision-selector-tiempo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
}

.revision-selector-tiempo label {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.revision-selector-tiempo input[type="date"],
.revision-selector-tiempo input[type="time"] {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--pp-border);
  border-radius: 6px;
  background: var(--pp-surface-2);
  color: var(--pp-fg);
  font-size: 0.9rem;
  font-family: inherit;
}

/* Botones de exportar */
.revision-exportar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
}

.revision-info-line {
  font-size: 0.85rem;
  color: var(--pp-fg-suave);
  text-align: center;
  padding: 0.3rem 0;
}

/* Responsive: controles más compactos en móvil */
@media (max-width: 480px) {
  .rev-btn {
    width: 36px;
    height: 36px;
  }
  .rev-btn-grande {
    width: 46px;
    height: 46px;
  }
  .rev-btn svg {
    width: 16px;
    height: 16px;
  }
  .rev-btn-grande svg {
    width: 20px;
    height: 20px;
  }
  .revision-exportar .btn {
    flex: 1;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }
}

/* ===========================================================================
   INDICADOR DE VIGILANCIA (2 píxeles azules, esquina inferior izquierda)
   Solo visible si el toggle de configuración está activado.
   =========================================================================== */

/* Indicador de vigilancia: 4 píxeles morados en cuadrado 2×2 (esquina inf. izq.) */
.indicador-vigilancia-pixels {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 4px;
  height: 4px;
  z-index: 50;
  display: none;
  pointer-events: none;
  /* Cuadrado 2×2 usando box-shadow: pixel(0,0) + pixel(2,0) + pixel(0,2) + pixel(2,2) */
  background: #8a2be2;              /* Morado (BlueViolet) */
  box-shadow:
    2px 0 0 #8a2be2,                /* pixel derecho superior */
    0 2px 0 #8a2be2,                /* pixel izquierdo inferior */
    2px 2px 0 #8a2be2;              /* pixel derecho inferior */
}

.indicador-vigilancia-pixels.visible {
  display: block;
}

/* ===========================================================================
   SECCIONES DE MODO (panel avanzado)
   =========================================================================== */

.seccion-modo {
  /* Sin estilos especiales, solo contenedor */
}

.dias-semana {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.dia-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.6rem;
  background: var(--pp-surface-2);
  border: 1px solid var(--pp-border);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.dia-toggle input {
  margin: 0;
}

.dia-toggle input:checked + span {
  font-weight: 700;
  color: var(--pp-accent);
}

/* ===========================================================================
   CANVAS DE SELECCIÓN DE ZONA (overlay temporal)
   =========================================================================== */

.overlay-zona {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 300;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.overlay-zona.visible {
  display: flex;
}

.overlay-zona canvas {
  max-width: 95vw;
  max-height: 80vh;
  border: 2px solid var(--pp-accent);
  cursor: crosshair;
}

.overlay-zona .instrucciones {
  color: white;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  text-align: center;
}

.overlay-zona .botones {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

/* ===========================================================================
   BOTÓN INSTALAR PWA
   =========================================================================== */

#btn-instalar {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--pp-accent);
  color: var(--pp-accent-fg);
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-weight: 500;
  box-shadow: var(--pp-shadow-strong);
  z-index: 50;
  display: none;
  align-items: center;
  gap: 0.5rem;
  transition: transform var(--pp-transicion);
}

#btn-instalar.visible {
  display: flex;
}

#btn-instalar:hover {
  transform: translateX(-50%) translateY(-2px);
}

#btn-instalar svg {
  width: 18px;
  height: 18px;
}

/* ===========================================================================
   MODAL DE SALIDA
   =========================================================================== */

.modal-salir {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 1rem;
}

.modal-salir.visible {
  display: flex;
}

.modal-salir .contenido {
  background: var(--pp-surface);
  border-radius: var(--pp-radio);
  padding: 1.5rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.modal-salir h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.modal-salir p {
  color: var(--pp-fg-suave);
  margin-bottom: 1.25rem;
}

.modal-salir .acciones {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* ===========================================================================
   NOTIFICACIONES TOAST
   =========================================================================== */

.toast-container {
  position: fixed;
  bottom: max(5rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 500;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast {
  background: var(--pp-surface);
  color: var(--pp-fg);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: var(--pp-shadow-strong);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toast-in 0.3s ease;
  border-left: 3px solid var(--pp-accent);
}

.toast.error {
  border-left-color: #ff3b30;
}

.toast.exito {
  border-left-color: #34c759;
}

.toast.advertencia {
  border-left-color: #ff9500;
}

.toast svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===========================================================================
   SPINNER
   =========================================================================== */

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--pp-border);
  border-top-color: var(--pp-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.cargando-centro {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20;
}

/* ===========================================================================
   RESPONSIVE: ajustes específicos por tamaño de pantalla
   =========================================================================== */

/* Móvil pequeño: paneles ocupan toda la pantalla */
@media (max-width: 480px) {
  .panel {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .overlay {
    padding: 0;
    /* En móvil el overlay permite scroll completo */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .panel-cuerpo {
    padding: 1rem;
  }

  .fab {
    width: 48px;
    height: 48px;
  }

  .fab svg {
    width: 22px;
    height: 22px;
  }
}

/* Tablet: layout intermedio */
@media (min-width: 481px) and (max-width: 1024px) {
  .panel {
    max-width: 540px;
  }
}

/* Escritorio: paneles más amplios, FABs más pequeños */
@media (min-width: 1025px) {
  .fab {
    width: 52px;
    height: 52px;
  }

  .panel {
    max-width: 680px;
  }
}

/* ===========================================================================
   ACCESIBILIDAD: focus visible para teclado
   =========================================================================== */

*:focus-visible {
  outline: 2px solid var(--pp-accent);
  outline-offset: 2px;
}

/* Modo alto contraste: outline más visible */
[data-tema="alto-contraste"] *:focus-visible {
  outline: 3px solid #ffff00;
  outline-offset: 3px;
}

/* Respetar prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================================================================
   OCULTAR ELEMENTOS
   =========================================================================== */

.oculto {
  display: none !important;
}

/* Texto solo para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
