/* ─────────────────────────────────────────────────────────────────────────────
   tl-shell.css — shell de módulo (copia del AppShell del Portal de Compras) y
   componentes base compartidos (botones, campos, alertas, insignias, tabla,
   panel, diálogo, toast, esqueleto).
   Requiere /shared/tl-tokens.css antes. Las páginas de módulo cargan después
   /shared/tl-marca.css (radios de 2 px y recetas de la marca).

   Shell (tl-shell.js), recetas de AppShell.tsx:
     ≥ 1024 px  barra lateral midnight fija a la izquierda (256 px, alto
                completo) + cabecera BLANCA sticky con el nombre del apartado,
                campana y usuario; contenido con fondo ice y padding 24 px. El
                documento hace el scroll (la barra no se mueve).
     < 1024 px  la barra lateral se vuelve un cajón (☰ en la cabecera) sobre
                rgba(0,0,0,.5) con una X blanca arriba a la derecha; cabecera
                y contenido con padding 16 px.
     < 640 px   el botón de usuario muestra solo el avatar.
   Radios del shell: 2 px fijos (rasgo de la marca), sin depender de --radio.
   Sin cian, sin degradados, sin glows; sombra solo en el menú de usuario.
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --sb-ancho:    256px;                       /* w-64 */
  --sb-linea:    rgba(255, 255, 255, 0.10);   /* border-white/10 */
  --sb-hover:    rgba(255, 255, 255, 0.05);   /* hover:bg-white/5 */
  --sb-eyebrow:  rgba(174, 174, 184, 0.60);   /* text-silver/60 */
  --cab-alto:    65px;                        /* py-3 + botón de usuario 40 px + borde */
}

/* La cabecera es sticky: scrollIntoView / anclas no quedan tapadas por ella. */
html:has(> body.tl-con-shell) { scroll-padding-top: calc(var(--cab-alto) + 12px); }

/* ── Saltar al contenido (solo visible con el teclado) ─────────────────── */
.tl-saltar {
  position: fixed; left: 12px; top: -60px; z-index: 90;
  padding: 10px 14px; border-radius: 2px;
  background: #fff; color: var(--navy); border: 1px solid var(--navy);
  font-size: 13px; font-weight: 600; text-decoration: none;
  transition: top 0.15s;
}
.tl-saltar:focus { top: 12px; }

/* ── Barra lateral (Sidebar de AppShell.tsx) ───────────────────────────── */
.tl-sb {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
  width: var(--sb-ancho);
  display: flex; flex-direction: column;
  background: var(--midnight);
}

.tl-sb-marca {                                   /* px-5 py-5 border-b border-white/10 */
  flex-shrink: 0;
  padding: 20px;
  border-bottom: 1px solid var(--sb-linea);
}
.tl-sb-logo { display: block; height: 32px; width: auto; }   /* h-8 w-auto: proporción bloqueada */
.tl-sb-wordmark {
  display: block; font-size: 15px; font-weight: 700; line-height: 32px; letter-spacing: 0.06em; color: #fff;
}
.tl-sb-wordmark span { font-weight: 400; }
.tl-sb-mod {                                     /* text-silver/60 text-[10px] mt-2.5 uppercase tracking-wider */
  margin: 10px 0 0;
  font-size: 10px; font-weight: 400; line-height: 15px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--sb-eyebrow);
}

