/* ============================================================
   Ranking Radial Chile — Design System
   Dark + glassmorphism + acentos magenta/violeta (I&D Chile)
============================================================ */

:root {
  /* Paleta */
  --bg-0:           #060816;
  --bg-1:           #0b0e1d;
  --bg-2:           #11142a;
  --surface:        rgba(255, 255, 255, 0.04);
  --surface-2:      rgba(255, 255, 255, 0.07);
  --surface-strong: rgba(255, 255, 255, 0.10);
  --border:         rgba(255, 255, 255, 0.08);
  --border-strong:  rgba(255, 255, 255, 0.14);
  --text:           #f4f5fb;
  --text-2:         #a8b0c8;
  --text-3:         #6c7393;

  /* Acentos */
  --accent:         #7c5cff;
  --accent-2:       #ff5cdb;
  --accent-3:       #5ce0ff;
  --grad-primary:   linear-gradient(135deg, #7c5cff 0%, #ff5cdb 100%);
  --grad-cool:      linear-gradient(135deg, #5ce0ff 0%, #7c5cff 100%);
  --grad-app:       linear-gradient(135deg, #ffb800 0%, #ff5b3c 100%);

  --success:        #2ed687;
  --danger:         #ff4566;

  /* Geometría */
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --shadow-1: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 12px 48px rgba(124, 92, 255, 0.18);
  --shadow-glow: 0 0 48px rgba(124, 92, 255, 0.35);

  /* Fuentes */
  --font-head: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-num:  'Sora', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(124, 92, 255, 0.25), transparent 70%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(255, 92, 219, 0.18), transparent 70%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(92, 224, 255, 0.10), transparent 60%),
    var(--bg-0);
  min-height: 100vh;
  padding-bottom: 120px;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* ============================================================
   HEADER
============================================================ */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--grad-primary);
  display: grid; place-items: center;
  font-size: 22px;
  box-shadow: var(--shadow-glow);
}
.brand-text h1 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}
.brand-text p { margin: 0; font-size: 12px; color: var(--text-3); }

.header-cta {
  display: flex; gap: 10px; align-items: center;
}
.btn-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: all .2s ease;
}
.btn-pill:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn-pill.primary {
  background: var(--grad-primary);
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(124, 92, 255, 0.4);
}
.btn-pill.primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(124, 92, 255, 0.55); }

/* ============================================================
   HERO
============================================================ */
.hero {
  text-align: center;
  padding: 32px 16px 24px;
  margin-bottom: 36px;
}
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 16px;
}
.hero .eyebrow .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 12px var(--success);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(.8); }
}
.hero h2 {
  font-family: var(--font-head);
  font-size: clamp(28px, 4.5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
  background: linear-gradient(180deg, #fff 0%, #b8bcde 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p { color: var(--text-2); font-size: 16px; max-width: 580px; margin: 0 auto; }

.hero-stats {
  display: flex; justify-content: center; gap: 12px; flex-wrap: wrap;
  margin-top: 28px;
}
.hstat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 22px;
  min-width: 140px;
}
.hstat .n {
  font-family: var(--font-num);
  font-size: 26px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--grad-cool);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hstat .l { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }

/* ============================================================
   TOOLBAR (region selector + búsqueda + acciones)
============================================================ */
.toolbar {
  display: flex; gap: 12px;
  align-items: center; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 18px;
  backdrop-filter: blur(12px);
}
.toolbar .search {
  flex: 1; min-width: 0;
  position: relative;
}
.toolbar .search i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-3);
}
.toolbar .search input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px 10px 38px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all .2s;
}
.toolbar .search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}
.toolbar .select {
  position: relative;
}
.toolbar .select select {
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 36px 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.toolbar .select::after {
  content: '▾';
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.toolbar .compare-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all .2s;
}
.toolbar .compare-btn:hover { background: var(--surface-strong); border-color: var(--border-strong); }
.toolbar .compare-btn .badge-count {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}

/* ============================================================
   LAYOUT GRID
============================================================ */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
}
@media (max-width: 980px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   RANKING LIST
============================================================ */
.list-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; padding: 0 4px;
}
.list-header h3 {
  font-family: var(--font-head);
  font-size: 16px; font-weight: 600;
  margin: 0;
  color: var(--text);
}
.list-header .refresh {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-3); font-size: 12px;
}
.list-header .refresh .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.ranking-list { display: flex; flex-direction: column; gap: 10px; }

