﻿/* =========================
   base.css — Tokens + Layout base
   Scope: .tmx
   ========================= */

/* Reset local + esquema claro forzado */
.tmx,
.tmx * {
  box-sizing: border-box;
  color-scheme: light; /* siempre claro dentro del módulo */
}

/* -------------------------
   Tokens (design system)
   ------------------------- */
.tmx {
  --tmx-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "Liberation Sans", sans-serif;

  /* Paleta */
  --tmx-brand: #e77918; /* color institucional principal */
  --tmx-brand-ink: #ffffff;
  --tmx-accent: #639862; /* color institucional secundario (opcional) */

  --tmx-ink: #0f172a;
  --tmx-ink-muted: #475569;
  --tmx-border: #e2e8f0;
  --tmx-surface: #ffffff;
  --tmx-panel: #f8fafc;

  /* Accents */
  --tmx-ok: #15803d;
  --tmx-bad: #dc2626;

  /* ⬇️ Corregido: antes era #eef2ff (lila). Ahora mezcla suave con la marca. */
  --tmx-chip-bg: color-mix(in hsl, var(--tmx-brand) 12%, white 88%);

  /* Dimensiones */
  --tmx-radius: 12px;
  --tmx-chip-radius: 999px;
  --tmx-shadow: 0 8px 20px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.06);
  --tmx-gap: 16px;

  /* Tipografía */
  --tmx-h2: clamp(20px, 2vw, 26px);
  --tmx-h3: clamp(16px, 1.6vw, 18px);
  --tmx-text: 14px;
  --tmx-small: 12px;

  /* Base */
  background: var(--tmx-surface);
  font-family: var(--tmx-font);
  color: var(--tmx-ink);
}

/* -------------------------
   Encabezado (centrado)
   ------------------------- */
.tmx .tmx-header {
  display: grid;
  justify-items: center; /* centra h2 y p */
  text-align: center; /* centra el texto */
  gap: 6px;
  margin-bottom: 18px;
}
.tmx .tmx-header h2 {
  font-size: var(--tmx-h2);
  line-height: 1.2;
  margin: 0;
  font-weight: 800;
  color: var(--tmx-brand); /* toque de marca (opcional) */
}
.tmx #tmx-counter {
  font-size: var(--tmx-small);
  color: var(--tmx-ink-muted);
  margin: 0;
}

/* -------------------------
   Layout principal
   ------------------------- */
.tmx .tmx-layout {
  display: grid;
  grid-template-columns: 280px 1fr; /* filtros | resultados */
  gap: calc(var(--tmx-gap) * 1.25);
}
@media (max-width: 980px) {
  .tmx .tmx-layout {
    grid-template-columns: 1fr; /* apilar en móviles */
  }
}

/* Contenedores básicos con aria-label (secciones del módulo) */
.tmx section[aria-label] {
  background: transparent;
}

/* Panel lateral de filtros */
.tmx #filters {
  background: var(--tmx-panel);
  border: 1px solid var(--tmx-border);
  border-radius: var(--tmx-radius);
  padding: calc(var(--tmx-gap) * 1.25);
}

/* Contenedor de resultados (search + list + pager) */
.tmx [aria-label="Resultados de trámites"] {
  display: grid;
  gap: var(--tmx-gap);
}

/* Superficies internas comunes (tarjeticas) */
.tmx [aria-label="Resultados de trámites"] > section,
.tmx .tmx-surface {
  background: #ffffff;
  border: 1px solid var(--tmx-border);
  border-radius: var(--tmx-radius);
}

/* -------------------------
   Accesibilidad / Enlaces
   ------------------------- */
.tmx a:focus-visible,
.tmx button:focus-visible,
.tmx input:focus-visible,
.tmx select:focus-visible,
.tmx textarea:focus-visible {
  outline: 2px solid color-mix(in hsl, var(--tmx-brand) 72%, white 0%);
  outline-offset: 2px;
  border-radius: 8px;
}

.tmx a {
  color: var(--tmx-brand);
  text-decoration: none;
}
.tmx a:hover {
  text-decoration: underline;
}

/* -------------------------
   Utilidades rápidas
   ------------------------- */
.tmx .mt-0 {
  margin-top: 0;
}
.tmx .mb-0 {
  margin-bottom: 0;
}

