/* ============================
   estilo.css - Panel IMSERSOBOT
   ============================ */

/* Reset básico */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

/* Layout principal */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: #111827;
  color: #f9fafb;
  padding: 12px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 600;
}

.env-tag {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* Sesión en cabecera */
.header-session {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-user-label {
  font-size: 0.85rem;
  color: #d1d5db;
}

.btn-logout {
  padding: 6px 10px;
  border-radius: 9999px;
  border: none;
  background: #ef4444;
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-logout:hover {
  background: #dc2626;
}

/* Main */
.main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 16px auto;
  padding: 0 12px 24px;
}

/* Tarjetas */
.panel-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  margin-bottom: 16px;
  overflow: hidden;
}

.panel-card-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
}

.panel-card-body {
  padding: 10px 14px 12px;
}

/* Footer */
.footer {
  padding: 10px 16px;
  font-size: 0.8rem;
  color: #6b7280;
  display: flex;
  justify-content: center;
  gap: 6px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.footer-sep {
  color: #d1d5db;
}

/* Estado BOT */
.estado-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.estado-top-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.estado-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.estado-botones {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}


/* Métricas estado (solo actividad) */
.estado-metrics {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  color: #374151;
  font-weight: 600;
}


.estado-error {
  font-size: 0.85rem;
  color: #b91c1c;
}

/* Botones */
.btn {
  border-radius: 9999px;
  border: none;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
}
.btn-primary:hover {
  background: #1d4ed8;
}

.btn-warn {
  background: #f97316;
  color: #111827;
}
.btn-warn:hover {
  background: #ea580c;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}
.btn-secondary:hover {
  background: #d1d5db;
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* Estados ONLINE / OFFLINE en botones */
.btn-state-online {
  background: #16a34a;
  color: #ffffff;
  cursor: default;
}
.btn-state-online:hover {
  background: #16a34a;
}

.btn-state-offline {
  background: #b91c1c;
  color: #ffffff;
  cursor: default;
}
.btn-state-offline:hover {
  background: #b91c1c;
}

/* Configuración general en línea */
.cfg-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.cfg-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.88rem;
}

.cfg-label {
  color: #6b7280;
}
.cfg-value {
  font-weight: 500;
}

/* Pills ON/OFF */
.pill {
  display: inline-flex;
  min-width: 40px;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 9999px;
  font-size: 0.75rem;
  border: 1px solid transparent;
  font-weight: 600;
}
.pill-on {
  background: #16a34a;
  color: #ffffff;
  border-color: #15803d;
}
.pill-off {
  background: #b91c1c;
  color: #ffffff;
  border-color: #fecaca;
}

/* Usuarios */
.usuarios-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.usuarios-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.usuario-bloque {
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  background: #f9fafb;
}

/* Cabecera de usuario */
.usuario-tabla-header,
.usuario-tabla-row {
  display: grid;
  grid-template-columns: 1.4fr 1.7fr 1.3fr 0.7fr 0.9fr 0.8fr 0.8fr;
  gap: 4px;
  align-items: center;
  font-size: 0.8rem;
}

.usuario-tabla-header {
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 2px;
}

.usuario-tabla-row {
  padding: 4px 0;
  border-bottom: 1px dashed #e5e7eb;
}

/* Pills ON/OFF usuario */
.user-pill {
  display: inline-flex;
  padding: 2px 6px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.user-pill-on {
  background: #16a34a;
  color: #ffffff;
}
.user-pill-off {
  background: #b91c1c;
  color: #ffffff;
}

/* Flags En rango / Nuevas (usuario) */
.usuario-flag {
  display: inline-flex;
  min-width: 40px;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #ffffff;
}
.usuario-flag-on {
  background: #16a34a;
}
.usuario-flag-off {
  background: #b91c1c;
}

/* Horas */
.usuario-horas-bloque {
  margin-top: 6px;
}

.usuario-horas-titulo {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 3px;
}

.usuario-horas-grid {
  display: grid;
  grid-template-columns: repeat(24, minmax(14px, 1fr));
  gap: 2px;
}

.hora-pill {
  font-size: 0.7rem;
  padding: 2px 0;
  border-radius: 6px;
  text-align: center;
  border: 1px solid transparent;
  font-weight: 600;
}
.hora-on {
  background: #16a34a;
  color: #ffffff;
  border-color: #15803d;
}
.hora-off {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* Provincias */
.usuario-provincias {
  margin-top: 8px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 6px;
}

.usuario-prov-header,
.usuario-prov-row {
  display: grid;
  grid-template-columns: 2.3fr 1.2fr 1.2fr 1fr 1fr;
  font-size: 0.78rem;
  gap: 4px;
  align-items: center;
}

.usuario-prov-header {
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 2px;
}

.usuario-prov-row {
  padding: 3px 0;
  cursor: pointer;
}
.usuario-prov-row:hover {
  background: #f1f5f9;
}

.usuario-prov-flag {
  font-size: 0.8rem;
}
.usuario-prov-flag-on {
  color: #16a34a;
}
.usuario-prov-flag-off {
  color: #b91c1c;
}

.usuario-prov-detalle {
  font-size: 0.78rem;
  padding: 4px 6px 6px;
  margin-bottom: 4px;
  border-radius: 6px;
  background: #f9fafb;
  border: 1px dashed #e5e7eb;
}

/* Utilidades */
.oculto {
  display: none;
}

/* Login */
.login-body {
  min-height: 100vh;
  background: radial-gradient(circle at top, #1e293b 0, #020617 45%, #000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e5e7eb;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 14px;
  padding: 20px 20px 18px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.7);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.login-card h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 0.85rem;
  text-align: center;
  color: #9ca3af;
  margin-bottom: 12px;
}

.login-error {
  font-size: 0.8rem;
  color: #fecaca;
  background: #7f1d1d;
  border-radius: 9999px;
  padding: 4px 10px;
  margin-bottom: 10px;
  text-align: center;
}

.login-input {
  width: 100%;
  border-radius: 9999px;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
  padding: 6px 10px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.login-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb;
}

.login-card label {
  font-size: 0.8rem;
  margin-bottom: 2px;
  color: #9ca3af;
  display: block;
}

/* Log en vivo */
.log-body {
  background: #020617;
  color: #e5e7eb;
  padding: 10px;
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.log-title {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: #e5e7eb;
}

.terminal {
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #0b1120;
  padding: 8px 10px;
  max-height: 80vh;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: pre-wrap;
}

/* Responsivo */
@media (max-width: 768px) {
  .usuario-tabla-header,
  .usuario-tabla-row {
    grid-template-columns: 1.4fr 1.8fr 1.4fr 0.9fr 0.9fr 0.7fr 0.7fr;
  }

  .usuario-horas-grid {
    grid-template-columns: repeat(24, minmax(12px, 1fr));
  }

  .usuario-prov-header,
  .usuario-prov-row {
    grid-template-columns: 2.1fr 1.1fr 1.1fr 0.9fr 0.9fr;
  }
}
/* ==========================================================
   BOTÓN ONLINE — Parpadeo + HALO animado
   ========================================================== */

/* Fondo parpadeando */
@keyframes blink-online {
  0%   { background-color: #16a34a; }
  50%  { background-color: #22c55e; }
  100% { background-color: #16a34a; }
}

/* Halo suave alrededor */
@keyframes glow-online {
  0% {
    box-shadow: 0 0 0px 0 rgba(34, 197, 94, 0.8);
  }
  50% {
    box-shadow: 0 0 12px 6px rgba(34, 197, 94, 0.55);
  }
  100% {
    box-shadow: 0 0 0px 0 rgba(34, 197, 94, 0.8);
  }
}

/* Se aplica SOLO cuando está online */
#btn-iniciar.btn-state-online {
  background-color: #16a34a !important;
  color: #ffffff !important;
  animation:
    blink-online 1.3s infinite ease-in-out,
    glow-online 2s infinite ease-in-out !important;
  position: relative;
  z-index: 2;
}

/* ==========================================================
   BOTÓN “Parar bot” — Rojo permanente
   ========================================================== */
.btn-stop {
  background-color: #dc2626 !important;
  color: white !important;
}


/* ==============================
   BOTONES MANUALES
   ============================== */
.btn-manual {
  background: #2563eb;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  margin-right: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-manual:hover {
  background: #1e40af;
}


/* =====================================================
   ESTILO DEFINITIVO PARA MANUALES — UNA SOLA COLUMNA
   ===================================================== */

.manual-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

/* Header de botones (PDF, volver…) */
.manual-header-buttons {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}

/* Contenedor principal: UNA SOLA COLUMNA */
.manual-main {
  display: block !important;
  width: 100%;
}

/* Navegación: aparece arriba como bloque */
.manual-nav {
  background: var(--panel-bg);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  padding: 12px;
  margin-bottom: 20px;
}

.manual-nav a {
  display: block;
  text-decoration: none;
  color: var(--text-color);
  padding: 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.manual-nav a:hover {
  background: var(--hover-bg);
}

/* Cada sección del manual */
.manual-section {
  background: var(--panel-bg);
  color: var(--text-color);
  padding: 20px;
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  margin-bottom: 26px;
}

/* Títulos principales */
.manual-section h2 {
  margin-top: 0;
  font-size: 1.4rem;
  margin-bottom: 12px;
  font-weight: 600;
}

/* Títulos secundarios */
.manual-section h3 {
  margin-top: 18px;
  font-size: 1.15rem;
  margin-bottom: 10px;
  font-weight: 600;
}

/* Párrafos */
.manual-section p {
  line-height: 1.45;
  margin-bottom: 10px;
}

/* Listas */
.manual-section ul {
  margin-left: 20px;
  margin-bottom: 12px;
}

.manual-section li {
  margin-bottom: 6px;
}

/* Notas informativas */
.manual-note {
  background: #fef9c3;
  border-left: 4px solid #ca8a04;
  padding: 10px;
  border-radius: 6px;
  margin-top: 10px;
  font-size: 0.9rem;
  color: #444;
}

/* Callouts azules */
.manual-callout {
  background: #e0f2fe;
  border-left: 4px solid #0284c7;
  padding: 10px;
  border-radius: 6px;
  margin-top: 10px;
  font-size: 0.9rem;
}

/* Bloques de código */
.manual-code {
  background: #111827;
  color: #e5e7eb;
  padding: 12px;
  border-radius: 6px;
  font-family: monospace;
  white-space: pre-wrap;
  overflow-x: auto;
  margin-top: 10px;
  font-size: 0.9rem;
}

/* Responsivo manuales */
@media (max-width: 768px) {
  .manual-page {
    padding: 10px;
  }
}
