/* =========================================================================
   Radio CR — estilos
   Tema oscuro, pensado para iPhone 16 (Safe Areas, Dynamic Island, barra inferior).
   ========================================================================= */

:root {
  --bg: #0B0B0F;
  --card: #19191F;
  --card-hover: #20202a;
  --accent: #E63946;
  --accent-soft: rgba(230, 57, 70, 0.14);
  --text: #FFFFFF;
  --text-dim: #9A9AA6;
  --text-faint: #6A6A75;
  --radius: 16px;
  --radius-sm: 12px;
  --mini-h: 68px;

  /* Safe areas del dispositivo (fallback a 0 en navegadores sin soporte) */
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --sa-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
               "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Encabezado ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(11,11,15,0.0) 100%);
  padding-top: calc(var(--sa-top) + 14px);
  padding-left: calc(var(--sa-left) + 20px);
  padding-right: calc(var(--sa-right) + 20px);
  padding-bottom: 8px;
  backdrop-filter: blur(8px);
}
.brand {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.brand-accent { color: var(--accent); }
.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 2px;
}
.search-wrap { margin-top: 14px; }
.search {
  width: 100%;
  background: var(--card);
  border: 1px solid #26262f;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px; /* 16px evita el zoom automático de iOS al enfocar */
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s ease;
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--text-faint); }

/* ---------- Contenido ---------- */

.content {
  padding: 8px calc(var(--sa-right) + 20px) 24px calc(var(--sa-left) + 20px);
  /* Deja espacio para el mini-reproductor cuando está visible */
  padding-bottom: calc(var(--sa-bottom) + 24px);
}
body.has-mini .content {
  padding-bottom: calc(var(--sa-bottom) + var(--mini-h) + 28px);
}

.section { margin-top: 18px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.list { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--text-faint); font-size: 14px; padding: 16px 0; }

/* ---------- Tarjeta de emisora ---------- */

.card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.08s ease;
  user-select: none;
}
.card[role="button"]:active { transform: scale(0.99); }
.card--active { border-color: var(--accent); background: var(--card-hover); }
.card--pending { opacity: 0.55; }

.card-info { flex: 1; min-width: 0; }
.card-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-right { flex-shrink: 0; display: flex; align-items: center; }

/* ---------- Logo / monograma ---------- */

.logo {
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2a2a34;
}
.logo img { width: 100%; height: 100%; object-fit: cover; }
.logo-text {
  font-weight: 700;
  color: #fff;
  font-size: 1.1em;
  letter-spacing: 0.5px;
}

/* ---------- Indicadores ---------- */

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
}
.tag--pending { background: #2a2a34; color: var(--text-faint); }

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3a3a44;
  display: inline-block;
}
.card--sounding .live-dot {
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(230,57,70,0.6); }
  70%  { box-shadow: 0 0 0 7px rgba(230,57,70,0); }
  100% { box-shadow: 0 0 0 0 rgba(230,57,70,0); }
}

/* ---------- Botones de reproducción ---------- */

.btn-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.08s ease, background 0.2s ease;
}
.btn-toggle:active { transform: scale(0.92); }
.btn-toggle--big { width: 76px; height: 76px; font-size: 26px; }

/* Spinner de carga/buffering dentro del botón */
.btn-toggle.is-busy {
  background: var(--accent-soft);
  position: relative;
}
.btn-toggle.is-busy::after {
  content: "";
  width: 44%;
  height: 44%;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mini-reproductor ---------- */

.mini {
  position: fixed;
  left: calc(var(--sa-left) + 12px);
  right: calc(var(--sa-right) + 12px);
  bottom: calc(var(--sa-bottom) + 12px);
  height: var(--mini-h);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(25,25,31,0.92);
  backdrop-filter: blur(16px);
  border: 1px solid #2a2a34;
  border-radius: 18px;
  padding: 0 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.mini-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  padding: 8px 0;
  color: inherit;
  text-align: left;
}
.mini-logo { width: 44px; height: 44px; flex-shrink: 0; }
.mini-logo .logo { width: 44px; height: 44px; }
.mini-texts { min-width: 0; display: flex; flex-direction: column; }
.mini-name {
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-status { font-size: 12px; color: var(--text-dim); }

/* ---------- Reproductor ampliado (hoja deslizante) ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: linear-gradient(180deg, #16161d 0%, var(--bg) 60%);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet.is-open { transform: translateY(0); }
.sheet-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--sa-top) + 14px) calc(var(--sa-right) + 24px)
           calc(var(--sa-bottom) + 28px) calc(var(--sa-left) + 24px);
}
.sheet-close {
  align-self: center;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 30px;
  line-height: 1;
  padding: 4px 24px;
  margin-bottom: 8px;
}
.player-logo {
  margin-top: 4vh;
  width: min(66vw, 260px);
  height: min(66vw, 260px);
  display: flex;
}
.player-logo .logo {
  width: 100%; height: 100%;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.player-logo .logo-text { font-size: 64px; }

.player-head { text-align: center; margin-top: 28px; }
.player-name { font-size: 26px; font-weight: 800; letter-spacing: -0.4px; }
.player-freq { color: var(--text-dim); font-size: 15px; margin-top: 4px; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 5px 12px;
  border-radius: 999px;
}
.live-badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s infinite;
}

.player-status {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 16px;
  min-height: 20px;
  text-align: center;
}

.player-controls {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 28px;
}
.btn-ghost {
  background: none;
  border: none;
  color: var(--text);
  font-size: 26px;
  opacity: 0.85;
  padding: 10px;
  transition: opacity 0.15s ease, transform 0.08s ease;
}
.btn-ghost:active { transform: scale(0.9); opacity: 1; }

.btn-fav {
  margin-top: 26px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid #2a2a34;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.btn-fav .heart { font-size: 16px; }
.btn-fav.is-fav { color: var(--accent); border-color: var(--accent); }

/* ---------- Respeto a "reducir movimiento" ---------- */
@media (prefers-reduced-motion: reduce) {
  .card--sounding .live-dot, .live-badge-dot { animation: none; }
  .btn-toggle.is-busy::after { animation-duration: 1.4s; }
  .sheet { transition: none; }
}