.radio-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 48px 56px minmax(0,1fr) auto auto;
  gap: 14px;
  align-items: center;
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
}
.radio-card::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--grad-primary);
  opacity: 0;
  transition: opacity .2s;
  border-radius: var(--radius);
}
.radio-card > * { position: relative; z-index: 1; }
.radio-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-1); }
.radio-card.is-top1::before { opacity: 0.06; }
.radio-card.is-top1 { border-color: rgba(124, 92, 255, 0.4); }

.rank-num {
  font-family: var(--font-head);
  font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text-3);
  width: 48px;
}
.radio-card.is-top1 .rank-num,
.radio-card.is-top2 .rank-num,
.radio-card.is-top3 .rank-num {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.radio-logo {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 22px;
  color: var(--text-3);
  overflow: hidden;
  flex-shrink: 0;
}
.radio-logo img { width: 100%; height: 100%; object-fit: cover; }

.radio-info { min-width: 0; }
.radio-name {
  font-family: var(--font-head);
  font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 8px;
}
.radio-meta {
  font-size: 12px; color: var(--text-3);
  display: flex; gap: 8px; align-items: center;
  margin-top: 2px;
}
.radio-meta .sep { color: var(--text-3); opacity: .5; }

.tag-app {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--grad-app);
  color: #1a0f00;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.05em;
  cursor: help;
  flex-shrink: 0;
}
.tag-dest {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--grad-primary);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.05em;
  flex-shrink: 0;
}

.audience {
  text-align: right;
  min-width: 110px;
}
.audience .n {
  font-family: var(--font-num);
  font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.audience .l { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.audience .delta {
  display: inline-block;
  font-size: 11px;
  margin-top: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.audience .delta.up   { background: rgba(46, 214, 135, 0.15); color: var(--success); }
.audience .delta.down { background: rgba(255, 69, 102, 0.15); color: var(--danger); }
.audience .delta.flat { color: var(--text-3); }

.card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: grid; place-items: center;
  transition: all .15s;
}
.icon-btn:hover { background: var(--surface-strong); border-color: var(--border-strong); }
.icon-btn.play.is-playing { background: var(--grad-primary); border-color: transparent; }
.icon-btn.compare.is-selected {
  background: var(--grad-cool); border-color: transparent; color: #000;
}

/* Skeleton loader */
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-strong) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-row { height: 76px; margin-bottom: 10px; }

.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-3);
}
.empty-state i { font-size: 40px; opacity: 0.4; display: block; margin-bottom: 12px; }

/* ============================================================
   SIDEBAR
============================================================ */
.sidebar { display: flex; flex-direction: column; gap: 14px; }

.side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.side-card h4 {
  font-family: var(--font-head);
  font-size: 14px; font-weight: 600;
  margin: 0 0 6px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-2);
}

/* Destacada de la semana */
.featured-card {
  background:
    radial-gradient(circle at 30% 0%, rgba(124, 92, 255, 0.3), transparent 60%),
    var(--surface);
  border: 1px solid rgba(124, 92, 255, 0.3);
}
.featured-card .crown {
  display: inline-block;
  background: var(--grad-primary);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 12px;
}
.featured-card .name {
  font-family: var(--font-head);
  font-size: 18px; font-weight: 700;
  margin-bottom: 4px;
}
.featured-card .meta { color: var(--text-3); font-size: 12px; margin-bottom: 12px; }
.featured-card .growth {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(46, 214, 135, 0.15);
  color: var(--success);
  padding: 6px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* CTA App (sin números) */
.cta-app-card {
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 184, 0, 0.18), transparent 60%),
    var(--surface);
  border: 1px solid rgba(255, 184, 0, 0.25);
  position: relative;
  overflow: hidden;
}
.cta-app-card .icon-bg {
  position: absolute; right: -10px; bottom: -10px;
  font-size: 80px; opacity: 0.08;
}
.cta-app-card h3 {
  font-family: var(--font-head);
  font-size: 16px; font-weight: 700;
  margin: 0 0 8px;
}
.cta-app-card p { font-size: 13px; color: var(--text-2); margin: 0 0 14px; }
.cta-app-card .btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--grad-app);
  color: #1a0f00;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  border: 0;
  width: 100%;
  justify-content: center;
}

