/* ==========================================================================
   Bóveda del Gato Negro — Theme Polish v2.0 (unificado con Purchase Detail)
   - Tokens (colores, radios, sombras, gaps, motion)
   - Tipografía base + ritmo vertical
   - Paneles y Tarjetas (elevación y hover)
   - Botones / Chips / Selects (consistencia y accesibilidad)
   - Sidebar (estado activo/hover)
   - Tooltips / Toasts (armonía)
   - Skeletons y estados vacíos
   - Motion responsable (prefers-reduced-motion)
   - Micro-opt de rendering (content-visibility)
   - NUEVO: Badges canónicos (desde Purchase Detail)
   - NUEVO: Pills unificados con hover
   - NUEVO: KPIs con glow y borde lateral
   - NUEVO: Encabezados tipo pill
   - NUEVO: Tabla unificada con sticky headers mejorados
   ========================================================================== */

/* ============================== TOKENS =================================== */
:root {
  /* Colores base (modo dark) */
  --bg-0: #0d0f13; /* canvas */
  --bg-1: #10131a; /* panel */
  --bg-2: #111216; /* tarjeta */
  --bd-1: #23252b; /* borde suave */
  --bd-2: #2d2f36; /* borde hover */
  --tx-1: #e9e9f1; /* texto principal */
  --tx-2: #cfd2d8; /* texto secundario */
  --tx-3: #a0a0a6; /* texto tenue */

  /* Acentos */
  --acc-1: #5276ff;   /* primario frío */
  --acc-2: #a7f3d0;   /* éxito */
  --acc-warn: #ffd569;/* aviso */
  --acc-err: #f28b82; /* error */

  /* NUEVO: Sistema de colores semánticos (desde Purchase Detail) */
  --color-green: #a0ffc8;
  --color-green-bg: #1a3a2a;
  --color-amber: #ffd36b;
  --color-amber-bg: #3a2a1a;
  --color-red: #ff9d9d;
  --color-red-bg: #3a1a1a;
  --color-blue: #7bc2ff;
  --color-blue-bg: #1a2a3a;
  --color-gray: #6a7080;
  --color-gray-bg: #1a1c24;

  /* Geometría */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --gap-sm: 8px;
  --gap-md: 12px;
  --gap-lg: 16px;
  
  /* NUEVO: Geometría extendida */
  --pill-radius: 24px;
  --card-radius: 12px;

  /* Elevaciones */
  --elev-0: none;
  --elev-1: 0 1px 0 0 #1a1b20 inset, 0 0 0 1px rgba(255,255,255,0.02);
  --elev-2: 0 6px 16px rgba(0,0,0,.35), 0 0 0 1px rgba(82,118,255,.08);

  /* Motion */
  --ease-1: cubic-bezier(.2,.7,.2,1);
  --dur-1: .14s;
  
  /* NUEVO: Motion extendido */
  --transition-fast: 0.1s ease;
  --transition-normal: 0.2s ease;

  /* Sugerencia de esquema oscuro a controles nativos */
  color-scheme: dark;
}

/* ===== Bridge de tokens (compat con main.css) ===== */
:root {
  --panel: var(--bg-1);
  --panel-border: var(--bd-1);
  --panel-outline: var(--bd-1);
  --text: var(--tx-1);
  --muted: var(--tx-3);
  --btn: #0f1013;
  --btn-border: var(--bd-1);
  --btn-hover: #151722;
}

/* ============================ TIPOGRAFÍA ================================= */
html {
  font-family: Inter, "Segoe UI", Roboto, system-ui, -apple-system, Arial, sans-serif;
  color: var(--tx-2);
  background: var(--bg-0);
}

h1, h2, h3 {
  color: var(--tx-1);
  line-height: 1.3;
  letter-spacing: .2px;
}
p, li, span {
  color: var(--tx-2);
  line-height: 1.45;
}

/* =========================== PANELES / CARDS ============================= */
.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--bd-1);
  background: var(--bg-1);
  box-shadow: var(--elev-1);
}

.card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--bd-1);
  /* Luz ambiental muy leve en la parte alta */
  background:
    linear-gradient(180deg, rgba(255,255,255,.02) 0%, rgba(255,255,255,0) 40%),
    var(--bg-2);
  box-shadow: var(--elev-1);
  transition:
    transform var(--dur-1) var(--ease-1),
    box-shadow var(--dur-1) var(--ease-1),
    border-color var(--dur-1) var(--ease-1);
}
.card:hover {
  transform: translateY(-1px);
  border-color: var(--bd-2);
  box-shadow: var(--elev-2);
}

