/* =========================================================
   RC RADIO TV ECUADOR — "Tu Radio Balzareña"
   Tokens de marca
   ========================================================= */
:root {
  /* Color */
  --rojo-vivo: #e4002b;
  --amarillo-sol: #ffc72c;
  --azul-profundo: #0b3c8c;
  --azul-noche: #041b4d;
  --azul-noche-2: #071f3f;
  --crema-arena: #fff8ec;
  --carbon: #15141a;
  --carbon-suave: #2a2836;

  --gradiente-marca: linear-gradient(135deg, var(--rojo-vivo) 0%, var(--amarillo-sol) 50%, var(--azul-profundo) 100%);
  --gradiente-marca-suave: linear-gradient(135deg, rgba(228,0,43,.16) 0%, rgba(255,199,44,.16) 50%, rgba(11,60,140,.16) 100%);

  /* Tipografía */
  --f-display: "Fredoka", "Trebuchet MS", sans-serif;
  --f-body: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout */
  --radio-radius: 26px;
  --tab-bar-h: 68px;
  --miniplayer-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --sombra-flotante: 0 12px 30px -8px rgba(4, 27, 77, 0.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--f-body);
  background: var(--carbon);
  color: var(--crema-arena);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

h1, h2, h3, .display {
  font-family: var(--f-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

button, input, select {
  font-family: inherit;
}

a { color: inherit; }

::selection { background: var(--amarillo-sol); color: var(--carbon); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--amarillo-sol);
  outline-offset: 3px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* =========================================================
   SPLASH
   ========================================================= */
#splash {
  position: fixed; inset: 0;
  z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
  background: var(--gradiente-marca);
  background-size: 220% 220%;
  animation: gradienteVivo 9s ease infinite;
  transition: opacity .5s ease, visibility .5s ease;
  padding: 24px;
  text-align: center;
}

#splash.oculto { opacity: 0; visibility: hidden; pointer-events: none; }

@keyframes gradienteVivo {
  0%   { background-position: 0% 30%; }
  50%  { background-position: 100% 70%; }
  100% { background-position: 0% 30%; }
}

.splash-logo {
  width: min(68vw, 300px);
  height: auto;
  filter: drop-shadow(0 12px 26px rgba(4,27,77,.5));
  animation: latido 2.4s ease-in-out infinite;
}

@keyframes latido {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

.splash-marca {
  font-size: clamp(22px, 6vw, 30px);
  color: var(--crema-arena);
  text-shadow: 0 2px 10px rgba(4,27,77,.5);
  line-height: 1.15;
}

.splash-slogan {
  font-family: var(--f-body);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--azul-noche);
  background: var(--crema-arena);
  padding: 6px 16px;
  border-radius: 999px;
}

.splash-ondas {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 34px;
  margin-top: 4px;
}

.splash-ondas span {
  width: 5px;
  border-radius: 3px;
  background: var(--crema-arena);
  animation: onda 1.1s ease-in-out infinite;
  opacity: .95;
}
.splash-ondas span:nth-child(1) { height: 12px; animation-delay: -1.0s; }
.splash-ondas span:nth-child(2) { height: 24px; animation-delay: -0.8s; }
.splash-ondas span:nth-child(3) { height: 34px; animation-delay: -0.6s; }
.splash-ondas span:nth-child(4) { height: 18px; animation-delay: -0.4s; }
.splash-ondas span:nth-child(5) { height: 28px; animation-delay: -0.2s; }
.splash-ondas span:nth-child(6) { height: 14px; animation-delay: 0s; }

@keyframes onda {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

.splash-carga {
  width: 140px; height: 4px;
  border-radius: 4px;
  background: rgba(4,27,77,.25);
  overflow: hidden;
  margin-top: 6px;
}
.splash-carga::after {
  content: "";
  display: block;
  width: 40%; height: 100%;
  background: var(--azul-noche);
  border-radius: 4px;
  animation: cargaBarra 1.3s ease-in-out infinite;
}
@keyframes cargaBarra {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* =========================================================
   APP SHELL
   ========================================================= */
#app {
  min-height: 100%;
  display: none;
  flex-direction: column;
  background: radial-gradient(circle at 50% -10%, var(--azul-noche-2) 0%, var(--carbon) 55%);
}
#app.visible { display: flex; }

.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  background: rgba(21,20,26,.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.app-header__logo {
  width: 38px; height: 38px; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,199,44,.6);
  flex-shrink: 0;
}

.app-header__text { flex: 1; min-width: 0; }
.app-header__title {
  font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header__slogan {
  font-size: 11px;
  letter-spacing: .6px;
  color: var(--amarillo-sol);
  text-transform: uppercase;
  font-weight: 700;
}

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--crema-arena);
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.icon-btn:hover { background: rgba(255,255,255,.14); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 19px; height: 19px; }

/* Views */
.view {
  display: none;
  flex: 1;
  padding: 22px 18px calc(var(--tab-bar-h) + var(--miniplayer-h) + 30px);
  animation: entrar .35s ease;
}
.view.activa { display: block; }

@keyframes entrar {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- INICIO: Dial tricolor (elemento firma) ---------- */
.dial-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 0 8px;
}

.pill-vivo {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--rojo-vivo);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.2px;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 22px;
}
.pill-vivo__punto {
  width: 7px; height: 7px; border-radius: 50%;
  background: #fff;
  animation: parpadeo 1.4s ease-in-out infinite;
}
@keyframes parpadeo { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.dial {
  position: relative;
  width: min(64vw, 260px);
  height: min(64vw, 260px);
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--rojo-vivo), var(--amarillo-sol), var(--azul-profundo), var(--rojo-vivo));
  padding: 8px;
  box-shadow: var(--sombra-flotante);
}
.dial.reproduciendo { animation: giroLento 18s linear infinite; }
@keyframes giroLento { to { transform: rotate(360deg); } }

.dial__nucleo {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 38% 30%, var(--azul-noche-2), var(--azul-noche) 75%);
}

/* Logo real del cliente: se muestra completo (contain), sin recortar,
   centrado y con espacio reservado abajo para el ecualizador */
.dial__logo-wrap {
  position: absolute;
  inset: 4% 14% 24% 14%;
  display: flex; align-items: center; justify-content: center;
}
.dial__logo {
  width: 100%;
  height: auto;
  display: block;
  transform-origin: 50% 50%;
  transform: scale(1);
  will-change: transform;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.45));
}

.dial__ecualizador {
  position: absolute;
  bottom: 13%;
  left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 4px;
  height: 18px;
}
.dial__ecualizador span {
  width: 4px; border-radius: 2px;
  background: var(--amarillo-sol);
  height: 5px;
}

.btn-play {
  position: absolute;
  top: 42%; left: 50%;
  transform: translate(-50%, -50%);
  width: 64px; height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--crema-arena);
  color: var(--azul-noche);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0,0,0,.4), 0 0 0 10px rgba(4,27,77,.35);
  transition: transform .15s ease;
}
.btn-play:active { transform: translate(-50%, -50%) scale(.94); }
.btn-play svg { width: 26px; height: 26px; margin-left: 2px; }
.btn-play.esperando svg { margin-left: 0; }

.dial-estado {
  margin-top: 18px;
  font-size: 13px;
  color: rgba(255,248,236,.65);
  text-align: center;
  min-height: 18px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.dial-config-aviso {
  margin-top: 14px;
  font-size: 12px;
  text-align: center;
  color: var(--amarillo-sol);
  background: rgba(255,199,44,.1);
  border: 1px dashed rgba(255,199,44,.4);
  border-radius: 12px;
  padding: 10px 14px;
  max-width: 320px;
}

/* ---------- Grid de accesos rápidos ---------- */
.seccion-titulo {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,248,236,.55);
  margin: 34px 0 14px;
}

.grid-accesos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.acceso {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 8px;
  border-radius: 18px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.07);
  text-decoration: none;
  color: var(--crema-arena);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.acceso:hover { background: rgba(255,255,255,.09); }
.acceso:active { transform: scale(.95); }

.acceso__icono {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: grid; place-items: center;
}
.acceso__icono svg { width: 22px; height: 22px; }

.acceso--tv .acceso__icono       { background: linear-gradient(135deg, var(--azul-profundo), var(--azul-noche)); color: var(--crema-arena); }
.acceso--whatsapp .acceso__icono { background: #25d366; color: #04210f; }
.acceso--facebook .acceso__icono { background: #1877f2; color: #fff; }
.acceso--tiktok .acceso__icono   { background: var(--carbon); color: var(--crema-arena); border: 1px solid rgba(255,255,255,.15); }
.acceso--youtube .acceso__icono  { background: #ff0033; color: #fff; }
.acceso--compartir .acceso__icono{ background: linear-gradient(135deg, var(--rojo-vivo), var(--amarillo-sol)); color: var(--azul-noche); }

/* ---------- TV VIEW ---------- */
.tv-marco {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radio-radius);
  overflow: hidden;
  background: var(--azul-noche-2);
  box-shadow: var(--sombra-flotante);
  display: flex; align-items: center; justify-content: center;
}
.tv-marco iframe, .tv-marco video {
  width: 100%; height: 100%; border: 0; display: block;
}

.tv-vacio {
  text-align: center; padding: 30px 20px;
  color: rgba(255,248,236,.7);
  font-size: 13px;
  max-width: 280px;
}
.tv-vacio strong { color: var(--amarillo-sol); display: block; margin-bottom: 6px; font-family: var(--f-display); font-size: 15px; }

.tv-acciones {
  display: flex; gap: 10px; margin-top: 16px;
}
.btn-secundario {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  color: var(--crema-arena);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-secundario svg { width: 16px; height: 16px; }

/* ---------- COMUNIDAD VIEW ---------- */
.lista-comunidad { display: flex; flex-direction: column; gap: 12px; }
.fila-comunidad {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.07);
  text-decoration: none;
  color: var(--crema-arena);
}
.fila-comunidad__icono {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
}
.fila-comunidad__icono svg { width: 20px; height: 20px; }
.fila-comunidad__texto { flex: 1; min-width: 0; }
.fila-comunidad__titulo { font-weight: 700; font-size: 14px; }
.fila-comunidad__sub { font-size: 12px; color: rgba(255,248,236,.55); }
.fila-comunidad__flecha { opacity: .5; }

/* ---------- AJUSTES VIEW ---------- */
.tarjeta {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 18px;
  padding: 6px;
  margin-bottom: 16px;
}
.opcion {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.opcion:last-child { border-bottom: none; }
.opcion__icono {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gradiente-marca-suave);
  flex-shrink: 0;
}
.opcion__icono svg { width: 18px; height: 18px; }
.opcion__texto { flex: 1; }
.opcion__titulo { font-size: 14px; font-weight: 700; }
.opcion__sub { font-size: 12px; color: rgba(255,248,236,.5); margin-top: 2px; }

.switch {
  position: relative; width: 46px; height: 26px; flex-shrink: 0;
}
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch__track {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(255,255,255,.18);
  transition: background .2s ease;
}
.switch__track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--crema-arena);
  transition: transform .2s ease;
}
.switch input:checked ~ .switch__track { background: var(--azul-profundo); }
.switch input:checked ~ .switch__track::after { transform: translateX(20px); background: var(--amarillo-sol); }

.btn-primario {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  background: var(--gradiente-marca);
  color: var(--azul-noche);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primario svg { width: 17px; height: 17px; }

.acerca-de {
  text-align: center;
  font-size: 12px;
  color: rgba(255,248,236,.4);
  padding: 10px 0 4px;
  line-height: 1.6;
}

/* =========================================================
   MINI PLAYER
   ========================================================= */
.mini-player {
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 8px);
  height: var(--miniplayer-h);
  border-radius: 18px;
  background: rgba(7, 31, 63, 0.92);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: var(--sombra-flotante);
  display: flex; align-items: center; gap: 12px;
  padding: 0 10px 0 12px;
  z-index: 45;
  transform: translateY(120%);
  transition: transform .3s ease;
}
.mini-player.mostrar { transform: translateY(0); }

.mini-player__disco-giro {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,199,44,.5);
  overflow: hidden;
}
.mini-player__disco-giro.girando { animation: girarDisco 3.5s linear infinite; }
@keyframes girarDisco { to { transform: rotate(360deg); } }

.mini-player__disco {
  width: 100%; height: 100%;
  display: block;
  object-fit: cover;
  transform-origin: 50% 50%;
  transform: scale(1);
  will-change: transform;
}

.mini-player__texto { flex: 1; min-width: 0; }
.mini-player__titulo { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-player__sub { font-size: 11px; color: var(--amarillo-sol); }

.mini-player__btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: var(--crema-arena); color: var(--azul-noche);
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.mini-player__btn svg { width: 18px; height: 18px; }

/* =========================================================
   TAB BAR
   ========================================================= */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-bar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(21,20,26,.85);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-top: 1px solid rgba(255,255,255,.07);
  z-index: 50;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  border: none; background: none; cursor: pointer;
  color: rgba(255,248,236,.5);
  font-size: 10.5px;
  font-weight: 700;
  padding-top: 4px;
}
.tab svg { width: 21px; height: 21px; }
.tab.activo { color: var(--amarillo-sol); }
.tab__punto {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--amarillo-sol);
  opacity: 0;
  margin-top: -2px;
}
.tab.activo .tab__punto { opacity: 1; }

/* =========================================================
   TOAST
   ========================================================= */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 16px);
  transform: translate(-50%, 20px);
  background: var(--crema-arena);
  color: var(--azul-noche);
  font-size: 13px;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--sombra-flotante);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 200;
  max-width: 88vw;
  text-align: center;
}
#toast.mostrar { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   Responsive: pantallas más anchas (tablet / desktop)
   ========================================================= */
@media (min-width: 640px) {
  #app { align-items: center; }
  .app-header, .view { width: 100%; max-width: 460px; }
  .mini-player, .tab-bar { max-width: 460px; left: 50%; transform: translateX(-50%); }
  .mini-player.mostrar { transform: translate(-50%, 0); }
  .tab-bar { border-radius: 22px 22px 0 0; }
}
