﻿/* =========================
   admin.css — UI de administración (scope .tmx)
   ========================= */

/* -------- Accesibles por defecto -------- */
.tmx *:focus-visible {
  outline: 2px solid color-mix(in hsl, var(--tmx-brand, #2563eb) 72%, white 0%);
  outline-offset: 2px;
}

/* -------- Botón "Administrar" (header) -------- */
.tmx .tmx-header {
  position: relative;
  padding-right: 140px;
}
.tmx .tmx-admin-slot {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tmx .tmx-admin-btn {
  font-size: var(--tmx-small);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--tmx-accent, #639862);
  color: #fff;
  border: 1px solid color-mix(in hsl, var(--tmx-accent, #639862) 60%, white 40%);
  box-shadow: var(--tmx-shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.tmx .tmx-admin-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
  filter: saturate(1.02);
}
@media (max-width: 520px) {
  .tmx .tmx-header {
    padding-right: 0;
  }
  .tmx .tmx-admin-slot {
    position: static;
    justify-content: center;
    margin-top: 8px;
  }
}

/* -------- Modal base -------- */
.tmx .tmx-admin-modal[hidden] {
  display: none !important;
}
.tmx .tmx-admin-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
}
.tmx .tmx-admin-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(2px);
}
.tmx .tmx-admin-modal__box {
  position: absolute;
  left: 50%;
  top: 10%;
  transform: translateX(-50%);
  width: min(960px, 94vw);
  max-height: 78vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #fff;
  border: 1px solid var(--tmx-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  animation: tmx-pop 0.18s ease-out;
}
@keyframes tmx-pop {
  from {
    transform: translateX(-50%) translateY(-4px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}

.tmx .tmx-admin-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tmx-border);
  background: var(--tmx-panel);
}
.tmx .tmx-admin-modal__header h3 {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
  color: var(--tmx-ink);
}
.tmx .tmx-admin-close {
  appearance: none;
  background: #fff;
  border: 1px solid var(--tmx-border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.tmx .tmx-admin-close:hover {
  transform: translateY(-1px);
  background: #fafafa;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.tmx .tmx-admin-modal__body {
  padding: 10px 12px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

/* -------- Toolbar -------- */
.tmx .tmx-admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tmx .tmx-admin-size {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--tmx-ink-muted);
}
.tmx .tmx-admin-select {
  padding: 6px 8px;
  border: 1px solid var(--tmx-border);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.tmx .tmx-admin-select:hover {
  background: #fafafa;
}
.tmx .tmx-admin-select:focus-visible {
  outline: 2px solid color-mix(in hsl, var(--tmx-brand, #2563eb) 72%, white 0%);
  outline-offset: 2px;
}
.tmx .tmx-admin-pager {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tmx .tmx-admin-iconbtn {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--tmx-border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease,
    filter 0.2s ease;
}
.tmx .tmx-admin-iconbtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  background: #fafafa;
  filter: saturate(1.02);
}
.tmx .tmx-admin-iconbtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.tmx .tmx-admin-range {
  font-size: 12px;
  color: var(--tmx-ink-muted);
  padding: 0 6px;
}

/* -------- Grid tabla -------- */
.tmx .tmx-admin-grid-wrap {
  overflow: auto;
  max-height: calc(78vh - 110px);
  border: 1px solid var(--tmx-border);
  border-radius: 10px;
  background: #fff;
}
.tmx .tmx-admin-grid {
  --cols-template: 3fr 1fr 1fr 0.7fr;
  min-width: 760px;
  display: grid;
  grid-template-rows: auto 1fr;
}
.tmx .tmx-admin-grid__head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  border-bottom: 1px solid var(--tmx-border);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.03);
}
.tmx .tmx-admin-grid__row {
  display: grid;
  grid-template-columns: var(--cols-template);
}
.tmx .tmx-admin-grid__row--head .tmx-admin-grid__cell {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.2px;
  color: #0f172a;
}
.tmx .tmx-admin-grid__cell {
  padding: 8px 10px;
  border-bottom: 1px solid var(--tmx-border);
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tmx .tmx-admin-grid__cell--head {
  background: #f8fafc;
}
.tmx .tmx-admin-grid__cell:not(:last-child) {
  border-right: 1px solid #f1f5f9;
}

/* Zebra + hover */
.tmx .tmx-admin-grid__body .tmx-admin-grid__row:nth-child(even) {
  background: #fbfdff;
}
.tmx .tmx-admin-grid__body .tmx-admin-grid__row:hover {
  background: color-mix(in hsl, var(--tmx-brand, #2563eb) 6%, white 94%);
}

/* Alineación centrada para Tipo, Activo y Acción (2,3,4) */
.tmx .tmx-admin-grid__row > .tmx-admin-grid__cell:nth-child(2),
.tmx .tmx-admin-grid__row > .tmx-admin-grid__cell:nth-child(3),
.tmx .tmx-admin-grid__row > .tmx-admin-grid__cell:nth-child(4) {
  text-align: center;
}

/* Botón “Ver más” */
.tmx .tmx-admin-more {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  background: var(--tmx-brand);
  color: var(--tmx-brand-ink);
  box-shadow: var(--tmx-shadow);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.tmx .tmx-admin-more:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.1);
  filter: saturate(1.04);
}

/* -------- Badges -------- */
.tmx .tmx-badge-pill {
  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: 700;
  background: #fff;
  white-space: nowrap;
}
.tmx .tmx-badge-pill--type {
  border-color: color-mix(in hsl, var(--tmx-brand, #2563eb) 50%, white 50%);
  background: color-mix(in hsl, var(--tmx-brand, #2563eb) 8%, white 92%);
  color: color-mix(in hsl, var(--tmx-brand, #2563eb) 90%, black 10%);
}
.tmx .tmx-badge-pill--ok {
  border-color: #b7e4c7;
  background: #eefbf3;
  color: #13763c;
}
.tmx .tmx-badge-pill--bad {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}
.tmx .tmx-badge-pill--cost {
  border-color: #f3d3a1;
  background: #fff6e9;
  color: #a26500;
}
.tmx .tmx-badge-pill--free {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #334155;
}

.tmx .tmx-badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px dashed var(--tmx-border);
  font-size: 12px;
  background: #fafafa;
  color: var(--tmx-ink);
}

/* -------- Panel lateral (sheet) -------- */
.tmx .tmx-admin-sheet {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10001;
}
.tmx .tmx-admin-sheet__box {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(
    720px,
    96vw
  ); /* ancho base; en edición lo sobreescribe admin-edit.css */
  background: #fff;
  border-left: 1px solid var(--tmx-border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
  transform: translateX(100%);
  transition: transform 0.28s ease;
  display: grid;
  grid-template-rows: auto 1fr;
  pointer-events: auto;
}
.tmx .tmx-admin-sheet.is-open .tmx-admin-sheet__box {
  transform: translateX(0);
}
.tmx .tmx-admin-sheet[aria-hidden="true"] {
  visibility: hidden;
}
.tmx .tmx-admin-sheet[aria-hidden="false"] {
  visibility: visible;
}

.tmx .tmx-admin-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--tmx-border);
  background: var(--tmx-panel);
}
.tmx .tmx-admin-sheet__body {
  padding: 14px;
  overflow: auto;
}

/* Encabezado y chips (detalle) */
.tmx .tmx-sheet-head {
  display: grid;
  gap: 6px;
  margin: 0 0 8px;
}
.tmx .tmx-sheet-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--tmx-ink);
  margin: 0;
}
.tmx .tmx-sheet-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Grilla fluida (detalle) */
.tmx .tmx-sheet-grid--fluid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}
.tmx .tmx-sheet-grid--stack {
  display: grid;
  grid-template-columns: 1fr; /* una columna a todo el ancho */
  gap: 12px;
}

/* Tarjetas (detalle) */
.tmx .tmx-sheet-card {
  background: #fff;
  border: 1px solid var(--tmx-border);
  border-radius: 12px;
  box-shadow: var(--tmx-shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tmx .tmx-card-title {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--tmx-ink);
  letter-spacing: 0.2px;
}
.tmx .tmx-card--full {
  grid-column: 1 / -1;
}

/* Definiciones (Resumen) */
.tmx .tmx-dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.tmx .tmx-dl__row {
  display: grid;
  grid-template-columns: 160px 1fr; /* un poco más ancho para evitar saltos */
  gap: 8px;
  align-items: start;
}
.tmx .tmx-dl dt {
  margin: 0;
  font-weight: 700;
  color: var(--tmx-ink);
  font-size: 12px;
}
.tmx .tmx-dl dd {
  margin: 0;
  color: var(--tmx-ink);
  font-size: 13px;
  line-height: 1.35;
}

/* Lista de enlaces (detalle) */
.tmx .tmx-link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.tmx .tmx-link-list li {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px;
  align-items: start;
}
.tmx .tmx-link-list li > span {
  font-weight: 700;
  font-size: 12px;
  color: var(--tmx-ink);
}
.tmx .tmx-link-wrap a {
  display: inline-block;
  word-break: break-word;
  overflow-wrap: anywhere;
  text-decoration: underline;
}

/* Descripción (detalle) */
.tmx .tmx-sheet-desc {
  font-size: 13px;
  color: var(--tmx-ink-muted);
  margin: 0;
}
.tmx .tmx-more-compact {
  padding: 4px 8px;
  font-size: 12px;
}

/* -------- Scrollbars (WebKit) -------- */
.tmx .tmx-admin-grid-wrap::-webkit-scrollbar,
.tmx .tmx-admin-sheet__body::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}
.tmx .tmx-admin-grid-wrap::-webkit-scrollbar-thumb,
.tmx .tmx-admin-sheet__body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
}
.tmx .tmx-admin-grid-wrap::-webkit-scrollbar-thumb:hover,
.tmx .tmx-admin-sheet__body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* -------- Reduced motion -------- */
@media (prefers-reduced-motion: reduce) {
  .tmx .tmx-admin-btn,
  .tmx .tmx-admin-iconbtn,
  .tmx .tmx-admin-more,
  .tmx .tmx-admin-close,
  .tmx .tmx-admin-modal__box,
  .tmx .tmx-admin-sheet__box {
    transition: none !important;
    animation: none !important;
  }
}

/* =========================================
   Admin · Buscador en toolbar (scope .tmx)
   ========================================= */

.tmx .tmx-admin-toolbar {
  gap: 12px;
  flex-wrap: wrap; /* en pantallas pequeñas baja a segunda línea */
}

/* Contenedor del buscador */
.tmx .tmx-admin-search {
  position: relative;
  display: flex;
  align-items: center;
  width: clamp(220px, 40vw, 420px);
  max-width: 100%;
}

/* Input de búsqueda */
.tmx .tmx-admin-search__input {
  appearance: none;
  width: 100%;
  padding: 8px 34px 8px 12px; /* espacio para el botón de limpiar */
  font-size: 13px;
  line-height: 1.35;
  border: 1px solid var(--tmx-border);
  border-radius: 10px;
  background: var(--tmx-surface);
  color: var(--tmx-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.tmx .tmx-admin-search__input::placeholder {
  color: var(--tmx-ink-muted);
  opacity: 0.9;
}

.tmx .tmx-admin-search__input:hover {
  background: color-mix(in hsl, var(--tmx-surface) 94%, black 6%);
}

.tmx .tmx-admin-search__input:focus-visible {
  outline: 2px solid color-mix(in hsl, var(--tmx-brand) 72%, white 0%);
  outline-offset: 2px;
  border-color: color-mix(in hsl, var(--tmx-brand) 40%, var(--tmx-border) 60%);
  box-shadow: 0 0 0 3px color-mix(in hsl, var(--tmx-brand) 18%, transparent);
}

/* Botón limpiar (✕) */
.tmx .tmx-admin-search__clear {
  position: absolute;
  right: 6px;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--tmx-ink-muted);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease,
    opacity 0.2s ease;
}

.tmx .tmx-admin-search__clear:hover {
  background: color-mix(in hsl, var(--tmx-panel) 80%, var(--tmx-surface) 20%);
  color: var(--tmx-ink);
  transform: translateY(-1px);
}

/* Ocultar el botón cuando no hay texto (solo con CSS, sin JS) */
.tmx .tmx-admin-search__input:placeholder-shown + .tmx-admin-search__clear {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
}

/* Responsive: en pantallas muy estrechas, ocupa todo el ancho de la fila */
@media (max-width: 560px) {
  .tmx .tmx-admin-search {
    width: 100%;
    order: 2; /* manda el buscador debajo del selector de página si hace falta */
  }
}

/* =========================
   Estados vacíos / textos
   ========================= */

/* Utilidad para textos apagados (reusa en “No hay trámites…”) */
.tmx .tmx-muted {
  color: var(--tmx-ink-muted);
}

/* Si prefieres no usar inline styles en la celda vacía,
   puedes asignar esta clase desde JS (opcional): */
.tmx .tmx-admin-grid__empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 16px 8px;
  color: var(--tmx-ink-muted);
}

/* =========================
   Accesibilidad y motion
   ========================= */
@media (prefers-reduced-motion: reduce) {
  .tmx .tmx-admin-search__clear,
  .tmx .tmx-admin-search__input {
    transition: none !important;
  }
}