/* Comodines de layout para tarjetas (no invasivos) */
.card .card__head { display:flex; align-items:flex-start; justify-content:space-between; gap: var(--gap-md); }
.card .card__desc { margin-top: 6px; color: var(--tx-2); }
.card .card__meta { display:flex; align-items:center; justify-content:space-between; gap: var(--gap-md); flex-wrap:wrap; }

/* Separador suave reusado */
.sep {
  height:1px;
  background: linear-gradient(90deg, transparent, var(--bd-1), transparent);
  opacity:.85;
}

/* =================== BOTONES / CHIPS / SELECTS ========================== */
.btn{
  border-radius: var(--radius-sm);
  border: 1px solid var(--bd-1);
  background: #0f1013;
  color: var(--tx-1);
  transition:
    transform var(--dur-1) var(--ease-1),
    border-color var(--dur-1) var(--ease-1),
    background var(--dur-1) var(--ease-1);
}
.btn:hover { transform: translateY(-1px); border-color: var(--bd-2); }

/* Foco accesible — Fallback universal */
.btn:focus-visible {
  outline: 2px solid var(--acc-1);
  outline-offset: 2px;
}
/* Refinar si hay soporte de color-mix */
@supports (outline: color-mix(in srgb, red 50%, white 50%)) {
  .btn:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--acc-1) 75%, white 25%);
    outline-offset: 2px;
  }
}
/* Alto contraste (Windows) */
@media (forced-colors: active) {
  .btn:focus-visible { outline: 2px solid Highlight; }
}

.chip, .pill {
  border-radius: 999px;
  border: 1px solid #253045;
  background: #10131a;
  color: #bcd0ff;
}
.chip:hover { border-color: #355180; }

/* El chip muestra el foco interno (inputs/selects) */
.chip:focus-within {
  border-color: #5865f2;
  box-shadow: 0 0 0 2px rgba(88,101,242,.25);
}
@media (forced-colors: active) {
  .chip:focus-within { outline: 2px solid Highlight; outline-offset: 2px; }
}

select {
  color: var(--tx-1);
  background: #0f1013;
  border: 1px solid var(--bd-1);
  border-radius: var(--radius-sm);
}
select:focus-visible { outline: 2px solid #355180; outline-offset: 2px; }
select:disabled { opacity:.55; cursor:not-allowed; }

/* ============================== SIDEBAR ================================== */
.side-nav__link {
  display:flex; align-items:center; gap:10px; padding:8px 10px;
  border-radius: var(--radius-md);
  border:1px solid transparent;
  color: var(--tx-2);
}
.side-nav__link:hover { background:#11131a; border-color: var(--bd-1); color: var(--tx-1); }
.side-nav__link.is-active { background:#151723; border-color:#2a2c35; color: var(--tx-1); }
.side-nav__icon { width:18px; height:18px; display:grid; place-items:center; flex: 0 0 18px; }

/* Foco visible en links del sidebar */
.side-nav__link:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--acc-1) 60%, white 15%);
  outline-offset: 2px;
  border-radius: var(--radius-md);
}
@media (forced-colors: active) {
  .side-nav__link:focus-visible { outline: 2px solid Highlight; }
}

.side-head-icon { display:inline-grid; place-items:center; width:18px; height:18px; margin-right:6px; }

.icon-img { width:18px; height:18px; object-fit:contain; border-radius:3px; }
.icon-img.contrast { filter: drop-shadow(0 0 1px rgba(0,0,0,.4)); }

/* =========================== TOOLTIPS / TOASTS =========================== */
.inf-prev {
  position:absolute;
  z-index: 50;
  border:1px solid #2b2f3a;
  background:#0f1117;
  border-radius: var(--radius-md);
  box-shadow: var(--elev-2);
  padding:6px;
  opacity: 0; transform: translateY(-4px);
  transition: opacity var(--dur-1) var(--ease-1), transform var(--dur-1) var(--ease-1);
}
.inf-prev.on { opacity:1; transform: translateY(0); }
.inf-prev img { width:auto; height:auto; max-width:260px; max-height:260px; display:block; }

.toasts { display:grid; gap:10px; position:fixed; right:14px; bottom:16px; z-index:60; }
.toast {
  border-radius: var(--radius-md);
  border:1px solid var(--bd-1);
  background:#10131a;
  color:var(--tx-1);
  box-shadow: var(--elev-2);
  padding:10px 12px;
}

/* ============================== SKELETONS ================================ */
.skel-anim{
  background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.08), rgba(255,255,255,.04));
  background-size: 200% 100%;
  animation: skel 1.1s var(--ease-1) infinite;
}
@keyframes skel { to { background-position: -200% 0; } }

.empty { color:var(--tx-3); display:flex; align-items:center; gap:10px; }

/* ========================== MOTION RESPONSABLE =========================== */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================ MICRO‑PERFORMANCE ========================== */
/* Si preferís, podés aplicar esto directo en HTML/JS; acá dejamos reglas por id
   usados en el proyecto (no rompe si no existen en DOM). */
#metaList, #walletCards {
  content-visibility: auto;
  contain-intrinsic-size: 720px; /* ajuste fino para reducir "saltito" inicial */
}

/* ===================== DETALLE TEMÁTICO (OPCIONAL) ====================== */
/* Usar con moderación: un micro degradado “bronce” sólo en headings de panel. */
/*
.panel-head__title {
  background: linear-gradient(90deg, #f2e3c1 0%, #d7b980 40%, #9f7a40 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
*/

/* ===================== HERO: altura y superposición ===================== */
/* Ajustá el selector a tu hero real: .header-hero, .hero, .hero-wrap, etc. */
.an-hero {
  /* Altura base más baja */
  min-height: 240px;
  padding-top: 18px;
  padding-bottom: 18px;

  /* Evitar que tape el menú o los paneles */
  position: relative;
  z-index: 0;
}
.an-hero::after {
  /* Si usás brillos/overlays, que no eleven el stacking-context */
  z-index: 0;
}

/* HEADER (menú superior): asegurar que quede por encima del hero si se superponen */
.site-header, .topbar, header[role="banner"] {
  position: relative;
  z-index: 2;
}

/* SEPARACIÓN con el contenido (paneles) */
.an-hero { margin-bottom: 12px; }

/* Alternativa (si preferís tirar del contenido, no del hero) */
/*
main .panel-head:first-of-type,
#walletPanel .panel-head,
#metaPanel .panel-head,
#achievementsPanel .panel-head,
#wvPanel .panel-head {
  margin-top: 8px;
}
*/

/* Breakpoints: hero más compacto en pantallas chicas */
@media (max-width: 900px) {
  .an-hero {
    min-height: 200px;
    padding-top: 14px;
    padding-bottom: 14px;
    margin-bottom: 10px;
  }
}

/* ===================== SIDEBAR — Separación del borde izquierdo ===================== */
aside.col-side .panel-head {
  padding-left: 14px !important;  /* aire a ícono + texto */
  padding-right: 10px;            /* simetría */
}

aside.col-side .panel-head__title {
  margin-left: 4px;               /* separa el ícono del texto */
  display: flex;
  align-items: center;
  gap: 8px;                       /* espacio entre icono y título */
}

/* Si los iconos están demasiado pegados independientemente del título */
aside.col-side .side-head-icon,
aside.col-side .panel-head img {
  margin-right: 6px !important;   /* espacio útil icono → título */
}

/* ==========================================================================
   NUEVAS SECCIONES — Componentes canónicos desde Purchase Detail
   ========================================================================== */

/* ============================== BADGES CANÓNICOS ========================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
  transition: transform var(--transition-fast), filter var(--transition-fast);
  cursor: default;
}
.badge:hover {
  transform: scale(1.02);
  filter: brightness(1.1);
}
.badge--success {
  background: var(--color-green-bg);
  color: var(--color-green);
  border: 1px solid #2a6a4a;
}
.badge--warning {
  background: var(--color-amber-bg);
  color: var(--color-amber);
  border: 1px solid #aa8a3a;
}
.badge--info {
  background: var(--color-blue-bg);
  color: var(--color-blue);
  border: 1px solid #3a6a9a;
}
.badge--infinite {
  background: #1a2a2a;
  color: var(--color-blue);
  border: 1px solid #2a6a6a;
}
.badge--muted {
  background: #2a2a2a;
  color: #a0a0a6;
  border: 1px solid #4a4a4a;
}

/* ============================== PILLS UNIFICADOS =========================== */
.pill-unified {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-gray-bg);
  border: 1px solid #2a2c35;
  border-radius: var(--pill-radius);
  padding: 4px 12px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.pill-unified:hover {
  background: #20222c;
  border-color: #3a3e4a;
}

