/* ============================================================
   MiVoz.pe – Estilos principales
   HTML + CSS + JavaScript. Tema oscuro, glassmorphism, responsive.
   ============================================================ */

:root {
  --bg-main: #000000;
  --slate-950: rgb(2, 6, 23);
  --slate-900: rgb(15, 23, 42);
  --slate-800: rgb(30, 41, 59);
  --slate-700: rgb(51, 65, 85);
  --slate-400: rgb(148, 163, 184);
  --slate-300: rgb(203, 213, 225);
  --blue: #2563eb;
  --blue-hover: #3b82f6;
  --red-live: #dc2626;
  --white: #ffffff;
  --glass-bg: rgba(15, 23, 42, 0.6);
  --glass-border: rgba(71, 85, 105, 0.5);
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.5rem;
  --radius-full: 9999px;
  --transition: all 0.3s ease;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --focus-outline: 4px solid var(--blue);
}

@media (min-width: 1921px) {
  :root { font-size: 20px; }
  .hud__btn { min-width: 56px; min-height: 56px; }
  *:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  color: var(--white);
  background: var(--bg-main);
  -webkit-tap-highlight-color: transparent;
}

body:not(.user-is-tabbing) *:focus { outline: none; }
*:focus-visible { outline: var(--focus-outline); outline-offset: 2px; }

#app { position: fixed; inset: 0; width: 100%; height: 100%; }

/* Splash */
.splash {
  position: absolute; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--slate-950) 0%, var(--slate-900) 50%, var(--slate-950) 100%);
  opacity: 1; transition: opacity 0.5s ease;
}
.splash.splash--hidden { opacity: 0; pointer-events: none; }
.splash__inner { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.splash__logo-wrap { position: relative; width: 5rem; height: 5rem; display: flex; align-items: center; justify-content: center; }
.splash__spinner {
  position: absolute; inset: 0;
  border: 4px solid rgba(37, 99, 235, 0.3); border-top-color: var(--blue);
  border-radius: 50%; animation: splash-spin 2s linear infinite;
}
.splash__emoji { position: relative; z-index: 1; font-size: 2.5rem; }
.splash__title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.splash__loading { font-size: 1rem; color: var(--slate-400); animation: pulse 1.5s ease-in-out infinite; }
@keyframes splash-spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Player */
.player-wrap { position: absolute; inset: 0; background: var(--bg-main); }
.video-section { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.buffer-indicator {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.buffer-indicator.buffer-indicator--visible { opacity: 1; }
.buffer-indicator__spinner {
  width: 48px; height: 48px; border: 4px solid var(--glass-border); border-top-color: var(--blue);
  border-radius: 50%; animation: splash-spin 1s linear infinite;
}
.buffer-indicator__logo { font-size: 2rem; }

.error-state {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  background: rgba(0, 0, 0, 0.9); opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.error-state.error-state--visible { opacity: 1; pointer-events: auto; }
.error-state__text { font-size: 1rem; color: var(--slate-300); }
.error-state__btn {
  padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 600; color: var(--white); background: var(--blue);
  border: none; border-radius: var(--radius-md); cursor: pointer; transition: var(--transition);
}
.error-state__btn:hover { background: var(--blue-hover); }

/* HUD */
.hud {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none; opacity: 1; transition: opacity 0.3s ease;
}
.hud .hud__top, .hud .hud__bottom { pointer-events: auto; }
.hud.hud--hidden { opacity: 0; pointer-events: none; }

.hud__top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
}
.hud__channel-info { display: flex; align-items: center; gap: 0.75rem; }
.hud__channel-logo { font-size: 1.75rem; line-height: 1; }
.hud__channel-text { display: flex; flex-direction: column; gap: 0.15rem; }
.hud__channel-name { font-size: 1.25rem; font-weight: 600; }
.hud__channel-category { font-size: 0.875rem; color: var(--slate-400); }
.hud__live-badge {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.6rem;
  font-size: 0.75rem; font-weight: 700; color: var(--white); background: var(--red-live);
  border-radius: var(--radius-full); text-transform: uppercase; letter-spacing: 0.02em;
}
.hud__live-pulse { width: 6px; height: 6px; background: var(--white); border-radius: 50%; animation: live-pulse 1.5s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.2); opacity: 0.8; } }
.hud__clock { font-size: 0.875rem; font-variant-numeric: tabular-nums; color: var(--slate-300); }

.hud__bottom {
  padding: 1rem 1.25rem; background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--glass-border); box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
}
.hud__controls { display: flex; align-items: center; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.hud__btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0;
  color: var(--white); background: transparent; border: none; border-radius: 50%; cursor: pointer; transition: var(--transition);
}
.hud__btn:hover { background: rgba(255, 255, 255, 0.1); }
.hud__btn--play { width: 52px; height: 52px; min-width: 52px; min-height: 52px; background: var(--blue); color: var(--white); }
.hud__btn--play:hover { background: var(--blue-hover); }
.hud__icon { width: 24px; height: 24px; flex-shrink: 0; }
.hud__icon--play, .hud__icon--pause { display: none; }
.hud__btn[data-playing="true"] .hud__icon--pause { display: block; }
.hud__btn[data-playing="false"] .hud__icon--play { display: block; }

.hud__volume-wrap { position: relative; display: flex; align-items: center; }
.hud__volume-slider-wrap { width: 0; overflow: hidden; opacity: 0; transition: width 0.2s ease, opacity 0.2s ease; }
.hud__volume-wrap:hover .hud__volume-slider-wrap { width: 120px; opacity: 1; margin-left: 0.5rem; }
.hud__volume-slider {
  width: 100%; height: 6px; -webkit-appearance: none; appearance: none;
  background: rgba(255, 255, 255, 0.3); border-radius: var(--radius-full);
}
.hud__volume-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; background: var(--white); border-radius: 50%; cursor: pointer; }
.hud__volume-slider::-moz-range-thumb { width: 14px; height: 14px; background: var(--white); border-radius: 50%; cursor: pointer; border: none; }
.hud__icon--mute { display: none; }
.hud__volume-wrap[data-muted="true"] .hud__icon--volume { display: none; }
.hud__volume-wrap[data-muted="true"] .hud__icon--mute { display: block; }

