/* =====================================================================
   ARCHIVO: css/app.css  (el "estilo" de TODAS las pantallas)
   ---------------------------------------------------------------------
   Aquí se define cómo se ve el sistema: colores, letras, botones, tablas.
   Si quieres cambiar el color de la marca, solo edita los valores de
   la sección ":root" (las "variables" de colores de más abajo).
   ===================================================================== */

/* ---------- 1) COLORES Y MEDIDAS (cámbialos aquí y cambia todo el sistema) ---------- */
:root {
  --ink: #14213d;          /* azul tinta: color principal (menú, botones, títulos) */
  --ink-soft: #3b4663;     /* texto secundario oscuro */
  --muted: #667089;        /* texto de apoyo (etiquetas, ayudas) */
  --line: #e1e5ec;         /* líneas y bordes suaves */
  --bg: #f3f5f8;           /* fondo de la página */
  --card: #ffffff;         /* fondo de las tarjetas */
  --accent: #f2a900;       /* ámbar "reloj marcador": el único color llamativo */
  --accent-ink: #4a3300;   /* texto sobre ámbar */
  --ok: #16875a;   --ok-bg: #e3f5ec;      /* verde: correcto */
  --bad: #c93b3b;  --bad-bg: #fbe8e8;     /* rojo: error / peligro */
  --warn: #8a5a00; --warn-bg: #fff3d1;    /* amarillo: aviso */
  --radius: 10px;
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;  /* títulos y números grandes */
  --font-body: 'Figtree', 'Segoe UI', system-ui, sans-serif;                 /* texto normal */
}

/* ---------- 2) BASE ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font-body); }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 600; }
p { margin: 0; }
a { color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }   /* números alineados en columnas y sin partirse en dos líneas */
.hidden { display: none !important; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }

/* Foco visible para quien navega con teclado */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- 3) FORMULARIOS ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field .help { font-size: 12px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #c9d0dc; border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242,169,0,.35); }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }

/* ---------- 4) BOTONES ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; font: 600 14px var(--font-body); border-radius: 8px; border: 1px solid transparent;
  background: var(--ink); color: #fff; cursor: pointer; text-decoration: none; transition: background .15s, transform .05s;
}
.btn:hover { background: #1f3260; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--ink); border-color: #c9d0dc; }
.btn.secondary:hover { background: #f0f3f8; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.accent:hover { background: #ffb81f; }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #a92f2f; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: #e9edf4; }
.btn.block { width: 100%; }
.btn.lg { padding: 15px 20px; font-size: 16px; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: #e9edf4; color: var(--ink); }
.icon-btn.bad:hover { background: var(--bad-bg); color: var(--bad); }
.ico { width: 18px; height: 18px; flex: none; }

/* ---------- 5) TARJETAS, ETIQUETAS, AVISOS ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card > h3, .card > .card-head { margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #e9edf4; color: var(--ink-soft); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

/* ---------- 6) TABLAS ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px 14px; background: #f7f9fc; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
tr.alert-row td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
td.actions { white-space: nowrap; text-align: right; }
table.nowrap td { white-space: nowrap; }          /* tablas compactas (ej: historial del trabajador en el celular) */

/* ---------- 7) ESTRUCTURA DEL PANEL (menú lateral + contenido) ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #cfd7ea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 22px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { max-height: 42px; max-width: 100%; margin-bottom: 8px; background: #fff; border-radius: 6px; padding: 4px; }
.brand .name { font: 700 18px var(--font-display); color: #fff; }
.brand .slug { font-size: 12px; color: #93a0c0; }
.nav { list-style: none; margin: 14px 0; padding: 0 10px; flex: 1; overflow-y: auto; }
.nav button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px; margin-bottom: 2px; background: none; border: 0; border-radius: 8px; color: inherit; font: 500 14.5px var(--font-body); cursor: pointer; text-align: left; position: relative; }
.nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav button.active { background: rgba(255,255,255,.1); color: #fff; }
.nav button.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.nav .count { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: 12px; font-weight: 700; padding: 0 8px; }
.side-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #93a0c0; }
.side-foot button { background: none; border: 0; color: #cfd7ea; cursor: pointer; font: 600 13px var(--font-body); padding: 6px 0; display: flex; gap: 8px; align-items: center; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .menu-btn { display: none; }
.content { padding: 26px 28px 60px; max-width: 1200px; }
.section { display: none; }
.section.active { display: block; }
.section > * + * { margin-top: 20px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .value { font: 700 34px var(--font-display); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.warn { border-color: var(--accent); }

/* ---------- 8) VENTANAS EMERGENTES (modales) Y AVISOS FLOTANTES ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12,20,40,.55); display: flex; align-items: flex-start; justify-content: center; padding: 30px 14px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); border-left: 5px solid var(--accent); animation: toast-in .2s ease-out; }
.toast.ok { border-left-color: #3ecf8e; } .toast.bad { border-left-color: #ff6b6b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* PIN grande (se muestra una sola vez al crear o restablecer) */
.pin-box { text-align: center; padding: 18px; background: #f7f9fc; border: 2px dashed var(--accent); border-radius: 12px; }
.pin-box .pin { font: 800 42px var(--font-display); letter-spacing: .15em; font-variant-numeric: tabular-nums; }

/* ---------- 9) PANTALLAS PEQUEÑAS (celulares y tablets) ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 22px; }
}
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }      /* en celular: indicadores de a dos por fila */
  .kpi { padding: 14px; } .kpi .value { font-size: 28px; }
  .card { padding: 16px; }
}

/* ---------- 10) IMPRESIÓN (liquidaciones): solo se imprime la ventana abierta ---------- */
@media print {
  body { background: #fff; }
  body > *:not(.modal-backdrop) { display: none !important; }
  .modal-backdrop { position: static; background: none; padding: 0; display: block; }
  .modal { box-shadow: none; max-width: none; padding: 0; }
  .no-print { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