/* ============================== KPIs CON GLOW ============================== */
.kpi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: all var(--transition-normal);
  border-left-width: 3px;
  border-left-style: solid;
  border-left-color: transparent;
}
.kpi--ok {
  border-left-color: var(--color-green);
  box-shadow: 0 0 6px rgba(160, 255, 200, 0.2);
}
.kpi--warn {
  border-left-color: var(--color-amber);
  box-shadow: 0 0 6px rgba(255, 211, 107, 0.2);
}
.kpi--bad {
  border-left-color: var(--color-red);
  box-shadow: 0 0 6px rgba(255, 157, 157, 0.2);
}
.kpi__label {
  color: #a0a6b3;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.kpi__value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.kpi--ok .kpi__value { color: var(--color-green); }
.kpi--warn .kpi__value { color: var(--color-amber); }
.kpi--bad .kpi__value { color: var(--color-red); }

/* ============================== ENCABEZADOS TIPO PILL ====================== */
.header-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-gray-bg);
  border: 1px solid #2a2c35;
  border-radius: var(--pill-radius);
  padding: 4px 12px;
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: normal;
  white-space: nowrap;
}
.header-pill .header-pill__label {
  color: #b4bad0;
}
.header-pill__icon {
  display: inline-flex;
  align-items: center;
}

/* ============================== TABLA UNIFICADA ============================ */
.table-unified {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
.table-unified th,
.table-unified td {
  padding: 10px 12px;
  border-bottom: 1px solid #24252a;
  white-space: nowrap;
  vertical-align: middle;
}
.table-unified thead th {
  position: sticky;
  top: 0;
  background: #0f1118;
  z-index: 2;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9aa2b8;
  border-bottom: 1px solid #2a2c35;
}
.table-unified th:first-child,
.table-unified td:first-child {
  position: sticky;
  left: 0;
  background: #0e1116;
  z-index: 1;
}

/* ============================== CELDAS DE DATOS NUMÉRICOS ================== */
.aa-cell {
  font-weight: 500;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.aa-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.aa-delta-icon {
  font-size: 0.7rem;
  opacity: 0.8;
}

/* ============================== COLORES SEMÁNTICOS ========================= */
.text-green { color: var(--color-green) !important; font-weight: 700; }
.text-red   { color: var(--color-red) !important; font-weight: 700; }
.text-amber { color: var(--color-amber) !important; font-weight: 700; }
.text-blue  { color: var(--color-blue) !important; font-weight: 700; }

.bg-green-bg { background: var(--color-green-bg); }
.bg-amber-bg { background: var(--color-amber-bg); }
.bg-red-bg   { background: var(--color-red-bg); }
.bg-blue-bg  { background: var(--color-blue-bg); }
.bg-gray-bg  { background: var(--color-gray-bg); }

/* ============================== ANIMACIÓN DE ENTRADA ======================= */
@keyframes fadeInScale {
  0% {
    opacity: 0;
    transform: scale(0.98);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
.animate-fade-in {
  animation: fadeInScale 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

/* ============================== SKELETON MEJORADO ========================== */
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-enhanced {
  background: linear-gradient(90deg, #1a1c24 25%, #252830 50%, #1a1c24 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}
.skeleton-bar {
  height: 24px;
  background: linear-gradient(90deg, #1a1c24 25%, #252830 50%, #1a1c24 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
}
.skeleton-table-wrap {
  padding: 20px;
  text-align: center;
}
.skeleton-table-wrap .skeleton-bar {
  height: 200px;
  width: 100%;
}

/* ============================== TOOLTIP MEJORADO =========================== */
[data-tip] {
  position: relative;
  cursor: help;
}
[data-tip]:hover:after {
  content: attr(data-tip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: #0c0e14;
  color: #e0e4ed;
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 1000;
  border: 1px solid #3a3e4a;
  pointer-events: none;
}