/* Autoplay overlay */
.autoplay-overlay {
  position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.autoplay-overlay.autoplay-overlay--visible { opacity: 1; pointer-events: auto; }
.autoplay-overlay__btn {
  display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1.5rem 2rem;
  font-size: 1.25rem; font-weight: 600; color: var(--white); background: var(--blue); border: none;
  border-radius: var(--radius-lg); cursor: pointer; transition: var(--transition); box-shadow: 0 8px 32px rgba(37, 99, 235, 0.4);
}
.autoplay-overlay__btn:hover { background: var(--blue-hover); transform: scale(1.02); }
.autoplay-overlay__icon { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.2); border-radius: 50%; }
.autoplay-overlay__icon svg { width: 32px; height: 32px; margin-left: 4px; }

/* Lista de canales */
.channel-backdrop {
  position: absolute; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.channel-backdrop.channel-backdrop--visible { opacity: 1; pointer-events: auto; }

.channel-list {
  position: fixed; top: 0; right: 0; z-index: 70; width: 100%; max-width: 520px; height: 100%; max-height: 100vh;
  display: flex; flex-direction: column; background: rgba(2, 6, 23, 0.95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid var(--glass-border); box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1); overflow: hidden;
}
.channel-list.channel-list--open { transform: translateX(0); }
.channel-list__handle { display: none; width: 40px; height: 4px; margin: 0.5rem auto; background: var(--slate-700); border-radius: var(--radius-full); }
.channel-list__header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--glass-border); }
.channel-list__title { font-size: 1.5rem; font-weight: 700; }
.channel-list__close {
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0;
  color: var(--slate-300); background: transparent; border: none; border-radius: 50%; cursor: pointer; transition: var(--transition);
}
.channel-list__close:hover { background: rgba(255, 255, 255, 0.1); color: var(--white); }
.channel-list__close svg { width: 24px; height: 24px; }
.channel-list__search-wrap { position: relative; padding: 0 1.5rem 1rem; }
.channel-list__search-icon { position: absolute; left: 2rem; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--slate-400); pointer-events: none; }
.channel-list__search {
  width: 100%; padding: 0.75rem 1rem 0.75rem 2.75rem; font-size: 1rem; color: var(--white);
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--glass-border); border-radius: var(--radius-md); transition: var(--transition);
}
.channel-list__search::placeholder { color: var(--slate-400); }
.channel-list__search:focus { outline: none; border-color: var(--blue); background: rgba(255, 255, 255, 0.1); }
.channel-list__categories { padding: 0 1.5rem 1rem; }
.channel-list__chips { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.25rem; scrollbar-width: none; -ms-overflow-style: none; }
.channel-list__chips::-webkit-scrollbar { display: none; }
.channel-list__chip {
  flex-shrink: 0; padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; color: var(--slate-300);
  background: rgba(255, 255, 255, 0.08); border: none; border-radius: var(--radius-full); cursor: pointer; transition: var(--transition);
}
.channel-list__chip:hover { background: rgba(255, 255, 255, 0.12); color: var(--white); }
.channel-list__chip.channel-list__chip--active { background: var(--blue); color: var(--white); }
.channel-list__scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 1.5rem 1.5rem; }
.channel-list__items { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.channel-list__item {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-radius: var(--radius-md);
  cursor: pointer; transition: var(--transition); border: 2px solid transparent;
}
.channel-list__item:hover { background: rgba(255, 255, 255, 0.06); }
.channel-list__item.channel-list__item--active { background: var(--blue); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); }
.channel-list__item-logo { font-size: 1.75rem; line-height: 1; }
.channel-list__item-info { flex: 1; min-width: 0; }
.channel-list__item-name { font-size: 1rem; font-weight: 600; margin-bottom: 0.15rem; }
.channel-list__item-meta { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--slate-400); }
.channel-list__item--active .channel-list__item-meta { color: rgba(255, 255, 255, 0.9); }
.channel-list__item-live { font-size: 0.7rem; font-weight: 700; color: var(--red-live); text-transform: uppercase; }

@media (max-width: 767px) {
  .channel-list { top: auto; right: 0; left: 0; max-width: none; max-height: 85vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-left: none; border-top: 1px solid var(--glass-border); transform: translateY(100%); }
  .channel-list.channel-list--open { transform: translateY(0); }
  .channel-list__handle { display: block; }
}
@media (min-width: 768px) and (max-width: 1024px) { .channel-list { max-width: 480px; } }

/* Gesture hint */
.gesture-hint {
  position: fixed; bottom: 6rem; left: 50%; transform: translateX(-50%) translateY(10px); z-index: 80;
  padding: 0.75rem 1.25rem; font-size: 0.875rem; color: var(--white); background: var(--glass-bg);
  backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease;
}
.gesture-hint.gesture-hint--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.gesture-hint__text { margin: 0; text-align: center; max-width: 320px; }
@media (min-width: 768px) { .gesture-hint { display: none; } }

/* Toasts */
.toast-container { position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; pointer-events: none; }
.toast {
  padding: 0.75rem 1.25rem; font-size: 0.9375rem; color: var(--white); background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); animation: toast-in 0.3s ease; max-width: 90vw;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast.toast--out { animation: toast-out 0.25s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }
