/* ============================================================================
 *  COMPONENTES · Sistema ProinfoHR (web)
 *  Versión: 2026-05-18
 *  Depende de tokens.css. Orden de carga:
 *    <link rel="stylesheet" href="/css/tokens.css">
 *    <link rel="stylesheet" href="/css/components.css">
 *  Reglas de oro aplicadas (design-system §11):
 *    · Filled buttons sólido seed (no gradient)
 *    · Cards opacas, una sola sombra, sin backdrop-filter
 *    · Inputs sin border lateral, focus seed 1.8
 *    · PressableCard scale 0.96 al active
 *    · Gradient solo en hero
 * ========================================================================= */

/* ============================================================================
 *  BOTONES — design-system §6 (FilledButton/OutlinedButton/TextButton)
 *  Spec: full-width 54 px, radius 14, 15 w600 ls 0.1.
 * ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--btn-height);
  padding: 0 var(--space-9);
  border-radius: var(--radius-lg);
  border: 0;
  background: transparent;
  font-family: var(--font-base);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.1px;
  line-height: 1;
  color: var(--on-surface);
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: background-color var(--duration-press) var(--ease-out),
              color var(--duration-press) var(--ease-out),
              border-color var(--duration-press) var(--ease-out),
              transform var(--duration-press) var(--ease-out);
}

.btn:active           { transform: scale(0.97); }
.btn:disabled         { cursor: not-allowed; opacity: 1; }
.btn .ms              { font-size: 18px; }
.btn.block            { display: flex; width: 100%; }

/* Filled (CTA principal) — sólido seed */
.btn-filled {
  background: var(--seed);
  color: #FFFFFF;
}
.btn-filled:hover:not(:disabled) { background: var(--seed-hover); }
.btn-filled:disabled             { background: var(--outline); color: #FFFFFF; }

/* Filled danger */
.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

/* Outlined */
.btn-outlined {
  background: transparent;
  color: var(--on-surface);
  border: 1.2px solid var(--outline-variant);
}
.btn-outlined:hover:not(:disabled) {
  background: var(--surface-container-low);
  border-color: var(--outline);
}

/* Text (link button) — fg seed w600 14 */
.btn-text {
  min-height: auto;
  padding: 6px 8px;
  background: transparent;
  color: var(--seed);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
}
.btn-text:hover:not(:disabled) { background: rgba(37, 99, 235, 0.06); }

/* Botón circular para back / header */
.btn-icon {
  min-height: auto;
  width: var(--header-icon-btn);
  height: var(--header-icon-btn);
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--on-surface);
}
.btn-icon:hover:not(:disabled) { background: var(--surface-container-low); }
.btn-icon .ms { font-size: 22px; }

/* Botón sobre hero gradient (blanco translúcido) */
.btn-icon-on-hero {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
  color: #FFFFFF;
}
.btn-icon-on-hero:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.28);
}

/* ============================================================================
 *  INPUTS — design-system §6 InputDecorationTheme
 *  Spec: filled sobre surfaceDim, sin border lateral, radius 14,
 *        focus border seed 1.8, contentPadding 18/18.
 * ========================================================================= */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label,
.field > .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--on-surface-variant);
}

.input,
.textarea,
.select {
  display: block;
  width: 100%;
  min-height: var(--input-height);
  padding: var(--space-8);
  border: 1.8px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--surface-dim);
  font-family: var(--font-base);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--on-surface);
  outline: none;
  transition: border-color var(--duration-press) var(--ease-out),
              background-color var(--duration-press) var(--ease-out);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--on-surface-variant);
  opacity: 0.7;
  font-weight: 400;
}

.input:hover:not(:focus):not(:disabled),
.textarea:hover:not(:focus):not(:disabled),
.select:hover:not(:focus):not(:disabled) {
  background: #EEF2F8;
}

.input:focus,
.textarea:focus,
.select:focus {
  background: var(--surface);
  border-color: var(--seed);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"],
.select[aria-invalid="true"] {
  border-color: var(--danger);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Select con chevron custom */
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* Checkbox custom */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--on-surface);
}
.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-xs);
  accent-color: var(--seed);
  cursor: pointer;
  flex-shrink: 0;
}

