/*
 * Sistema de diseño — Talleres de los Centros Comunitarios de Ushuaia
 *
 * Un solo archivo, sin build step (coherente con el resto del proyecto:
 * EJS renderizado en el servidor, sin bundler). Basado en los mockups de
 * referencia (paleta morada + Libre Franklin/Public Sans) que ya existían
 * para el proyecto. Todas las páginas (panel interno y catálogo público)
 * cargan este mismo archivo vía <link>, así que un cambio acá se ve en
 * todos lados.
 *
 * Las tipografías se sirven desde /fonts (self-hosted) en vez de tirar de
 * Google Fonts: una VPS municipal a futuro podría estar en una red con
 * salida a internet restringida (el mismo motivo por el que se eligió
 * Resend por SMTP y no depender de otro servicio externo), y así la
 * fuente carga siempre, sin depender de un tercero.
 */

@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/libre-franklin-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/libre-franklin-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/libre-franklin-latin-800-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/public-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/public-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/public-sans-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/public-sans-latin-700-normal.woff2') format('woff2');
}

:root {
  /* Superficies y texto */
  --bg: #FAF9FC;
  --surface: #FFFFFF;
  --border: #E7E3EE;
  --border-strong: #D9D3E6;
  --text: #1F1730;
  --text-2: #655D74;
  --text-3: #9691A3;

  /* Marca */
  --accent: #4B2E9E;
  --accent-dark: #37217A;
  --accent-bright: #6C4FD1;
  --accent-light: #8B6FD9;
  --accent-soft: #5B3FB0;
  --accent-tint: #EFEAFB;
  --accent-tint-2: #E3DBF7;

  /* Estados semánticos (mismo nombre que usa el código: VERDE/AMARILLO/NARANJA/GRIS) */
  --verde-bg: #E6F6EC;   --verde-fg: #15803D;
  --amarillo-bg: #FBF0D9; --amarillo-fg: #92700A;
  --naranja-bg: #FDECE1; --naranja-fg: #C2410C;
  --gris-bg: #EEEDF0;    --gris-fg: #57534E;
  --rojo-bg: #FDECEC;    --rojo-fg: #B91C1C;

  /* Panel interno */
  --sidebar-bg: #241A3D;
  --sidebar-text: #B7ADD6;
  --sidebar-text-dim: #8776A8;
  --sidebar-active: #3A2A66;

  /* Escala */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-sm: 0 4px 16px rgba(31, 23, 48, 0.05);
  --shadow: 0 8px 24px rgba(31, 23, 48, 0.08);
  --shadow-lg: 0 12px 32px rgba(31, 23, 48, 0.10);
  --font-display: 'Libre Franklin', system-ui, sans-serif;
  --font-body: 'Public Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 8px;
}

h2 { font-size: 24px; }
h3 { font-size: 17px; margin-bottom: 10px; }

p { line-height: 1.55; }

a { color: var(--accent); }

.detalle { font-size: 13px; color: var(--text-2); margin: 2px 0; }
.ayuda { color: var(--text-3); font-size: 12.5px; margin-top: 4px; line-height: 1.5; }