.tl-sb-nav {                                     /* flex-1 px-3 py-4 space-y-0.5 overflow-y-auto */
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 2px;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.tl-sb-sec { display: flex; flex-direction: column; gap: 2px; }
.tl-sb-sec-tit {                                 /* rótulo de sección: 10px uppercase tracking-wider silver/60 */
  margin: 0; padding: 12px 12px 4px;
  font-size: 10px; font-weight: 400; line-height: 15px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--sb-eyebrow);
}
.tl-sb ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.tl-sb-item {                                    /* flex items-center gap-3 px-3 py-2.5 rounded-sm text-sm font-medium */
  display: flex; align-items: center; gap: 12px;
  width: 100%; margin: 0; padding: 10px 12px;
  border: 0; border-radius: 2px; background: transparent;
  font-family: inherit; font-size: 14px; font-weight: 500; line-height: 20px; text-align: left;
  color: var(--silver); text-decoration: none; cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
a.tl-sb-item:hover, button.tl-sb-item:hover:not(:disabled) { background: var(--sb-hover); color: #fff; }
.tl-sb-item.is-activo, a.tl-sb-item.is-activo:hover { background: var(--navy); color: #fff; }
.tl-sb-item:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.tl-sb-item.is-pronto { opacity: 0.5; cursor: default; }
.tl-sb-txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tl-sb-pronto {
  display: block; margin-top: 2px;
  font-size: 10px; font-weight: 500; line-height: 14px; letter-spacing: 0.05em; text-transform: uppercase;
}

.tl-sb-pie {                                     /* px-3 py-4 border-t border-white/10 */
  flex-shrink: 0;
  padding: 16px 12px;
  border-top: 1px solid var(--sb-linea);
}
.tl-sb-inicio { margin-bottom: 4px; }            /* mb-1 */
.tl-sb-salir { font-weight: 400; }               /* Cerrar Sesión sin font-medium, como Compras */
.tl-sb-salir:disabled { opacity: 0.6; cursor: progress; }

/* ── Cabecera blanca (header de AppShell.tsx) ──────────────────────────── */
.tl-cab {                                        /* bg-white border-b border-silver/40 px-6 py-3 */
  position: sticky; top: 0; z-index: 45;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--cab-alto);
  margin-left: var(--sb-ancho);
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid rgba(174, 174, 184, 0.40);
}
.tl-cab-izq { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tl-cab-txt { min-width: 0; }
.tl-cab-tit {                                    /* text-navy font-bold text-sm uppercase tracking-wide */
  margin: 0;
  font-size: 14px; font-weight: 700; line-height: 20px; letter-spacing: 0.025em; text-transform: uppercase;
  color: var(--navy);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-cab-sub {                                    /* subtítulo opcional (p. ej. centro): text-xs slate */
  margin: 0; font-size: 12px; line-height: 16px; color: var(--slate);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-cab-abrir {                                  /* lg:hidden text-slate hover:text-navy, Menu 22 */
  display: none; flex-shrink: 0;
  margin: 0 0 0 -4px; padding: 4px;
  border: 0; border-radius: 2px; background: transparent; color: var(--slate); cursor: pointer;
  transition: color 0.15s;
}
.tl-cab-abrir:hover { color: var(--navy); }
.tl-cab-abrir .tl-ico { display: block; }

.tl-cab-der { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.tl-cab-campana {                                /* relative text-slate hover:text-navy p-1, Bell 20 */
  position: relative; display: block; padding: 4px;
  border: 0; border-radius: 2px; background: transparent; color: var(--slate); cursor: pointer;
  transition: color 0.15s;
}
.tl-cab-campana:hover { color: var(--navy); }
.tl-cab-campana .tl-ico { display: block; }

.tl-usr { position: relative; }
.tl-usr-btn {                                    /* flex items-center gap-2 text-sm hover:bg-ice rounded-sm px-2 py-1.5 */
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border: 0; border-radius: 2px; background: transparent;
  font-family: inherit; font-size: 14px; line-height: 20px; cursor: pointer;
  transition: background-color 0.15s;
}
.tl-usr-btn:hover, .tl-usr-btn[aria-expanded="true"] { background: var(--ice); }
.tl-usr-avatar {                                 /* w-7 h-7 bg-navy rounded-sm; inicial text-white text-xs font-bold */
  width: 28px; height: 28px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy); border-radius: 2px;
  color: #fff; font-size: 12px; font-weight: 700; line-height: 16px;
}
.tl-usr-nombre {                                 /* hidden sm:block font-medium text-slate truncate max-w-32 */
  display: block; max-width: 128px;
  font-weight: 500; color: var(--slate);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-usr-chev { color: var(--silver); }           /* ChevronDown 14 text-silver */

.tl-usr-menu {                                   /* absolute right-0 top-full mt-1 w-48 bg-white border-silver/50 rounded-sm shadow-lg z-50 */
  position: absolute; right: 0; top: 100%; z-index: 50;
  width: 192px; margin-top: 4px;
  background: #fff; border: 1px solid rgba(174, 174, 184, 0.50); border-radius: 2px;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.10), 0 4px 6px -4px rgb(0 0 0 / 0.10);
}
.tl-usr-dato { padding: 12px 16px; border-bottom: 1px solid var(--ice); }   /* px-4 py-3 border-b border-ice */
.tl-usr-dato p {
  margin: 0; font-size: 12px; line-height: 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-usr-nom { font-weight: 600; color: var(--navy); }
.tl-usr-rol { color: var(--slate); }
.tl-usr-salir {                                  /* flex items-center gap-2 w-full px-4 py-2.5 text-sm text-slate hover:bg-ice */
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 16px;
  border: 0; border-radius: 0; background: transparent;
  font-family: inherit; font-size: 14px; line-height: 20px; color: var(--slate); text-align: left; cursor: pointer;
  transition: background-color 0.15s;
}
.tl-usr-salir:hover:not(:disabled) { background: var(--ice); }
.tl-usr-salir:disabled { opacity: 0.6; cursor: progress; }

/* ── Contenido (main de AppShell.tsx: p-6, fondo ice del body) ─────────── */
.tl-con-shell .tl-contenido {
  display: block; min-width: 0; min-height: calc(100vh - var(--cab-alto));
  margin-left: var(--sb-ancho); padding: 24px;
}
.tl-contenido:focus { outline: none; }

/* ── Fondo del cajón (solo bajo 1024 px) ───────────────────────────────── */
.tl-sb-velo { display: none; }
.tl-sb-cerrar {                                  /* absolute top-4 right-4 text-white, X 20 */
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 2px; background: transparent; color: #fff; cursor: pointer;
}
.tl-sb-cerrar:focus-visible { outline: 2px solid #fff; outline-offset: 0; }

@media (max-width: 1023.98px) {
  .tl-sb {
    z-index: 70;
    transform: translateX(-100%); visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .tl-sb.is-abierto { transform: none; visibility: visible; transition: transform 0.2s ease, visibility 0s; }
  .tl-sb-velo { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, 0.5); }

  .tl-cab { margin-left: 0; padding: 12px 16px; }          /* px-4 */
  .tl-cab-abrir { display: block; }
  .tl-con-shell .tl-contenido { margin-left: 0; padding: 16px; }   /* p-4 */
  html.tl-sb-bloqueo { overflow: hidden; }
}
@media (max-width: 639.98px) {
  .tl-usr-nombre { display: none; }                         /* hidden sm:block */
}

@media print {
  .tl-sb, .tl-cab, .tl-sb-velo, .tl-saltar { display: none !important; }
  .tl-con-shell .tl-contenido { margin-left: 0; padding: 0; min-height: 0; }
}

/* ── Botones ───────────────────────────────────────────────────────────── */
.tl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; min-height: 38px;
  border: 1px solid transparent; border-radius: var(--radio);
  font-size: 13px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.tl-btn:disabled, .tl-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.tl-btn-pri { background: var(--navy); color: #fff; }
.tl-btn-pri:hover:not(:disabled) { background: var(--navy-deep); }
.tl-btn-sec { background: #fff; border-color: var(--linea-fuerte); color: var(--slate); }
.tl-btn-sec:hover:not(:disabled) { background: var(--ice); color: var(--navy); }
.tl-btn-fant { background: transparent; color: var(--slate); }
.tl-btn-fant:hover:not(:disabled) { background: var(--ice); color: var(--navy); }
.tl-btn-peligro { background: #fff; border-color: var(--err-bd); color: var(--err-tx); }
.tl-btn-peligro:hover:not(:disabled) { background: var(--err-bg); }
.tl-btn-chico { padding: 5px 10px; min-height: 30px; font-size: 11px; gap: 6px; }
.tl-btn-bloque { width: 100%; }
.tl-btn-ico { padding: 0; width: 34px; min-height: 34px; height: 34px; }

/* ── Campos ────────────────────────────────────────────────────────────── */
.tl-campo { margin-bottom: 16px; }
.tl-label {
  display: block; margin-bottom: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--slate);
}
.tl-input, .tl-select {
  width: 100%; min-height: 40px; padding: 9px 12px;
  background: #fff; border: 1px solid var(--silver); border-radius: var(--radio);
  font-size: 14px; color: var(--negro);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tl-select { padding-right: 32px; }
.tl-input:focus, .tl-select:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
.tl-input:disabled, .tl-select:disabled { background: var(--ice); color: var(--slate); cursor: not-allowed; }
.tl-input::placeholder { color: #8A8F9C; }
.tl-ayuda { margin: 6px 0 0; font-size: 12px; color: var(--slate); }
.tl-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--negro); cursor: pointer; }
.tl-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--navy); cursor: pointer; }
.tl-check input:disabled, .tl-check input:disabled + span { cursor: not-allowed; opacity: 0.5; }

/* ── Alertas e insignias ───────────────────────────────────────────────── */
.tl-alerta {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid; border-radius: var(--radio);
  font-size: 13px; line-height: 1.45;
}
.tl-alerta .tl-ico { margin-top: 1px; }
.tl-alerta-error { background: var(--err-bg); color: var(--err-tx); border-color: var(--err-bd); }
.tl-alerta-ok    { background: var(--ok-bg);  color: var(--ok-tx);  border-color: var(--ok-bd); }
.tl-alerta-aviso { background: var(--av-bg);  color: var(--av-tx);  border-color: var(--av-bd); }
.tl-alerta-info  { background: var(--info-bg); color: var(--info-tx); border-color: var(--info-bd); }
.tl-alerta-cuerpo { flex: 1; min-width: 0; }
.tl-alerta-cerrar {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  padding: 2px; margin: -2px -4px 0 0; border-radius: var(--radio); opacity: 0.75;
}
.tl-alerta-cerrar:hover { opacity: 1; }

.tl-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border: 1px solid; border-radius: var(--radio);
  font-size: 12px; font-weight: 500; line-height: 1.5; white-space: nowrap;
}
.tl-badge-ok   { background: var(--ok-bg);   color: var(--ok-tx);   border-color: var(--ok-bd); }
.tl-badge-err  { background: var(--err-bg);  color: var(--err-tx);  border-color: var(--err-bd); }
.tl-badge-av   { background: var(--av-bg);   color: var(--av-tx);   border-color: var(--av-bd); }
.tl-badge-info { background: var(--info-bg); color: var(--info-tx); border-color: var(--info-bd); }
.tl-badge-gris { background: var(--gris-bg); color: var(--gris-tx); border-color: var(--gris-bd); }
.tl-badge-navy { background: var(--navy);    color: #fff;           border-color: var(--navy); }

/* ── Panel y tabla ─────────────────────────────────────────────────────── */
.tl-panel { background: var(--white-tl); border: 1px solid var(--linea); border-radius: var(--radio); }
.tl-panel-cab {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid rgba(174, 174, 184, 0.3);
}
.tl-panel-tit { margin: 0; font-size: 14px; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: 0.05em; }

.tl-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tl-tabla th {
  padding: 11px 14px; background: var(--ice); text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--slate);
}
.tl-tabla td { padding: 11px 14px; border-bottom: 1px solid var(--linea-suave); vertical-align: middle; }
.tl-tabla tbody tr:hover { background: rgba(242, 242, 245, 0.5); }
.tl-tabla .tl-num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Diálogo (elemento <dialog> nativo) ────────────────────────────────── */
.tl-dialogo {
  width: min(500px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  padding: 0; border: 0; border-radius: var(--radio);
  background: #fff; color: var(--negro); box-shadow: var(--sombra-2xl);
}
.tl-dialogo::backdrop { background: rgba(0, 0, 0, 0.5); }
.tl-dialogo-cab {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--linea);
}
.tl-dialogo-cab h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: 0.05em; }
.tl-dialogo-cuerpo { padding: 20px; }
.tl-dialogo-pie { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 0 20px 20px; }
.tl-dialogo-x {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: var(--radio); background: transparent; color: var(--slate); cursor: pointer;
}
.tl-dialogo-x:hover { background: var(--ice); color: var(--navy); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.tl-toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  max-width: min(380px, calc(100vw - 32px));
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--radio);
  background: var(--midnight); color: #fff; box-shadow: var(--sombra-xl);
  border-left: 4px solid var(--cyan);
  font-size: 13px; line-height: 1.45;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.tl-toast.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.tl-toast.is-error { border-left-color: #F87171; }
.tl-toast.is-ok { border-left-color: #34D399; }
@media (max-width: 639.98px) { .tl-toast { left: 16px; right: 16px; bottom: 16px; max-width: none; } }

/* ── Esqueleto y spinner ───────────────────────────────────────────────── */
.tl-esq { background: rgba(174, 174, 184, 0.25); border-radius: var(--radio); animation: tl-pulso 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes tl-pulso { 50% { opacity: 0.5; } }
.tl-gira { animation: tl-giro 0.9s linear infinite; }
@keyframes tl-giro { to { transform: rotate(360deg); } }
