/* =====================================================
   TABLA PERLA — Widget de Tablas Reutilizable v2
   Fichero : tabla-perla.css
   Scope   : Solo afecta a elementos con class="tabla-perla"
   Web     : Webapuestas (Drupal 11)
====================================================== */

/* ── RESET ─────────────────────────────────────────── */
.tabla-perla *,
.tabla-perla *::before,
.tabla-perla *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── VARIABLES DE TEMA ─────────────────────────────── */
.tabla-perla {
  --tp-inicio:  #3aa0d6;
  --tp-fin:     #4fd1b1;
  --tp-cat1:    rgba(255,255,255,.80);
  --tp-cat2:    rgba(255,255,255,.50);
  --tp-cat3:    rgba(255,255,255,.65);
  --tp-cat4:    rgba(255,255,255,.40);
}

/* ── CONTENEDOR PRINCIPAL ──────────────────────────── */
.tabla-perla {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Helvetica, Arial, sans-serif;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(90deg, var(--tp-inicio), var(--tp-fin));
  position: relative;
}

.tabla-perla::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 80% at 100% 50%, rgba(255,255,255,.10) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at   0%  0%, rgba(255,255,255,.08) 0%, transparent 50%);
  pointer-events: none;
}

/* ── WRAPPER INTERIOR ──────────────────────────────── */
.tp-inner {
  position: relative;
  z-index: 1;
  padding: 20px 20px 16px;
}

/* ── CABECERA ──────────────────────────────────────── */
.tp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 8px;
}

.tp-pretitle {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(255,255,255,.85);
  margin-bottom: 5px;
}

.tp-title {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.01em;
  line-height: 1.1;
}

/* ── TABS ──────────────────────────────────────────── */
.tp-tabs {
  display: flex;
  gap: 3px;
  background: rgba(0,0,0,.15);
  border-radius: 8px;
  padding: 3px;
  flex-wrap: wrap;
}

.tp-tab {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 5px 13px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
  line-height: 1.4;
}

.tp-tab:hover  { color: rgba(255,255,255,.9); background: rgba(255,255,255,.12); }
.tp-tab.active { background: rgba(255,255,255,.25); color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); }

/* ── TEXTO DE AYUDA ────────────────────────────────── */
.tp-hint {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tp-hint::before {
  content: 'ℹ';
  font-size: 13px;
  opacity: .55;
}

/* ── LISTA ─────────────────────────────────────────── */
.tp-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── FILA ──────────────────────────────────────────── */
.tp-row {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  overflow: hidden;
  transition: background .18s, border-color .18s;
  position: relative;
  cursor: pointer;
}

/* Acento lateral por categoría */
.tp-row::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 10px 0 0 10px;
  transition: width .2s;
}

.tp-row.cat-1::before { background: var(--tp-cat1); }
.tp-row.cat-2::before { background: var(--tp-cat2); }
.tp-row.cat-3::before { background: var(--tp-cat3); }
.tp-row.cat-4::before { background: var(--tp-cat4); }

.tp-row:hover         { background: rgba(255,255,255,.20); border-color: rgba(255,255,255,.30); }
.tp-row:hover::before { width: 4px; }
.tp-row.open          { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.30); }
.tp-row.hidden        { display: none; }

/* ── CABECERA DE FILA (área clickable) ─────────────── */
.tp-row-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px 11px 16px;
  user-select: none;
}

/* ── RANKING ───────────────────────────────────────── */
.tp-rank {
  width: 36px;
  flex-shrink: 0;
  font-size: 22px;
  font-weight: 800;
  color: rgba(255,255,255,.40);
  text-align: right;
  line-height: 1;
}