/* ---------- Botones ---------- */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn.secundario { background: var(--gris-bg); color: var(--text); }
.btn.secundario:hover { background: var(--border-strong); }
.btn.peligro { background: var(--rojo-fg); }
.btn.peligro:hover { background: #8f1414; }

/* ---------- Tarjetas y contenedores ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 18px;
}

/* ---------- Formularios ---------- */
label { display: block; margin-bottom: 14px; font-size: 14px; }
label span.txt { display: block; margin-bottom: 5px; font-weight: 600; color: var(--text); }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea { min-height: 80px; }

.fila-check { display: flex; align-items: center; gap: 8px; }
.fila-check input { width: auto; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }

.error { color: var(--rojo-fg); font-size: 12.5px; margin-top: 4px; }

/* ---------- Avisos ---------- */
.aviso, .ok, .error-caja {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 18px;
  line-height: 1.5;
}
.aviso { background: var(--amarillo-bg); border: 1px solid #EBCB7A; color: #6b4d05; }
.ok { background: var(--verde-bg); border: 1px solid #9AD9AF; color: #0f5c2c; }
div.error-caja { background: var(--rojo-bg); border: 1px solid #F3B4B4; color: var(--rojo-fg); }

/* ---------- Insignias / píldoras de estado ---------- */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--gris-bg);
  color: var(--gris-fg);
}
.badge.on { background: var(--verde-bg); color: var(--verde-fg); }
.badge.off { background: var(--rojo-bg); color: var(--rojo-fg); }

.estado-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 10px;
}
.estado-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.estado-pill.VERDE { background: var(--verde-bg); color: var(--verde-fg); }
.estado-pill.AMARILLO { background: var(--amarillo-bg); color: var(--amarillo-fg); }
.estado-pill.NARANJA { background: var(--naranja-bg); color: var(--naranja-fg); }
.estado-pill.GRIS { background: var(--gris-bg); color: var(--gris-fg); }

/* ---------- Estadísticas (ficha de inscriptos) ---------- */
.stats-fila { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stats-fila .stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  box-shadow: var(--shadow-sm);
}
.stats-fila .stat .num { display: block; font-family: var(--font-display); font-size: 26px; font-weight: 800; color: var(--accent); }
.stats-fila .stat .num.alerta { color: var(--naranja-fg); }
.stats-fila .stat .lbl { font-size: 12px; color: var(--text-2); }

/* ---------- Barras de herramientas ---------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar h2 { margin: 0; }

/* ---------- Tablas ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 18px;
}
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th {
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }
td a { font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }

/* ---------- Layout del panel interno ---------- */
.app-shell { display: flex; min-height: 100vh; align-items: flex-start; }

.sidebar {
  width: 240px;
  flex: none;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  min-height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: 15px;
}
.sidebar-brand .marca {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--accent-bright);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex: none;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.activo { background: var(--sidebar-active); color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; margin-top: 14px; }
.sidebar-foot form { margin: 0; }
.sidebar-foot button {
  background: none;
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.sidebar-foot button:hover { background: rgba(255,255,255,0.08); color: #fff; }

.app-main { flex: 1; min-width: 0; }

.app-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.app-topbar h1 {
  font-size: 18px;
  margin: 0;
}
.userbox { display: flex; align-items: center; gap: 12px; }
.userbox .quien { font-size: 13px; color: var(--text-2); text-align: right; line-height: 1.3; }
.userbox .quien strong { color: var(--text); display: block; font-size: 13.5px; }
.userbox form { margin: 0; }
.userbox button {
  background: var(--gris-bg);
  border: none;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.userbox button:hover { background: var(--border-strong); color: var(--text); }

.app-main main { max-width: 1080px; margin: 0 auto; padding: 28px; }

@media (max-width: 880px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-height: 0;
    position: static;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 12px 14px;
  }
  .sidebar-brand { padding: 0 14px 0 0; flex: none; }
  .sidebar-nav { flex-direction: row; flex: none; }
  .sidebar-nav a { white-space: nowrap; }
  .sidebar-foot { border-top: none; margin: 0 0 0 10px; padding: 0; flex: none; }
  .sidebar-foot button { width: auto; white-space: nowrap; }
  .app-main main { padding: 18px; }
  .app-topbar { padding: 14px 18px; }
}

/* Tablas en columna en pantallas angostas: cada fila pasa a ser una
   "tarjeta" con etiqueta + valor, en vez de forzar el scroll horizontal.
   Requiere que cada <td> tenga data-label="..." (agregado en las vistas). */
@media (max-width: 720px) {
  .table-wrap { border-radius: var(--radius); }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr {
    padding: 12px 14px;
    border-bottom: 8px solid var(--bg);
  }
  tbody tr:last-child { border-bottom: none; }
  td {
    border: none;
    padding: 7px 0;
    font-size: 14.5px;
  }
  td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-3);
    margin-bottom: 2px;
  }
  td[data-label=""] { padding-top: 10px; display: flex; gap: 12px; flex-wrap: wrap; }
  td:empty { display: none; }
}

/* ---------- Panel público (catálogo) ---------- */
.topbar-publico {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.topbar-publico .marca-grupo { display: flex; align-items: center; gap: 12px; }
.topbar-publico .marca {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--accent-bright);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; flex: none;
}
.topbar-publico .titulos h1 { font-size: 16px; margin: 0; }
.topbar-publico .titulos p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-2); }
.topbar-publico a.login {
  color: var(--accent);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  border: 1px solid var(--border-strong);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
}
.topbar-publico a.login:hover { background: var(--accent-tint); border-color: var(--accent-tint); }

