/* ==========================================================================
   TT Skeleton Loader — Adaptive shimmer overlay
   Trading Talents · v1
   --------------------------------------------------------------------------
   Reduce el "page loading by parts" feo. Aparece solo si la carga supera
   180 ms (umbral perceptual), se oculta al instante cuando todo está listo.
   ========================================================================== */

:root {
  --tt-sk-bg: #0a0a0f;
  --tt-sk-surface: #1a1a24;
  --tt-sk-surface-2: #22222e;
  --tt-sk-border: rgba(255, 255, 255, 0.06);
  --tt-sk-shimmer: rgba(255, 255, 255, 0.09);
  --tt-sk-accent: #d4af37;
  --tt-sk-accent-soft: rgba(212, 175, 55, 0.18);
}

/* ───────── Overlay base ───────── */
.tt-skeleton-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: var(--tt-sk-bg);
  display: flex;
  flex-direction: column;
  pointer-events: all;
  opacity: 1;
  transition: opacity 140ms cubic-bezier(0.4, 0, 0.2, 1);
  contain: strict;
  overflow: hidden;
}

.tt-skeleton-overlay[hidden] {
  display: none !important;
}

.tt-skeleton-overlay.tt-sk-fading {
  opacity: 0;
  pointer-events: none;
}

/* ───────── Shimmer animation ───────── */
.tt-sk-shimmer {
  position: relative;
  background: var(--tt-sk-surface-2);
  overflow: hidden;
  border-radius: 6px;
}

.tt-sk-shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--tt-sk-shimmer) 50%,
    transparent 100%
  );
  animation: tt-sk-wave 0.85s linear infinite;
  will-change: transform;
}

@keyframes tt-sk-wave {
  100% { transform: translateX(100%); }
}

/* ───────── Layout helpers ───────── */
.tt-sk-topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--tt-sk-border);
  background: linear-gradient(180deg, #14141f, var(--tt-sk-bg));
  flex-shrink: 0;
}

.tt-sk-topbar .logo-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--tt-sk-accent), #e6c45a);
  opacity: 0.85;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: #000;
  letter-spacing: -0.04em;
}
.tt-sk-topbar .logo-mark::before { content: "TT"; }

.tt-sk-topbar .nav-line { height: 12px; width: 80px; }
.tt-sk-topbar .nav-spacer { flex: 1; }
.tt-sk-topbar .nav-avatar { width: 32px; height: 32px; border-radius: 50%; }

.tt-sk-main {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  overflow: hidden;
}

@media (max-width: 768px) {
  .tt-sk-main { grid-template-columns: 1fr; }
  .tt-sk-sidebar { display: none; }
}