/* Texto de ayuda / error inline */
.field .help  { font-size: 12px; color: var(--on-surface-variant); }
.field .error { font-size: 12px; font-weight: 500; color: var(--danger); }

/* ============================================================================
 *  CARDS — design-system §11.13 (radius 18-20, opacas, una sola sombra)
 * ========================================================================= */

.card {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-9);
  box-shadow: var(--shadow-soft);
}

.card-sm {
  border-radius: var(--radius-xl);
  padding: var(--space-7);
}

.card-elevated { box-shadow: var(--shadow-card); }

/* PressableCard — feedback táctil (design-system §7.1) */
.pressable {
  cursor: pointer;
  transition: transform var(--duration-press) var(--ease-out);
}
.pressable:active     { transform: scale(0.96); }
.pressable-sm:active  { transform: scale(0.97); }
.pressable-lg:active  { transform: scale(0.94); }

/* ============================================================================
 *  APP BAR — design-system §11.6 (plano sobre surfaceDim, elevation 0)
 * ========================================================================= */

.app-bar {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-7);
  background: var(--surface-dim);
}

.app-bar .title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--on-surface);
  flex: 1;
}

/* ============================================================================
 *  HERO HEADER — design-system §8.1
 *  Spec: bottom radius 28, hero gradient, padding 16/8/10/18, color blanco.
 * ========================================================================= */

.hero-header {
  position: relative;
  overflow: hidden;
  padding: max(env(safe-area-inset-top), 8px) 10px 18px 16px;
  border-bottom-left-radius: var(--radius-hero-bottom);
  border-bottom-right-radius: var(--radius-hero-bottom);
  background: var(--hero-gradient);
  color: #FFFFFF;
}

.hero-header h1, .hero-header h2, .hero-header h3 { color: #FFFFFF; }

.hero-greeting {
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.hero-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #FFFFFF;
}

.hero-avatar {
  width: var(--avatar-hero);
  height: var(--avatar-hero);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.hero-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 600;
}

/* Dashboard hero card (sombra brand) — design-system §8.1 */
.hero-card {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-6) var(--space-5);
  box-shadow: var(--shadow-soft), var(--shadow-brand);
}

/* ============================================================================
 *  TABS PÍLDORA — design-system §7.7 (AppPillTabBar)
 *  Spec: container surfaceContainer radius 14 padding 4, indicador surface
 *        radius 10 con soft shadow, label 13 w600.
 * ========================================================================= */

.pill-tabs {
  display: flex;
  gap: 0;
  padding: 4px;
  background: var(--surface-container);
  border-radius: var(--radius-lg);
  margin: 0 var(--space-7) 10px;
}

.pill-tabs .tab {
  flex: 1;
  min-height: calc(var(--tabbar-height) - 8px);
  padding: 0 var(--space-5);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-base);
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: background-color var(--duration-press) var(--ease-out),
              color var(--duration-press) var(--ease-out);
}

.pill-tabs .tab:hover:not([aria-selected="true"]) { color: var(--on-surface); }

.pill-tabs .tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--on-surface);
  box-shadow: var(--shadow-soft);
}

