/*
 * Estilos del panel administrativo (SPA) de SmartTemp.
 *
 * Comparten la paleta y el lenguaje visual del formulario público de alta
 * (`form-alta.html`) para mantener coherencia de marca. Se agregan estilos de
 * layout (login, barra superior, navegación lateral por rol, tablas y tarjetas
 * de módulo) para el panel administrativo.
 *
 * _Requirements: 14.2, 14.4_
 */

:root {
  --azul: #1a5fb4;
  --azul-oscuro: #14487f;
  --azul-claro: #eaf1fb;
  --gris-borde: #cbd2d9;
  --gris-texto: #3b4351;
  --gris-suave: #6b7280;
  --rojo: #b02a37;
  --rojo-fondo: #fbeaec;
  --verde: #1e7e46;
  --verde-fondo: #e7f5ec;
  --fondo: #f2f4f7;
  --panel: #ffffff;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fondo);
  color: var(--gris-texto);
  line-height: 1.5;
}

/* Utilidad para ocultar elementos según rol / estado de sesión. */
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ */
/* Login                                                              */
/* ------------------------------------------------------------------ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.login-card .encabezado {
  background: var(--azul);
  color: #fff;
  padding: 24px 28px;
}

.login-card .encabezado h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-card .encabezado p { margin: 0; font-size: 0.9rem; opacity: 0.9; }

.login-card form { padding: 24px 28px 28px; }

/* ------------------------------------------------------------------ */
/* Layout de la aplicación (topbar + sidebar + contenido)             */
/* ------------------------------------------------------------------ */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--azul);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar .marca { font-size: 1.15rem; font-weight: 700; }

.topbar .sesion { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }

.topbar .rol-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  text-transform: capitalize;
}

.topbar button {
  width: auto;
  padding: 6px 14px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.15);
}

.topbar button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.28); }

.cuerpo { flex: 1; display: flex; align-items: stretch; }

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--gris-borde);
  padding: 16px 0;
  flex-shrink: 0;
}

.sidebar nav { display: flex; flex-direction: column; }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 20px;
  border: none;
  background: transparent;
  color: var(--gris-texto);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--azul-claro); }

.nav-item.activo {
  background: var(--azul-claro);
  color: var(--azul-oscuro);
  border-left-color: var(--azul);
  font-weight: 600;
}

.contenido { flex: 1; padding: 24px; overflow: auto; }

.vista { max-width: 1000px; margin: 0 auto; }
.vista h2 { margin-top: 0; font-size: 1.3rem; }

/* ------------------------------------------------------------------ */
/* Tarjetas / paneles de módulo                                       */
/* ------------------------------------------------------------------ */

.panel {
  background: var(--panel);
  border: 1px solid var(--gris-borde);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel h3 { margin-top: 0; font-size: 1.05rem; }

.acciones { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.fila { display: flex; gap: 14px; flex-wrap: wrap; }
.fila .campo { flex: 1; min-width: 160px; }

/* ------------------------------------------------------------------ */
/* Formularios (reutilizado de form-alta)                             */
/* ------------------------------------------------------------------ */

.campo { margin-bottom: 16px; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 6px;
}

label .obligatorio { color: var(--rojo); margin-left: 2px; }
.opcional { color: #8a94a6; font-weight: 400; font-size: 0.82rem; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  background: #fff;
  color: var(--gris-texto);
  font-family: inherit;
}

textarea { min-height: 96px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(26, 95, 180, 0.15);
}

input.invalido, select.invalido { border-color: var(--rojo); }

button {
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--azul);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover:not(:disabled) { background: var(--azul-oscuro); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

button.secundario { background: #e5e9f0; color: var(--gris-texto); }
button.secundario:hover:not(:disabled) { background: #d6dce6; }

button.bloque { width: 100%; }

/* ------------------------------------------------------------------ */
/* Mensajes                                                           */
/* ------------------------------------------------------------------ */

.mensaje {
  display: none;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 0.92rem;
}

.mensaje.visible { display: block; }
.mensaje.exito { background: var(--verde-fondo); color: var(--verde); border: 1px solid #b7e0c4; }
.mensaje.error { background: var(--rojo-fondo); color: var(--rojo); border: 1px solid #f0c2c7; }
.mensaje ul { margin: 8px 0 0; padding-left: 20px; }

/* ------------------------------------------------------------------ */
/* Tablas                                                             */
/* ------------------------------------------------------------------ */

.tabla-wrap { overflow-x: auto; }

table.datos {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.datos th, table.datos td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--gris-borde);
}

table.datos th { background: var(--azul-claro); color: var(--azul-oscuro); font-weight: 600; }
table.datos tr:hover td { background: #f8fafc; }

.vacio { color: var(--gris-suave); font-style: italic; padding: 12px 0; }

pre.salida {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* Campo de contraseña con botón "ojito" para mostrar/ocultar          */
/* ------------------------------------------------------------------ */

.campo-password {
  position: relative;
}

.campo-password input {
  /* espacio a la derecha para el botón del ojito */
  padding-right: 44px;
}

.campo-password .ojito {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--gris-texto);
}

.campo-password .ojito:hover:not(:disabled) {
  background: var(--azul-claro);
}

/* ------------------------------------------------------------------ */
/* Recuperación de contraseña (login + página reset.html)             */
/* ------------------------------------------------------------------ */

.olvido-wrap {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.9rem;
}

.olvido-wrap a {
  color: var(--azul);
  text-decoration: none;
}

.olvido-wrap a:hover { text-decoration: underline; }

.forgot-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gris-borde);
}
