﻿/* =========================
   componentes.css — UI del módulo
   Scope: .tmx
   ========================= */

/* Forzar esquema CLARO dentro del componente */
.tmx,
.tmx * {
  color-scheme: light !important;
}

/* ========== Search ========== */
.tmx .tmx-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.tmx .tmx-input {
  width: 100%;
  font-size: var(--tmx-text);
  padding: 10px 12px;
  border: 1px solid var(--tmx-border);
  border-radius: 10px;
  background: var(--tmx-surface);
  color: var(--tmx-ink);
}

/* Botón borrar dentro del input */
.tmx .tmx-input-wrap {
  position: relative;
}
.tmx .tmx-q-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  padding: 0 6px;
  color: var(--tmx-ink-muted);
  cursor: pointer;
  display: none;
}
.tmx .tmx-input-wrap.has-value .tmx-q-clear {
  display: inline-flex;
}

.tmx .tmx-btn {
  font-size: var(--tmx-text);
  font-weight: 700;
  padding: 10px 14px;
  border: 1px solid color-mix(in hsl, var(--tmx-brand) 60%, black 10%);
  border-radius: 10px;
  color: var(--tmx-brand-ink);
  background: var(--tmx-brand);
  box-shadow: var(--tmx-shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.tmx .tmx-btn:hover {
  transform: translateY(-1px);
}
.tmx .tmx-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== Filtros ========== */
.tmx .tmx-filters {
  display: grid;
  gap: 14px;
  background: var(--tmx-panel);
  border: 1px solid var(--tmx-border);
  border-radius: var(--tmx-radius);
  padding: 14px;
}
.tmx .tmx-filters__row {
  display: grid;
  gap: 8px;
}
.tmx .tmx-filters__row > strong {
  font-size: var(--tmx-small);
  color: var(--tmx-ink-muted);
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* Fallback para <select> nativo (si Slim Select no carga) */
.tmx .tmx-select {
  width: 100%;
  appearance: none;
  font-size: var(--tmx-text);
  padding: 10px 12px;
  border: 1px solid var(--tmx-border);
  border-radius: 10px;
  background: var(--tmx-surface);
  color: var(--tmx-ink);
}

/* Botón limpiar filtros (abajo) */
.tmx #btn-clear-filters {
  display: inline-block;
  margin-top: 2px;
  font-weight: 600;
  text-decoration: none;
  border: 1px dashed var(--tmx-border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--tmx-panel);
  color: var(--tmx-brand);
  cursor: pointer;
}
.tmx #btn-clear-filters:hover {
  background: color-mix(in hsl, var(--tmx-brand) 6%, white 94%);
}
.tmx #btn-clear-filters.is-active {
  background: var(--tmx-brand);
  color: var(--tmx-brand-ink);
  border-color: color-mix(in hsl, var(--tmx-brand) 60%, white 40%);
}

/* ========== Chips (si los usas en otro lado) ========== */
.tmx .tmx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tmx .tmx-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: var(--tmx-small);
  line-height: 1;
  border-radius: var(--tmx-chip-radius);
  border: 1px solid color-mix(in hsl, var(--tmx-brand) 38%, white 62%);
  background: var(--tmx-chip-bg);
  color: color-mix(in hsl, var(--tmx-brand) 90%, black 10%);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.2s ease,
    box-shadow 0.2s ease;
}
.tmx .tmx-chip:hover {
  transform: translateY(-1px);
}
.tmx .tmx-chip[aria-pressed="true"],
.tmx .tmx-chip.is-active {
  background: color-mix(in hsl, var(--tmx-brand) 8%, white 92%);
  border-color: color-mix(in hsl, var(--tmx-brand) 60%, white 40%);
}

/* Link utilitario */
.tmx .tmx-link {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--tmx-brand);
  font-size: var(--tmx-small);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* ========== Contenedor de resultados ========== */
.tmx #list {
  display: grid;
  gap: 14px;
}

/* ========== Cards (listado) ========== */
.tmx .tmx-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--tmx-border);
  border-radius: var(--tmx-radius);
  box-shadow: var(--tmx-shadow);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  /* ⬇️ ya no necesitamos reservar espacio extra para un botón absoluto */
  /* padding-bottom: 56px;  */
  --dep-badge-w: clamp(120px, 32vw, 240px);
}
.tmx .tmx-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08), 0 3px 8px rgba(0, 0, 0, 0.08);
  border-color: var(--tmx-brand);
}