/* Form añadir radio */
.request-form { display: flex; flex-direction: column; gap: 8px; }
.request-form label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.request-form input, .request-form select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.request-form input:focus, .request-form select:focus {
  border-color: var(--accent);
}
.request-form button {
  background: var(--grad-primary);
  color: #fff;
  border: 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  margin-top: 4px;
}
.form-feedback {
  font-size: 12px; margin-top: 8px; padding: 8px 10px; border-radius: 6px; text-align: center;
}
.form-feedback.ok   { background: rgba(46, 214, 135, 0.15); color: var(--success); }
.form-feedback.err  { background: rgba(255, 69, 102, 0.15); color: var(--danger); }

/* ============================================================
   BOTTOM BANNER (CTA app sutil)
============================================================ */
.bottom-banner {
  background:
    radial-gradient(circle at 0% 0%, rgba(124, 92, 255, 0.25), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(255, 184, 0, 0.18), transparent 50%),
    var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin: 40px 0 0;
  display: flex; gap: 20px; align-items: center;
  flex-wrap: wrap;
}
.bottom-banner .text { flex: 1; min-width: 220px; }
.bottom-banner h3 {
  font-family: var(--font-head);
  font-size: 22px; font-weight: 700;
  margin: 0 0 6px;
}
.bottom-banner p { color: var(--text-2); margin: 0; font-size: 14px; }
.bottom-banner .btn {
  background: var(--grad-app);
  color: #1a0f00;
  font-weight: 700;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 14px;
  border: 0;
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
}

/* ============================================================
   FOOTER
============================================================ */
.footer {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-3);
  font-size: 12px;
  margin-top: 28px;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--text-2); }

/* ============================================================
   FLOATING PLAYER
============================================================ */
.player {
  position: fixed; bottom: 16px; left: 16px; right: 16px;
  max-width: 1200px; margin: 0 auto;
  background: rgba(11, 14, 29, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow-1);
  z-index: 50;
  transform: translateY(120%);
  transition: transform .3s ease;
}
.player.is-active { transform: translateY(0); }
.player .p-logo {
  width: 44px; height: 44px;
  background: var(--surface-2);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}
.player .p-info { flex: 1; min-width: 0; }
.player .p-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .p-sub { font-size: 11px; color: var(--text-3); }
.player .p-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--grad-primary);
  border: 0; color: #fff;
  display: grid; place-items: center;
  font-size: 16px;
  cursor: pointer;
}
.player .p-vol {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-3);
}
.player .p-vol input {
  width: 100px;
  accent-color: var(--accent);
}
@media (max-width: 600px) {
  .player .p-vol { display: none; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar .select { flex: 1 1 calc(50% - 6px); }
  .toolbar .compare-btn { flex: 1 1 100%; justify-content: center; }

  .radio-card {
    grid-template-columns: 32px 48px minmax(0, 1fr);
    padding: 12px;
    gap: 10px;
  }
  .rank-num { width: 32px; font-size: 18px; }
  .radio-logo { width: 48px; height: 48px; }
  
  .radio-card .audience {
    grid-column: 1 / -1;
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border);
    text-align: left;
  }
  .radio-card .audience .l { margin-left: 8px; flex: 1; }
  .radio-card .audience .delta { margin-top: 0; }
  
  .radio-card .card-actions {
    grid-column: 1 / -1;
    display: flex; justify-content: center; gap: 12px;
    margin-top: 4px;
  }
  .card-actions .icon-btn { flex: 1; justify-content: center; border-radius: 8px; }
}

/* ============================================================
   MODAL COMPARADOR
============================================================ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(6, 8, 22, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-mask.is-open { display: flex; }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 880px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-family: var(--font-head); margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); cursor: pointer;
  display: grid; place-items: center;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
}
.chip .x { color: var(--text-3); cursor: pointer; }
.chip .x:hover { color: var(--danger); }
.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  height: 360px;
}

/* ============================================================
   TOAST
============================================================ */
.toast-stack {
  position: fixed; top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-1);
  min-width: 240px;
  animation: slidein .25s ease;
}
.toast.ok  { border-color: var(--success); }
.toast.err { border-color: var(--danger); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.btn-pill.accent-spark {
  background: var(--grad-primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(124, 92, 255, 0.4);
  border: none;
}
.btn-pill.accent-spark:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.6);
}
