/*
  ==========================================================
  HOJA DE ESTILOS PRINCIPAL
  Define la apariencia general de la aplicación:
  - Tipografía y colores base
  - Diseño de cabecera
  - Diseño de formulario y botones
  - Tabla de resultados
  ==========================================================
*/

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 20px;
  background-color: #fff;
  color: #333;
}

/* ===========================
   CABECERA (LOGO + TÍTULO)
   =========================== */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.header img {
  height: 90px;
  object-fit: contain;
}

.header h1 {
  font-size: 2em;
  margin: 0;
  text-align: center;
  font-weight: bold;
}

/* ===========================
   SECCIÓN DEL FORMULARIO
   =========================== */
.form-section {
  background-color: #f4f4f4;
  padding: 30px;
  border-radius: 8px;
  margin-bottom: 20px;
  text-align: center;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 30px;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.form-grid label {
  text-align: right;
  font-weight: 500;
  font-size: 0.95em;
}

.form-grid input[type="date"],
.form-grid input[type="time"] {
  width: 140px;
  padding: 6px 10px;
  font-size: 1em;
  border-radius: 4px;
  border: 1px solid #ccc;
  text-align: center;
}

/* ===========================
   BARRA DE BOTONES
   =========================== */
.button-bar {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
}

.button-bar button {
  padding: 8px 18px;
  font-size: 1em;
  cursor: pointer;
  border: 1px solid #999;
  background-color: #e6e6e6;
  border-radius: 5px;
  transition: background-color 0.2s;
}

.button-bar button:hover {
  background-color: #dcdcdc;
}

/* ===========================
   NOTA ACLARATORIA
   =========================== */
.disclaimer {
  margin-top: 15px;
  font-size: 0.9em;
  color: #444;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.disclaimer .asterisk {
  color: red;
  font-weight: bold;
  font-size: 1.2em;
  vertical-align: middle;
  margin-right: 4px;
}

/* ===========================
   TABLA DE RESULTADOS
   =========================== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

th, td {
  border: 1px solid #ccc;
  padding: 8px;
  text-align: center;
  font-size: 0.95em;
}

th {
  background-color: #ddd;
}

/* Filas con fondo gris claro para mejorar legibilidad */
.grises {
  background-color: #eee;
}

/* ==========================================================
   BLOQUE ESPECÍFICO PARA GAS (FORM-GAS)
   ----------------------------------------------------------
   Este bloque solo se muestra cuando el usuario define un
   rango independiente para el contador GAS (ID 96 / MAG 276).
   Se resalta con un borde azul para diferenciarlo visualmente.
   ========================================================== */
.form-gas {
  display: none;
  border: 2px solid #0070d2;
  border-radius: 8px;
}

/* Mensaje de cooldown bajo el formulario */
#cooldown-msg {
  margin-top: 5px;
  font-size: 14px;
  color: #d00;
}

/* ==========================================================
   POPUP ESPECÍFICO DE GAS
   ----------------------------------------------------------
   Capa semitransparente + tarjeta central.
   Controlado por app.js (mostrar/ocultar con style.display).
   ========================================================== */
.popup-gas-overlay {
  display: none;              /* app.js la pone a "flex" cuando procede */
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

/* Tarjeta interior del popup */
.popup-gas-card {
  background: #fff;
  padding: 25px;
  border-radius: 10px;
  width: 360px;
  text-align: center;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.25);
}

.popup-gas-card h3 {
  margin-top: 0;
}

/* Botones de SI / NO */
.popup-gas-buttons button {
  margin: 10px;
  padding: 6px 18px;
}

/* Formulario interno del popup (solo si se pulsa NO) */
.popup-gas-form {
  display: none;
  margin-top: 15px;
  text-align: left;
}

.popup-gas-form label {
  display: block;
  margin-top: 8px;
}

.popup-gas-form input {
  width: 100%;
  box-sizing: border-box;
}

/* Botón de aceptar en el popup */
.popup-gas-form button {
  padding: 6px 24px;
  margin-top: 12px;
}


/* ==========================================================
   ADAPTACIÓN RESPONSIVE / IIS
   ========================================================== */
#app-root {
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 800px) {
  body { margin: 10px; }
  .header { flex-direction: column; gap: 10px; }
  .header img { height: 70px; }
  .header h1 { font-size: 1.45em; }
  .form-section { padding: 18px 12px; }
  .form-grid { grid-template-columns: 1fr; gap: 8px; }
  .form-grid label { text-align: left; }
  .form-grid input[type="date"],
  .form-grid input[type="time"] { width: 100%; box-sizing: border-box; }
  .button-bar { flex-wrap: wrap; gap: 10px; }
  #resultados { display: block; overflow-x: auto; white-space: nowrap; }
  .popup-gas-card { width: min(360px, calc(100vw - 40px)); box-sizing: border-box; }
}

/* ==========================================================
   AUTENTICACIÓN v1.1.0
   ========================================================== */
.app-locked {
  display: none !important;
}

.login-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.98);
  z-index: 9999;
  padding: 20px;
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  box-sizing: border-box;
  padding: 32px;
  border: 1px solid #d9d9d9;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  text-align: center;
}

.login-logo {
  max-width: 190px;
  max-height: 90px;
  object-fit: contain;
}

.login-card label {
  display: block;
  margin: 20px 0 8px;
  font-weight: 600;
}

.login-card input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #bdbdbd;
  border-radius: 5px;
  font-size: 1rem;
}

.login-card button,
.logout-button {
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.login-card button {
  width: 100%;
  margin-top: 18px;
  padding: 10px 14px;
  font-size: 1rem;
}

.login-error {
  min-height: 1.4em;
  margin-top: 12px;
  font-weight: 600;
}

.logout-button {
  margin-left: auto;
  padding: 8px 12px;
  white-space: nowrap;
}