.tmx .tmx-card__title {
  margin: 0;
  font-size: var(--tmx-h3);
  font-weight: 800;
  line-height: 1.25;
  color: var(--tmx-ink);
  padding-right: var(--dep-badge-w);
  word-break: break-word;
  hyphens: auto;
}
.tmx .tmx-card__title a {
  text-decoration: none;
  color: inherit;
}
.tmx .tmx-card__title a:hover {
  text-decoration: underline;
}

.tmx .tmx-card__desc {
  margin: 0;
  font-size: var(--tmx-text);
  color: var(--tmx-ink-muted);
}

/* Meta (si lo usas) */
.tmx .tmx-card__meta {
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: var(--tmx-small);
  color: var(--tmx-ink-muted);
}
.tmx .tmx-card__meta > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px dashed var(--tmx-border);
  border-radius: 999px;
  background: #fafafa;
}

/* ===== Etiqueta de Dependencia (en la esquina) ===== */
.tmx .tmx-tag-dep {
  position: absolute;
  top: -1px;
  right: -1px;
  max-width: var(--dep-badge-w);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  background: var(--tmx-brand);
  color: var(--tmx-brand-ink);
  border: 1px solid var(--tmx-brand);
  border-top-right-radius: var(--tmx-radius);
  border-bottom-left-radius: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--tmx-shadow);
  z-index: 2;
}

/* ===== Badges de flags dentro del card ===== */
.tmx .tmx-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tmx .tmx-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--tmx-border);
  font-size: 12px;
  font-weight: 600;
  background: #fafafa;
  color: var(--tmx-ink);
}
.tmx .tmx-badge i {
  font-size: 14px;
  line-height: 1;
}

/* Variantes */
.tmx .tmx-badge--online {
  background: color-mix(in hsl, var(--tmx-brand) 8%, white 92%);
  border-color: var(--tmx-brand);
  color: color-mix(in hsl, var(--tmx-brand) 90%, black 10%);
}
.tmx .tmx-badge--presencial {
  background: #eefbf3;
  border-color: #b7e4c7;
  color: #13763c;
}
.tmx .tmx-badge--cost {
  background: #fff6e9;
  border-color: #f3d3a1;
  color: #a26500;
}
.tmx .tmx-badge--free {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #334155;
}

/* ===== Footer de acciones en la card (SUIT + Empezar) ===== */
.tmx .tmx-card__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

/* --- Botón SUIT (secundario y elegante) --- */
.tmx .tmx-suit-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate; /* efectos internos seguros */

  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;

  /* estilo ghost/outline sobre superficie clara */
  background: radial-gradient(
      120% 60% at 30% 0%,
      rgba(255, 255, 255, 0.7) 0%,
      transparent 65%
    ),
    linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  color: var(--tmx-brand);
  border: 1px solid var(--tmx-brand);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);

  transition: transform 0.18s ease, box-shadow 0.22s ease, background 0.22s ease,
    filter 0.22s ease;
}

/* glint suave diagonal */
.tmx .tmx-suit-btn::before {
  content: "";
  position: absolute;
  inset: -25%;
  border-radius: 999px;
  background: linear-gradient(
    120deg,
    transparent 45%,
    rgba(255, 255, 255, 0.5) 50%,
    transparent 55%
  );
  transform: translateX(-120%);
  pointer-events: none;
  mix-blend-mode: screen;
}

/* hover: eleva un poco y añade glint */
.tmx .tmx-suit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  filter: saturate(1.03);
}
.tmx .tmx-suit-btn:hover::before {
  animation: tmx-suit-glint 900ms ease forwards;
}

/* active: compresión + ripple suave */
.tmx .tmx-suit-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08),
    inset 0 2px 6px rgba(0, 0, 0, 0.06);
}
.tmx .tmx-suit-btn:active::after {
  content: "";
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%) scale(1);
  background: rgba(15, 23, 42, 0.08); /* usa --tmx-ink atenuado */
  border-radius: 999px;
  filter: blur(0.5px);
  animation: tmx-suit-ripple 520ms ease;
  pointer-events: none;
  z-index: -1;
}

