:root {
  --primary: #2563eb;
  --secondary: #64748b;
  --success: #22c55e;
  --bg: #f8fafc;
  --card: #ffffff;
  --danger: #ef4444;
  --orange: #f59e0b;
}

.container {
  max-width: 600px;
  margin: 0 auto;
}

h3 {
  color: var(--primary);
  margin: 0 0 10px 0;
  text-align: center;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.cronometro {
  font-size: 2.8rem;
  font-weight: bold;
  text-align: center;
  margin: 10px 0;
  font-family: monospace;
  color: var(--secondary);
}
#installBanner,
#iosInstallBanner {
  display: none;
  background: var(--primary);
  color: white;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 15px;
  text-align: center;
  align-items: center;
  justify-content: space-between;
}
#gridCal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  transition: opacity 0.4s;
  opacity: 0.3;
}
.day-name {
  text-align: center;
  font-size: 0.7rem;
  font-weight: bold;
  color: var(--secondary);
  padding-bottom: 5px;
}
.day {
  aspect-ratio: 1;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  background: white;
  position: relative;
}
.day.sat {
  background: #fff7ed;
  border-color: #fdba74;
}
.day.sun {
  background: #fef2f2;
  border-color: #fecaca;
}
.day.holiday {
  background: #fee2e2 !important;
  color: var(--danger);
  font-weight: bold;
  border-color: var(--danger);
}
.day.today {
  outline: 2px solid var(--primary);
  z-index: 1;
}
.day.work {
  border-left: 4px solid var(--success);
}
.day.ignored-extra::after {
  content: "🚫";
  position: absolute;
  top: 1px;
  right: 1px;
  font-size: 0.5rem;
}
button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.btn-main {
  background: var(--primary);
  color: white;
}
.btn-stop {
  background: var(--danger);
  color: white;
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.resumen-box {
  background: #eff6ff;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}
.resumen-flex {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-top: 4px;
  flex-wrap: wrap;
}
.resumen-flex b {
  color: var(--primary);
}
.rounded-info {
  color: var(--orange);
  font-size: 0.75rem;
  width: 100%;
  margin-top: 5px;
  border-top: 1px dashed #cbd5e1;
  padding-top: 5px;
  font-weight: bold;
}
label {
  display: block;
  font-size: 0.8rem;
  font-weight: bold;
  margin-bottom: 4px;
  color: var(--secondary);
}
.check-container {
  display: flex !important;
  flex-direction: row; /* Asegura que sea una fila */
  align-items: center; /* Centra verticalmente el cuadro con el texto */
  justify-content: flex-start; /* Los pega a la izquierda */
  gap: 12px; /* Espacio uniforme entre cuadro y texto */
  cursor: pointer;
  margin-bottom: 12px; /* Espacio entre un check y el siguiente */
  font-size: 0.9rem;
  color: var(--secondary);
  text-align: left; /* Fuerza el texto a la izquierda */
}

/* Opcional: para que el cuadrito sea un poco más grande y fácil de tocar en el Xiaomi */
.check-container input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0; /* Quita márgenes por defecto del navegador */
  cursor: pointer;
  accent-color: var(--primary); /* Le da tu color azul al marcarlo */
}
input,
select {
  width: 100%;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-sizing: border-box;
  margin-bottom: 10px;
}
.slider-container {
  margin: 15px 0;
}
.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
input[type="range"] {
  padding: 0;
  margin: 10px 0;
  cursor: pointer;
  height: 8px;
  background: #e2e8f0;
  border-radius: 5px;
  appearance: none;
  width: 100%;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
}
.def-hours-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}
.def-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f1f5f9;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
}
.def-row input {
  width: 50px;
  margin: 0;
  padding: 4px;
  text-align: center;
}
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px); /* Esto desenfoca el fondo y queda MUY pro */
  transition: all 0.3s ease;
}

.modal-content {
  background: white;
  padding: 15px;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}
.manual-section {
  background: #f8fafc;
  padding: 10px;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
  margin-top: 10px;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: #1e293b;
  padding: 0 !important;
  margin: 0 !important;

  /* IMPORTANTE: Espacio para que la barra no tape el contenido */
  padding-bottom: 80px;

  background: white !important;
}

/* --- INFRAESTRUCTURA DE SECCIONES --- */
.section {
  display: none; /* Ocultas por defecto */
  animation: fadeIn 0.3s ease; /* Un toque de fluidez */
}

.section.active {
  display: block; /* Solo la activa se muestra */
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- BARRA DE NAVEGACIÓN INFERIOR --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--card);
  display: flex;
  justify-content: space-around;
  padding: 10px 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  border-top: 1px solid #e2e8f0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--secondary);
  font-size: 0.7rem;
  font-weight: bold;
  cursor: pointer;
  flex: 1;
  transition: all 0.2s;
}

.nav-item.active {
  color: var(--primary);
}

/* Iconos temporales (Emoji) o FontAwesome */
.nav-icon {
  font-size: 1.3rem;
  margin-bottom: 2px;
}

/* --- OPTIMIZACIÓN DE CARDS --- */
.card {
  background: var(--card);
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  margin-bottom: 15px;
}

/* Efecto de presión al tocar (UX Mobile) */
button:active,
.day:active,
.nav-item:active {
  transform: scale(0.96);
}

/* --- BARRA SUPERIOR (TOP BAR) --- */
.top-bar {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--primary);
  color: white;
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  z-index: 1100;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.top-bar h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.top-bar .date-display {
  font-size: 0.75rem;
  opacity: 0.9;
  font-weight: 500;
}