.tp-rank.top { color: #ffd700; }

/* ── ICONO ─────────────────────────────────────────── */
.tp-icon {
  font-size: 17px;
  flex-shrink: 0;
  margin-left: 6px;
}

/* ── INFO TEXTUAL ──────────────────────────────────── */
.tp-info {
  flex: 1;
  min-width: 0;
  margin-left: 6px;
}

.tp-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.tp-sub {
  font-size: 10.5px;
  font-weight: 500;
  color: rgba(255,255,255,.6);
  letter-spacing: .07em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ── COLUMNA DERECHA ───────────────────────────────── */
.tp-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.tp-value {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  white-space: nowrap;
}

/* Unidad bajo el valor — se lee del atributo data-unit */
.tp-value[data-unit]::after {
  content: attr(data-unit);
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,.55);
  letter-spacing: .03em;
  margin-top: 2px;
}

/* ── BARRA DE PROGRESO ─────────────────────────────── */
.tp-bar-wrap { position: relative; }

.tp-bar {
  width: 64px;
  height: 3px;
  background: rgba(255,255,255,.2);
  border-radius: 2px;
  overflow: hidden;
}

.tp-bar-fill {
  height: 100%;
  border-radius: 2px;
  width: 0;
  background: rgba(255,255,255,.8);
  transition: width .9s cubic-bezier(.22,1,.36,1);
}

/* Tooltip de la barra */
.tp-bar-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 5px);
  right: 0;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

.tp-bar-tip::after {
  content: '';
  position: absolute;
  top: 100%; right: 8px;
  border: 4px solid transparent;
  border-top-color: rgba(0,0,0,.7);
}

.tp-bar-wrap:hover .tp-bar-tip { display: block; }

/* ── CHEVRON ───────────────────────────────────────── */
.tp-chevron {
  flex-shrink: 0;
  color: rgba(255,255,255,.35);
  transition: transform .25s, color .2s;
  display: flex;
  align-items: center;
  margin-left: 4px;
}

.tp-row:hover .tp-chevron { color: rgba(255,255,255,.7); }
.tp-row.open  .tp-chevron { transform: rotate(180deg); color: #fff; }

/* ── PANEL DETALLE (acordeón) ──────────────────────── */
.tp-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height .32s ease, opacity .25s;
  opacity: 0;
}

.tp-row.open .tp-detail {
  max-height: 200px;
  opacity: 1;
}

.tp-detail-inner {
  border-top: 1px solid rgba(255,255,255,.12);
  padding: 12px 20px 16px;
  font-size: 13px;
  color: rgba(255,255,255,.8);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tp-detail-inner strong { color: #fff; font-weight: 700; }

/* ── BADGE ─────────────────────────────────────────── */
.tp-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  width: fit-content;
  margin-bottom: 4px;
}

/* ── PIE DE TABLA ──────────────────────────────────── */
.tp-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.15);
}

.tp-footer-state {
  display: none;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tp-footer-state.active { display: flex; }

.tp-footer-note {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tp-footer-note::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(74,222,128,.6);
  flex-shrink: 0;
}

.tp-total {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  display: flex;
  align-items: center;
  gap: 4px;
}

.tp-total strong {
  font-weight: 700;
  color: rgba(255,255,255,.9);
}

/* ── TEMAS ─────────────────────────────────────────── */
.tabla-perla.tema-azul    { --tp-inicio: #3aa0d6; --tp-fin: #4fd1b1; }
.tabla-perla.tema-rojo    { --tp-inicio: #e05252; --tp-fin: #f0922e; }
.tabla-perla.tema-purpura { --tp-inicio: #7c3aed; --tp-fin: #db2777; }
.tabla-perla.tema-verde   { --tp-inicio: #059669; --tp-fin: #10b981; }
.tabla-perla.tema-oscuro  { --tp-inicio: #1e293b; --tp-fin: #334155; }
.tabla-perla.tema-dorado  { --tp-inicio: #b45309; --tp-fin: #d97706; }

/* ── RESPONSIVE ────────────────────────────────────── */
@media (max-width: 480px) {
  .tp-row.open .tp-detail  { max-height: 320px; }
  .tp-name                 { white-space: normal; font-size: 13px; }
  .tp-sub                  { font-size: 9.5px; }
  .tp-value                { font-size: 13px; }
  .tp-value::after         { font-size: 9px; }
  .tp-bar-wrap             { display: none; }
  .tp-tabs                 { gap: 2px; }
  .tp-tab                  { padding: 5px 9px; font-size: 11px; }
  .tp-detail-inner         { padding: 14px 16px 18px; }
}