/* focus accesible */
.tmx .tmx-suit-btn:focus-visible {
  outline: 3px solid color-mix(in hsl, var(--tmx-brand) 65%, white 0%);
  outline-offset: 3px;
}

/* disabled */
.tmx .tmx-suit-btn[disabled],
.tmx .tmx-suit-btn.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.08);
}

/* icono dentro del botón */
.tmx .tmx-suit-btn i {
  font-size: 14px;
  line-height: 1;
}

/* motion-safe */
@media (prefers-reduced-motion: reduce) {
  .tmx .tmx-suit-btn,
  .tmx .tmx-suit-btn:hover {
    transition: none;
  }
  .tmx .tmx-suit-btn::before,
  .tmx .tmx-suit-btn:active::after {
    animation: none !important;
  }
}

/* animaciones */
@keyframes tmx-suit-glint {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(120%);
  }
}
@keyframes tmx-suit-ripple {
  0% {
    opacity: 0.25;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(14);
  }
}

/* ===== Responsive etiqueta ===== */
@media (max-width: 640px) {
  .tmx .tmx-card {
    --dep-badge-w: clamp(140px, 56vw, 260px);
  }
}

/* ========== Paginador ========== */
.tmx .tmx-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--tmx-border);
  border-radius: var(--tmx-radius);
}
.tmx .tmx-pager__num {
  font-size: var(--tmx-small);
  color: var(--tmx-ink-muted);
}

/* ========== Estados vacíos / avisos ========== */
.tmx .tmx-empty {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  min-height: 120px;
  border: 1px dashed var(--tmx-border);
  border-radius: var(--tmx-radius);
  color: var(--tmx-ink-muted);
  background: var(--tmx-panel);
}

/* ========== Toast ========== */
.tmx #toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
}
.tmx .tmx-toast {
  background: var(--tmx-brand);
  color: var(--tmx-brand-ink);
  padding: 10px 14px;
  border-radius: 10px;
  margin-top: 8px;
  box-shadow: var(--tmx-shadow);
  animation: tmx-slide-in 0.25s ease;
  font-size: var(--tmx-small);
}
@keyframes tmx-slide-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========== Slim Select (bonito + contadores) ========== */
.tmx .ss-main {
  border: 1px solid var(--tmx-border);
  border-radius: 10px;
  background: var(--tmx-surface);
  min-height: 38px;
  padding: 4px 10px;
  box-shadow: none;
}
.tmx .ss-main:focus-within {
  outline: 2px solid color-mix(in hsl, var(--tmx-brand) 72%, white 0%);
  outline-offset: 2px;
}
.tmx .ss-placeholder {
  color: var(--tmx-ink-muted);
}

.tmx .ss-single .ss-values .ss-value .ss-value-text {
  font-size: var(--tmx-text);
  color: var(--tmx-ink);
}
.tmx .ss-main .ss-arrow {
  width: 10px;
  height: 10px;
  margin-left: 8px;
}
.tmx .ss-main .ss-deselect {
  display: none !important;
}

.tmx .ss-content {
  border: 1px solid var(--tmx-border);
  border-radius: 12px;
  background: var(--tmx-surface);
  box-shadow: var(--tmx-shadow);
  overflow: hidden;
}
.tmx .ss-search {
  padding: 8px;
  border-bottom: 1px solid var(--tmx-border);
}
.tmx .ss-search input {
  width: 100%;
  border: 1px solid var(--tmx-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: var(--tmx-text);
  background: var(--tmx-panel);
  color: var(--tmx-ink);
}
.tmx .ss-option {
  font-size: var(--tmx-text);
  padding: 8px 12px;
  color: var(--tmx-ink);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.tmx .ss-option:hover,
.tmx .ss-option.ss-highlighted {
  background: color-mix(in hsl, var(--tmx-brand) 10%, white 90%);
}
.tmx .ss-option.ss-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Badge de conteo (aplicado vía data-count desde JS) */
.tmx .ss-option::after {
  content: attr(data-count);
  display: inline-block;
  min-width: 18px;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--tmx-border);
  border-radius: 999px;
  background: var(--tmx-chip-bg);
  color: var(--tmx-ink-muted);
  text-align: center;
}
/* Oculta el texto "(n)" si el JS lo envolvió en .tmx-count-text */
.tmx .ss-option[data-count] .tmx-count-text {
  display: none;
}