/* ============================================================================
 *  BADGES DE ESTADO (SAT y similares)
 *  Pill compacta con par fondo+color semántico.
 * ========================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-asignar              { background: #FEF3C7; color: #B45309; }
.badge-pendiente_aceptacion { background: #DBEAFE; color: #1E40AF; }
.badge-programado           { background: #E0E7FF; color: #4338CA; }
.badge-en_curso             { background: #FFEDD5; color: #C2410C; }
.badge-cerrado              { background: #D1FAE5; color: #047857; }
.badge-cancelado            { background: #FEE2E2; color: #B91C1C; }

/* ============================================================================
 *  MODAL / DIALOG — design-system §8.9
 *  Spec: radius 20, sin backdrop-filter, overlay onSurface @ 0.5.
 * ========================================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-7);
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-10);
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - var(--space-10));
  overflow-y: auto;
  box-shadow: var(--shadow-card);
  transform: translateY(18px);
  opacity: 0;
  transition: transform var(--duration-entry) var(--ease-out-cubic),
              opacity   var(--duration-entry) var(--ease-out-cubic);
}

.modal-overlay.open .modal {
  transform: translateY(0);
  opacity: 1;
}

.modal.xwide { max-width: 880px; }
.modal.xxwide { max-width: 1060px; }

.modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--on-surface);
  margin-bottom: var(--space-5);
}
.modal-body { font-size: 14px; line-height: 1.5; color: var(--on-surface-variant); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-5);
  margin-top: var(--space-9);
}

/* ============================================================================
 *  FILTER CHIP — design-system §7.8 (AppFilterChip)
 *  Spec: doble línea (label ALL-CAPS + valor), radius 14, sombra soft.
 * ========================================================================= */

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid rgba(229, 231, 235, 0.7);
  box-shadow: var(--shadow-soft);
  font-family: var(--font-base);
  color: var(--on-surface);
  cursor: pointer;
  transition: background-color var(--duration-press) var(--ease-out),
              color var(--duration-press) var(--ease-out),
              border-color var(--duration-press) var(--ease-out);
}

.filter-chip[data-active="true"] {
  background: var(--seed);
  border-color: var(--seed);
  color: #FFFFFF;
}

.filter-chip .ms { font-size: 16px; color: var(--seed); }
.filter-chip[data-active="true"] .ms { color: #FFFFFF; }

.filter-chip .text { display: flex; flex-direction: column; line-height: 1.2; }

.filter-chip .label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(100, 116, 139, 0.85);
}
.filter-chip[data-active="true"] .label { color: rgba(255, 255, 255, 0.85); }

.filter-chip .value {
  font-size: 12.5px;
  font-weight: 700;
}

/* ============================================================================
 *  EMPTY STATE — design-system §7.3
 *  Spec: icono 64 radius 20 fondo accent@0.10, título 15.5 w700, subt 13 h1.45.
 * ========================================================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-11);
  text-align: center;
}

.empty-state .icon-circle {
  width: var(--empty-icon);
  height: var(--empty-icon);
  border-radius: var(--radius-2xl);
  background: rgba(37, 99, 235, 0.10);
  color: var(--seed);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-7);
}
.empty-state .icon-circle .ms { font-size: 32px; }

.empty-state .title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--on-surface);
  margin-bottom: 6px;
}
.empty-state .subtitle {
  font-size: 13px;
  line-height: 1.45;
  color: var(--on-surface-variant);
  max-width: 360px;
}
.empty-state .btn-text { margin-top: var(--space-7); }

/* ============================================================================
 *  STAT PILL — design-system §8.7
 *  Spec: card surface radius 14 soft + icono 34 seed@0.10 radius 10
 *        + label 11 w500 + value 16.5 w700 ls -0.3.
 * ========================================================================= */