/* Visually hidden (para etiquetas accesibles) */
.tmx .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Contador animado === */
.tmx #tmx-count {
  font-variant-numeric: tabular-nums; /* evita “bailes” de ancho */
  font-weight: 800;
  display: inline-block; /* necesario para la animación */
  padding: 0 0.2ch;
}
.tmx .tmx-count-bump {
  animation: tmx-count-pop 160ms ease-out;
}
@keyframes tmx-count-pop {
  0% {
    transform: translateY(0.25em);
    opacity: 0.85;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* =========================
   Botón primario en cards
   ========================= */
.tmx .tmx-start-btn {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
  background: var(--tmx-brand);
  color: var(--tmx-brand-ink);
  text-decoration: none;
  border: 1px solid color-mix(in hsl, var(--tmx-brand) 60%, white 40%);
  box-shadow: var(--tmx-shadow);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.tmx .tmx-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08), 0 3px 8px rgba(0, 0, 0, 0.08);
}
.tmx .tmx-start-btn:focus-visible {
  outline: 2px solid color-mix(in hsl, var(--tmx-brand) 72%, white 0%);
  outline-offset: 2px;
}

/* === Footer de acciones: alinear SUIT + Empezar trámite a la derecha === */
.tmx .tmx-card__actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

/* Quitar el absolute del CTA cuando esté dentro del footer */
.tmx .tmx-card__actions .tmx-start-btn {
  position: static;
  left: auto;
  bottom: auto;
}

/* Botón SUIT (secundario) */
.tmx .tmx-suit-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  background: #fff;
  color: var(--tmx-ink);
  text-decoration: none;
  border: 1px solid var(--tmx-border);
  box-shadow: var(--tmx-shadow);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.tmx .tmx-suit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08), 0 3px 8px rgba(0, 0, 0, 0.08);
}

/* Evita saltos de línea dentro de los botones del footer */
.tmx .tmx-card__actions .tmx-start-btn,
.tmx .tmx-card__actions .tmx-suit-btn {
  white-space: nowrap;
}

/* --- CTA "Empezar trámite" — versión mejorada (sin icono) --- */
.tmx .tmx-start-btn {
  position: relative; /* efectos internos */
  overflow: hidden; /* recortar brillos/ripple */
  isolation: isolate; /* evita que el brillo afecte afuera */

  /* paleta derivada de tu marca */
  --btn-base: var(--tmx-brand);
  --btn-hi: color-mix(in hsl, var(--tmx-brand) 78%, white 22%);
  --btn-lo: color-mix(in hsl, var(--tmx-brand) 78%, black 22%);

  /* fondo con luz superior suave + profundidad inferior */
  background: radial-gradient(
      120% 60% at 30% 0%,
      rgba(255, 255, 255, 0.35) 0%,
      transparent 60%
    ),
    linear-gradient(
      180deg,
      var(--btn-hi) 0%,
      var(--btn-base) 58%,
      var(--btn-lo) 100%
    );
  border: 0;
  color: var(--tmx-brand-ink);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.35) inset;
  letter-spacing: 0.2px;

  transform: translateZ(0); /* GPU kick */
  transition: transform 0.18s ease, box-shadow 0.22s ease, filter 0.22s ease,
    background-position 0.6s ease;
}

/* quita cualquier pseudo-previo heredado (como el ▶) */
.tmx .tmx-start-btn::before {
  content: none;
}

/* GLINT de brillo que cruza diagonalmente */
.tmx .tmx-start-btn::after {
  content: "";
  position: absolute;
  inset: -20%;
  border-radius: 999px;
  background: linear-gradient(
    120deg,
    transparent 45%,
    rgba(255, 255, 255, 0.36) 50%,
    transparent 55%
  );
  transform: translateX(-120%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

/* Hover: eleva, satura un pelín y pasa el glint */
.tmx .tmx-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.4) inset;
  filter: saturate(1.04);
}
.tmx .tmx-start-btn:hover::after {
  animation: tmx-cta-glint 900ms ease forwards;
}

/* Active: micro-compresión + ripple */
.tmx .tmx-start-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.1) inset;
}
.tmx .tmx-start-btn:active::before {
  content: "";
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%) scale(1);
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  filter: blur(1px);
  animation: tmx-cta-ripple 520ms ease;
  pointer-events: none;
  z-index: -1;
}

/* Focus accesible */
.tmx .tmx-start-btn:focus-visible {
  outline: 3px solid color-mix(in hsl, var(--tmx-brand) 65%, white 0%);
  outline-offset: 3px;
}

/* Estado deshabilitado */
.tmx .tmx-start-btn[disabled],
.tmx .tmx-start-btn.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.1);
}

/* Estado cargando: spinner minimal sin icono */
.tmx .tmx-start-btn.is-loading {
  pointer-events: none;
}
.tmx .tmx-start-btn.is-loading::after {
  animation: none;
} /* sin glint */
.tmx .tmx-start-btn.is-loading > span {
  visibility: hidden; /* reserva ancho del texto */
}
.tmx .tmx-start-btn.is-loading::before {
  content: "";
  position: absolute;
  width: 1.05em;
  height: 1.05em;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: rgba(255, 255, 255, 1);
  border-radius: 50%;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  animation: tmx-cta-spin 0.8s linear infinite;
}

/* Motion-safe */
@media (prefers-reduced-motion: reduce) {
  .tmx .tmx-start-btn,
  .tmx .tmx-start-btn:hover {
    transition: none;
  }
  .tmx .tmx-start-btn::after,
  .tmx .tmx-start-btn:active::before {
    animation: none !important;
  }
}

/* --- Animaciones --- */
@keyframes tmx-cta-glint {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(120%);
  }
}
@keyframes tmx-cta-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}
@keyframes tmx-cta-ripple {
  0% {
    opacity: 0.35;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(16);
  }
}
