/* =========================================================================
   Componentes reutilizables (sus macros están en templates/components).
   ========================================================================= */

/* -- Tarjetas y rejillas -------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.card--link { display: block; color: inherit; text-decoration: none; }
.card--row { display: flex; gap: 12px; align-items: center; }
.card--warn { border-color: var(--warn); }
.card--info { background: var(--brand-soft); border: 0; color: var(--brand-text); }

.stack { display: grid; gap: var(--gap); }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--wide, .grid--3 { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid--wide { grid-template-columns: 1.4fr 1fr; }
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.span-2 { grid-column: span 2; }

/* -- Cifras --------------------------------------------------------------- */
.stat__label { font-size: 14px; color: var(--muted); }
.stat__value {
  font-size: clamp(24px, 3vw, 32px); font-weight: 800; line-height: 1.1; white-space: nowrap;
}
.stat__note { font-size: 13px; color: var(--muted); }

/* -- Etiquetas de estado -------------------------------------------------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pill--ok { background: var(--ok-bg); color: var(--ok); }
.pill--warn { background: var(--warn-bg); color: var(--warn); }
.pill--bad { background: var(--bad-bg); color: var(--bad); }
.pill--info { background: var(--brand-soft); color: var(--brand-text); }
.pill--muted { background: var(--neutral-bg); color: var(--muted); }

/* -- Botones -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 0 20px;
  border: 0; border-radius: 12px;
  background: var(--brand); color: #fff; font-weight: 700;
  cursor: pointer; text-decoration: none;
}
.btn svg { width: 20px; height: 20px; }
.btn--outline { background: transparent; border: 1.5px solid var(--brand-text); color: var(--brand-text); }
.btn--small { min-height: 40px; padding: 0 14px; }
.btn--block { width: 100%; }
.btn--big { width: 100%; min-height: 76px; font-size: 21px; border-radius: 18px; }
.btn--start { justify-self: start; }
.btn[disabled], .btn.is-busy { opacity: .55; cursor: progress; }
.inline-form { display: contents; }

/* -- Listas --------------------------------------------------------------- */
.list > * {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.list > :last-child { border-bottom: 0; }
.icon-box {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand-text);
}
.icon-box svg { width: 22px; height: 22px; }
.icon-box--ok { background: var(--ok-bg); color: var(--ok); }
.icon-box--warn { background: var(--warn-bg); color: var(--warn); }
.icon-box--bad { background: var(--bad-bg); color: var(--bad); }
.icon-box--small { width: 32px; height: 32px; }
.chevron { color: var(--muted); }

/* -- Avatar con iniciales ------------------------------------------------- */
.avatar {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; text-decoration: none;
}
.avatar--header { width: 44px; height: 44px; font-size: 15px; }
.avatar--large { width: 64px; height: 64px; font-size: 22px; }

/* -- Formularios ---------------------------------------------------------- */
label, .label { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: var(--touch); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); font-size: 16px;
}
textarea { min-height: 110px; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.checkbox { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--ink); }

.password-field { position: relative; }
.password-field input { padding-right: 76px; }
.password-field button {
  position: absolute; top: 6px; right: 6px; height: 36px; padding: 0 10px;
  border: 0; background: transparent; color: var(--brand-text); font-weight: 700; cursor: pointer;
}

/* Elección tipo «chip» con radios (funciona sin JavaScript). */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
.chip { position: relative; margin: 0; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink); cursor: pointer;
}
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Botón de adjuntar archivo (input file escondido detrás de la etiqueta). */
.file-picker { position: relative; display: block; margin: 0; }
.file-picker input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-picker > span {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 0 16px; border-radius: 12px;
  border: 1.5px dashed var(--brand-text); color: var(--brand-text); font-weight: 700; cursor: pointer;
}
.file-picker svg { width: 20px; height: 20px; flex: none; }
.file-picker.has-file > span { border-style: solid; border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }

/* -- Avisos --------------------------------------------------------------- */
.alert { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 15px; }
.alert--error { background: var(--bad-bg); color: var(--bad); }
.alert--success { background: var(--ok-bg); color: var(--ok); }
.alert--info { background: var(--brand-soft); color: var(--brand-text); }
.note { margin-top: 18px; font-size: 13px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 50; max-width: 90vw;
  transform: translateX(-50%); padding: 12px 18px; border-radius: 12px;
  background: #14192A; color: #fff; opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.toast.is-visible { opacity: 1; }
@media (min-width: 768px) { .toast { bottom: 32px; } }

/* -- Barra de progreso (<progress> nativo: sin estilos en línea por la CSP) -- */
.progress {
  appearance: none; display: block; width: 100%; height: 10px;
  border: 0; border-radius: 5px; background: var(--line); overflow: hidden;
}
.progress::-webkit-progress-bar { background: var(--line); }
.progress::-webkit-progress-value { background: var(--brand-bar); }
.progress::-moz-progress-bar { background: var(--brand-bar); }

/* -- Tablas (se apilan en el móvil) --------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th {
  padding: 8px; border-bottom: 1px solid var(--line);
  text-align: left; color: var(--muted); font-weight: 600; font-size: 13px;
}
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .num { text-align: right; white-space: nowrap; }
.table--keyvalue td:first-child { width: 45%; color: var(--muted); }
.table--keyvalue td:last-child { font-weight: 700; }

@media (max-width: 600px) {
  .table--stack thead { display: none; }
  .table--stack tr { display: grid; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table--stack td { display: flow-root; padding: 2px 0 2px 7.5em; border: 0; }
  .table--stack td::before {
    content: attr(data-label); float: left; width: 7em; margin-left: -7.5em;
    color: var(--muted); font-size: 13px;
  }
  .table--stack .num { text-align: left; }
  .table--stack td:empty { display: none; }
}

/* -- Portada: bloque azul de fichaje -------------------------------------- */
.hero {
  display: flex; gap: 16px; align-items: center;
  padding: 20px; border-radius: var(--radius-lg);
  background: var(--brand); color: #fff; text-decoration: none;
}
.hero__muted { opacity: .78; font-size: 14px; }
.hero__title { font-size: 22px; font-weight: 700; }
.hero__round {
  display: grid; place-items: center; flex: none;
  width: 64px; height: 64px; border-radius: 50%; background: #fff; color: var(--brand);
}
.hero--block { display: block; }

/* Botón que se ve como una fila de lista (p. ej. «Cerrar sesión», que es un POST). */
.list__button {
  display: flex; gap: 12px; align-items: center; width: 100%;
  padding: 0; border: 0; background: none; color: inherit;
  text-align: left; cursor: pointer;
}

/* -- Interruptor (p. ej. «Enviar de forma anónima»): checkbox con estilo ---- */
.switch {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink);
}
.switch input {
  appearance: none; position: relative; flex: none; cursor: pointer;
  width: 46px; height: 26px; min-height: 26px; padding: 0;
  border: 0; border-radius: 13px; background: var(--line);
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: left .15s;
}
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 23px; }

/* -- Fotos del documento: dos botones grandes que abren la cámara ---------- */
.photo-pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.photo-pickers .file-picker > span {
  flex-direction: column; min-height: 96px; padding: 10px;
  border: 2px dashed var(--line); background: var(--bg); color: var(--muted); font-weight: 400;
}
.photo-pickers .file-picker svg { width: 26px; height: 26px; }

/* -- Título de sección con icono (Mi perfil) -------------------------------- */
.section-title { display: flex; gap: 8px; align-items: center; }

/* -- Selector de idioma ------------------------------------------------------ */
.language-switch { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 14px; }
.language-switch__option {
  min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--muted); cursor: pointer; font-size: 14px;
}
.language-switch__option.is-active { border-color: var(--brand-text); color: var(--brand-text); font-weight: 700; }

/* -- Confirmación del fichaje (ventana con «Hecho», mockup v5) ------------- */
.done-dialog {
  width: min(92vw, 380px); padding: 28px 22px 22px; border: 0; border-radius: var(--radius-lg);
  background: var(--card); color: inherit; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.done-dialog[open]:not(:modal) { position: fixed; inset: 0; margin: auto; z-index: 50; }
.done-dialog::backdrop { background: rgba(10, 15, 30, .45); }
.done-dialog h2 { margin: 12px 0 6px; font-size: 22px; }
.done-dialog p { margin: 0 0 18px; }
.done-dialog__check {
  display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--ok-bg); color: var(--ok);
}
.done-dialog__check svg { width: 32px; height: 32px; }