.stat-pill {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.stat-pill .icon {
  width: var(--stat-pill-icon);
  height: var(--stat-pill-icon);
  border-radius: var(--radius-sm);
  background: rgba(37, 99, 235, 0.10);
  color: var(--seed);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-pill .icon .ms { font-size: 20px; }

.stat-pill .text { display: flex; flex-direction: column; line-height: 1.2; }
.stat-pill .label {
  font-size: 11px;
  font-weight: 500;
  color: var(--on-surface-variant);
}
.stat-pill .value {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--on-surface);
}

/* ============================================================================
 *  SNACKBAR — design-system §7.10
 *  Spec: floating, bg onSurface, fg surface, radius 12, elevation 4.
 * ========================================================================= */

.snackbar {
  position: fixed;
  bottom: var(--space-10);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 12px 16px;
  background: var(--on-surface);
  color: var(--surface);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out),
              transform 220ms var(--ease-out);
  z-index: var(--z-snackbar);
}
.snackbar.open    { opacity: 1; transform: translateX(-50%) translateY(0); }
.snackbar-success { background: var(--success); color: #FFFFFF; }
.snackbar-error   { background: var(--danger);  color: #FFFFFF; }
.snackbar-warning { background: var(--warning); color: #FFFFFF; }

/* ============================================================================
 *  TABLA (listados) — header con caption ALL-CAPS, filas con divider sutil
 * ========================================================================= */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.table thead th {
  text-align: left;
  padding: var(--space-5) var(--space-7);
  background: var(--surface-dim);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  border-bottom: 1px solid var(--outline-variant);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--space-6) var(--space-7);
  font-size: 14px;
  color: var(--on-surface);
  border-bottom: 1px solid var(--outline-variant);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }

.table tbody tr:hover { background: var(--surface-container-low); }

/* ── Listados como tarjetas apiladas en móvil ─────────────────────────────
 * Las tablas de las vistas que usa el técnico en el teléfono (SATs y Visitas)
 * se reorganizan en tarjetas: cada fila es una card y cada celda una línea
 * "ETIQUETA … valor". Requiere data-label en cada <td>. Las tablas admin
 * (clientes/usuarios) se mantienen como tabla. */
@media (max-width: 640px) {
  .sats-table,
  .visitas-table {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }
  .sats-table thead,
  .visitas-table thead { display: none; }

  .sats-table tbody,
  .visitas-table tbody {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
  }

  .sats-table tbody tr,
  .visitas-table tbody tr {
    display: block;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: var(--space-6) var(--space-7);
  }
  .sats-table tbody tr:active,
  .visitas-table tbody tr:active { transform: scale(0.99); }

  .sats-table tbody td,
  .visitas-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-7);
    padding: 5px 0;
    border: 0;
    text-align: right;
  }
  .sats-table tbody td:first-child,
  .visitas-table tbody td:first-child { padding-top: 0; }
  .sats-table tbody td:last-child,
  .visitas-table tbody td:last-child { padding-bottom: 0; }

  .sats-table tbody td::before,
  .visitas-table tbody td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--on-surface-variant);
    text-align: left;
  }

  /* Anula los anchos "1%" y el nowrap que sólo tienen sentido en modo tabla */
  .sats-table .col-num,
  .sats-table .col-estado,
  .sats-table .col-fecha,
  .visitas-table .col-fecha,
  .visitas-table .col-sat,
  .visitas-table .col-estado-v {
    width: auto;
    white-space: normal;
  }
}

/* ============================================================================
 *  LOADING SPINNER — design-system §7.2
 *  Spec: 34 px stroke 2.6 color seed. Opcional mensaje 13 w500 abajo.
 * ========================================================================= */

.spinner {
  width: 34px;
  height: 34px;
  border: 2.6px solid rgba(37, 99, 235, 0.18);
  border-top-color: var(--seed);
  border-radius: 50%;
  animation: app-spin 800ms linear infinite;
}

@keyframes app-spin { to { transform: rotate(360deg); } }

.loading-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: var(--space-11);
}
.loading-block .message {
  font-size: 13px;
  font-weight: 500;
  color: var(--on-surface-variant);
}

/* ============================================================================
 *  CONTENEDORES DE PÁGINA
 *  Padding canónico 16, ancho máximo cómodo para escritorio.
 * ========================================================================= */

.page {
  padding: var(--space-7);
  max-width: 1280px;
  margin: 0 auto;
}

.page-narrow { max-width: 720px; }

.stack    > * + * { margin-top: var(--space-5); }
.stack-lg > * + * { margin-top: var(--space-9); }

.row {
  display: flex;
  gap: var(--space-5);
  align-items: center;
  flex-wrap: wrap;
}

.row-end { justify-content: flex-end; }
.row-between { justify-content: space-between; }

/* ============================================================================
 *  AJUSTES MÓVIL (transversales)
 * ========================================================================= */

/* iOS Safari hace zoom automático al enfocar un campo con font-size < 16px.
 * En móvil subimos los campos a 16px para evitar ese salto molesto. */
@media (max-width: 640px) {
  .input,
  .textarea,
  .select { font-size: 16px; }
}

/* Modales casi a pantalla completa en teléfonos pequeños: menos padding
 * exterior e interior para aprovechar el ancho. */
@media (max-width: 480px) {
  .modal-overlay { padding: var(--space-5); }
  .modal { padding: var(--space-7); }
  .modal-actions { gap: var(--space-3); }
}