.hero-publico { background: linear-gradient(180deg, var(--accent-tint) 0%, var(--bg) 100%); padding: 36px 28px 8px; }
.hero-publico .hero-inner { max-width: 1080px; margin: 0 auto; }
.hero-publico h2 { font-size: 30px; margin-bottom: 6px; text-wrap: balance; }
.hero-publico p { color: var(--text-2); margin: 0; max-width: 62ch; }

main.contenido-publico { max-width: 1080px; margin: 0 auto; padding: 24px 28px 48px; }

.filtros {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 20px;
}
.filtros label { margin-bottom: 0; min-width: 180px; flex: 1; }
.filtros .btn { flex: none; align-self: stretch; }

.grid-talleres { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.taller-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.taller-card .banda {
  height: 64px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px;
}
.taller-card:nth-of-type(3n+1) .banda { background: var(--accent-bright); }
.taller-card:nth-of-type(3n+2) .banda { background: var(--accent); }
.taller-card:nth-of-type(3n) .banda { background: var(--accent-light); }
.taller-card.GRIS .banda { background: var(--text-3); }
.taller-card .cuerpo { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.taller-card h3 { margin: 0 0 4px; font-size: 16px; }
.taller-card .acciones { margin-top: 14px; }
.taller-card .acciones .btn { width: 100%; text-align: center; }

/* ---------- Página de login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--accent-dark) 0%, var(--accent) 45%, var(--accent-bright) 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 34px 30px;
}
.login-card .marca {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--accent-bright);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; margin-bottom: 16px;
}
.login-card h1 { font-size: 19px; margin-bottom: 6px; }
.login-card p.sub { color: var(--text-2); font-size: 13.5px; margin: 0 0 22px; }
.login-card button { width: 100%; padding: 11px; font-size: 14.5px; }

/* ---------- Página de error ---------- */
.error-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.error-card {
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 30px;
  text-align: center;
}
.error-card .marca { font-size: 34px; margin-bottom: 6px; }

/* ---------- Tablero de indicadores (Fase 6) ---------- */
.tablero-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.tablero-tiles .stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.tablero-tiles .stat .num { display: block; font-family: var(--font-display); font-size: 28px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.tablero-tiles .stat .num .sobre { font-size: 15px; font-weight: 600; color: var(--text-3); }
.tablero-tiles .stat .num.alerta { color: var(--naranja-fg); }
.tablero-tiles .stat .lbl { font-size: 12.5px; color: var(--text-2); margin-top: 4px; display: block; }

.tablero-secciones { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .tablero-secciones { grid-template-columns: 1fr; } }
.tablero-seccion.full { grid-column: 1 / -1; }

.tablero-seccion h3 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tablero-seccion .nota { font-size: 12px; color: var(--text-3); font-weight: 500; }

/* Evolución semanal: barras CSS puras, sin librería de gráficos. */
.grafico-evolucion {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  padding-top: 8px;
}
.grafico-evolucion .col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.grafico-evolucion .col .valor { font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.grafico-evolucion .col .barra {
  width: 100%;
  max-width: 30px;
  background: var(--accent-bright);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: background 0.15s ease;
}
.grafico-evolucion .col:last-child .barra { background: var(--accent); }
.grafico-evolucion .col .etiqueta { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }

/* Ocupación por sede: barras horizontales. */
.ocupacion-sedes { display: flex; flex-direction: column; gap: 14px; }
.ocupacion-sede .fila-nombre { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 5px; }
.ocupacion-sede .fila-nombre .nombre { font-weight: 600; }
.ocupacion-sede .fila-nombre .cifra { color: var(--text-2); font-variant-numeric: tabular-nums; }
.ocupacion-sede .barra-fondo {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  height: 10px;
  overflow: hidden;
}
.ocupacion-sede .barra-relleno { height: 100%; background: var(--accent-bright); border-radius: var(--radius-pill); }
.ocupacion-sede .barra-relleno.lleno { background: var(--naranja-fg); }

.vacio-tablero { color: var(--text-3); font-size: 13.5px; padding: 6px 0; }
.alerta-texto { color: var(--naranja-fg); font-weight: 700; }