/* Ajuste al container para que no se pegue a la barra */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding-top: 10px; /* Espacio extra debajo de la top bar */
}

/* Ocultar el informe en la pantalla normal */
.print-only {
  display: none !important;
}

/* REGLAS DE IMPRESIÓN */
@media print {
  /* Ocultar todo lo que NO es el informe */
  body * {
    visibility: hidden;
  }
  .print-only,
  .print-only * {
    visibility: visible;
  }
  .print-only {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }

  /* Forzar fondo blanco y quitar espacios de la PWA */

  /* Estilo de la tabla en el PDF */
  table {
    border: 1px solid #e2e8f0;
  }
  th,
  td {
    border-bottom: 1px solid #e2e8f0;
    font-size: 10pt;
  }

  /* Evitar que el navegador ponga headers/footers propios si es posible */
  @page {
    margin: 1cm;
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  .print-only,
  .print-only * {
    visibility: visible;
    display: block !important;
  }
  .print-only {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
}

/* Ajustes para los inputs de tiempo en configuración */
.def-row input[type="time"] {
  -webkit-appearance: none; /* Quita estilos raros en iOS */
  appearance: none;
  min-width: 90px; /* Asegura espacio para HH:MM */
  background: white;
  color: #1e293b;
}

/* Contenedor principal de los ajustes de horas */
.def-hours-grid {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.day.no-work {
  background-color: #e2e8f0; /* Un gris clarito */
  color: #94a3b8;
  text-decoration: line-through; /* Tacha el número para indicar que no se cuenta */
}

.help-icon {
  background: #f1f5f9;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: bold;
  color: var(--primary);
  margin-left: 8px;
  font-size: 0.75rem;
}

#ayudaContenido p {
  margin-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
}

#ayudaContenido ul {
  margin-left: 15px;
  margin-bottom: 15px;
}

#ayudaContenido li {
  margin-bottom: 8px;
  list-style-type: disc;
}

#ayudaContenido b {
  color: var(--primary);
  font-weight: 700;
}

.app-footer {
  text-align: center;
  padding: 30px 10px 110px; /* Padding extra abajo para que no lo tape la nav-bar */
  font-size: 0.7rem;
  color: #94a3b8; /* Un gris azulado suave */
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.8;
}

.app-footer b {
  color: var(--primary); /* Resalta tu marca con el color principal de la app */
  font-weight: 600;
}

/* Badge de compensación en el calendario */
.comp-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #dcfce7; /* Verde clarito */
  color: #166534; /* Verde oscuro */
  font-size: 0.5rem;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: bold;
  border: 1px solid #bbf7d0;
}

/* Opcional: una clase para el contenedor del día */
.day.comp {
  border-bottom: 3px solid #22c55e;
}

@media print {
  /* Forzamos el reset de estilos responsivos */
  #informePrint table,
  #informePrint thead,
  #informePrint tbody,
  #informePrint th,
  #informePrint td,
  #informePrint tr {
    display: table !important; /* Anula cualquier display: block o flex */
    width: auto !important;
  }

  #informePrint table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  /* Ocultamos las etiquetas de móvil que causan el ruido visual */
  #informePrint td:before {
    display: none !important;
    content: "" !important;
  }

  /* Ajustes de espaciado para que entre en 1 hoja */
  body {
    background: white !important;
    font-size: 10pt !important;
  }
  #informePrint {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  #reporteResumen {
    display: flex !important;
    justify-content: space-around !important;
  }

  .day-name,
  .nav-bar,
  .app-footer,
  button,
  .no-print {
    display: none !important;
  }

  th,
  td {
    padding: 6px !important;
    border: 1px solid #cbd5e1 !important;
    text-align: right !important;
  }
  th:first-child,
  td:first-child {
    text-align: left !important;
  }
}

@media print {
  /* Forzamos que la tabla sea horizontal como en Excel */
  #informePrint table {
    display: table !important;
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 10pt !important;
  }
  #informePrint thead {
    display: table-header-group !important;
  }
  #informePrint tbody {
    display: table-row-group !important;
  }
  #informePrint tr {
    display: table-row !important;
  }

  /* Quitamos el estilo de "etiquetas" que apila los datos verticalmente */
  #informePrint td,
  #informePrint th {
    display: table-cell !important;
    border: 1px solid #cbd5e1 !important;
    padding: 6px 8px !important;
    text-align: right !important;
  }

  /* La columna de fecha queda alineada a la izquierda */
  #informePrint td:first-child,
  #informePrint th:first-child {
    text-align: left !important;
  }

  /* Ocultamos cualquier etiqueta oculta de móvil (:before) */
  #informePrint td:before {
    display: none !important;
    content: "" !important;
  }

  /* Limpieza general de la hoja */
  .nav-bar,
  .app-footer,
  button,
  .no-print {
    display: none !important;
  }
  body {
    background: white !important;
    margin: 0 !important;
  }
  #informePrint {
    width: 100% !important;
    padding: 0 !important;
  }
  #reporteResumen {
    display: flex !important;
    justify-content: space-between !important;
    margin-bottom: 20px !important;
  }
}

@media print {
  #informePrint th,
  #informePrint td {
    padding: 4px 5px !important; /* Más apretado */
    font-size: 9pt !important; /* Bajamos un punto la fuente */
  }
}