.tt-sk-sidebar {
  border-right: 1px solid var(--tt-sk-border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0d0d14;
}

.tt-sk-sidebar .sb-item {
  height: 36px;
  border-radius: 8px;
}

.tt-sk-content {
  padding: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ───────── Variant: default (generic content) ───────── */
.tt-sk-content .title-line { height: 24px; width: 280px; max-width: 50%; }
.tt-sk-content .sub-line { height: 14px; width: 60%; }

/* ───────── Variant: dashboard ───────── */
.tt-sk-dashboard .stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.tt-sk-dashboard .stat-card {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 92px;
}
.tt-sk-dashboard .stat-card .label { height: 11px; width: 70px; }
.tt-sk-dashboard .stat-card .value { height: 24px; width: 110px; }
.tt-sk-dashboard .stat-card .trend { height: 10px; width: 50px; }

.tt-sk-dashboard .chart-box {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 12px;
  height: 240px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tt-sk-dashboard .chart-box .chart-head { height: 14px; width: 160px; }
.tt-sk-dashboard .chart-box .chart-area { flex: 1; border-radius: 8px; }

/* ───────── Variant: table ───────── */
.tt-sk-table .table-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}
.tt-sk-table .table-toolbar .search { height: 36px; flex: 1; max-width: 320px; }
.tt-sk-table .table-toolbar .filter { height: 36px; width: 110px; }
.tt-sk-table .table-toolbar .btn { height: 36px; width: 130px; }

.tt-sk-table .table-card {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 12px;
  overflow: hidden;
}
.tt-sk-table .row {
  display: grid;
  grid-template-columns: 32px 2fr 1fr 1fr 1fr 80px;
  gap: 14px;
  padding: 14px 18px;
  align-items: center;
  border-bottom: 1px solid var(--tt-sk-border);
}
.tt-sk-table .row:last-child { border-bottom: 0; }
.tt-sk-table .row.head { background: #14141f; }
.tt-sk-table .row .cell { height: 12px; border-radius: 4px; }
.tt-sk-table .row .cell.avatar { height: 28px; width: 28px; border-radius: 50%; }
.tt-sk-table .row .cell.pill { height: 18px; border-radius: 999px; }

/* ───────── Variant: form ───────── */
.tt-sk-form .form-card {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 12px;
  padding: 24px;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tt-sk-form .field { display: flex; flex-direction: column; gap: 6px; }
.tt-sk-form .field .label { height: 12px; width: 120px; }
.tt-sk-form .field .input { height: 40px; border-radius: 8px; }
.tt-sk-form .field .input.textarea { height: 110px; }
.tt-sk-form .form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.tt-sk-form .form-actions .btn { height: 38px; width: 120px; border-radius: 8px; }

/* ───────── Variant: profile ───────── */
.tt-sk-profile .hero {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  gap: 18px;
  align-items: center;
}
.tt-sk-profile .hero .pic { width: 84px; height: 84px; border-radius: 50%; flex-shrink: 0; }
.tt-sk-profile .hero .info { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.tt-sk-profile .hero .info .name { height: 20px; width: 220px; }
.tt-sk-profile .hero .info .meta { height: 12px; width: 140px; }
.tt-sk-profile .hero .info .bio { height: 12px; width: 80%; }

.tt-sk-profile .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.tt-sk-profile .grid .card {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 10px;
  height: 120px;
}

/* ───────── Variant: landing (public) ───────── */
.tt-sk-landing {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.tt-sk-landing .lp-nav {
  height: 64px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--tt-sk-border);
  flex-shrink: 0;
}
.tt-sk-landing .lp-nav .logo { width: 100px; height: 22px; }
.tt-sk-landing .lp-nav .spacer { flex: 1; }
.tt-sk-landing .lp-nav .cta { height: 36px; width: 110px; border-radius: 8px; }

.tt-sk-landing .hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px 24px;
  text-align: center;
}
.tt-sk-landing .hero .h1 { height: 38px; width: min(560px, 90%); }
.tt-sk-landing .hero .h2 { height: 16px; width: min(440px, 80%); }
.tt-sk-landing .hero .h2-2 { height: 16px; width: min(360px, 70%); }
.tt-sk-landing .hero .cta { height: 48px; width: 200px; border-radius: 999px; margin-top: 12px; }

/* ───────── Variant: kol-portal ───────── */
.tt-sk-kolportal .row-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.tt-sk-kolportal .row-stats .stat {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 84px;
}
.tt-sk-kolportal .panels {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}
@media (max-width: 768px) {
  .tt-sk-kolportal .panels { grid-template-columns: 1fr; }
}
.tt-sk-kolportal .panels .card {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 12px;
  height: 280px;
}

/* ───────── Variant: academy-feed ───────── */
.tt-sk-academyfeed .feed-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 18px;
}
@media (max-width: 880px) {
  .tt-sk-academyfeed .feed-grid { grid-template-columns: 1fr; }
}
.tt-sk-academyfeed .post {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tt-sk-academyfeed .post .head { display: flex; align-items: center; gap: 10px; }
.tt-sk-academyfeed .post .head .avatar { width: 36px; height: 36px; border-radius: 50%; }
.tt-sk-academyfeed .post .head .name { height: 12px; width: 140px; }
.tt-sk-academyfeed .post .body { height: 14px; }
.tt-sk-academyfeed .post .body.short { width: 80%; }
.tt-sk-academyfeed .post .media { height: 180px; border-radius: 10px; }
.tt-sk-academyfeed .side .widget {
  background: var(--tt-sk-surface);
  border: 1px solid var(--tt-sk-border);
  border-radius: 12px;
  height: 200px;
  margin-bottom: 14px;
}

/* ───────── Variant: video (watch.html) — minimal, no oculta player ───────── */
.tt-sk-video {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  padding: 24px;
}
.tt-sk-video .player {
  width: min(900px, 100%);
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: #0a0a0f;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tt-sk-video .player .ring {
  width: 56px; height: 56px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--tt-sk-accent);
  border-radius: 50%;
  animation: tt-sk-spin 0.9s linear infinite;
}
@keyframes tt-sk-spin { to { transform: rotate(360deg); } }

/* ───────── Variant: minimal (logo only — boot inicial / errores) ───────── */
.tt-sk-minimal {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.tt-sk-minimal .mark {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--tt-sk-accent), #e6c45a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #000;
  font-size: 22px;
  letter-spacing: -0.04em;
  animation: tt-sk-pulse 1.4s ease-in-out infinite;
}
.tt-sk-minimal .mark::before { content: "TT"; }
.tt-sk-minimal .label {
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
}
@keyframes tt-sk-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* ───────── Accesibilidad: reduced motion ───────── */
@media (prefers-reduced-motion: reduce) {
  .tt-sk-shimmer::after { animation: none; }
  .tt-sk-minimal .mark { animation: none; }
  .tt-sk-video .player .ring { animation-duration: 2.4s; }
  .tt-skeleton-overlay { transition-duration: 120ms; }
}
