/* ================================================
   StreamTP — Agenda Deportiva
   Design System & Styles
   ================================================ */

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d14;
  --bg2:       #13131f;
  --bg3:       #1a1a2e;
  --surface:   #1e1e30;
  --surface2:  #252540;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);

  --primary:   #4f46e5;
  --primary-h: #6366f1;
  --accent:    #06b6d4;
  --live:      #10b981;
  --soon:      #3b82f6;
  --done:      #475569;
  --gold:      #f59e0b;

  --text:      #f0f0f8;
  --text-2:    #a0a0c0;
  --text-3:    #6b6b8a;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --font:      'Outfit', 'Segoe UI', system-ui, sans-serif;

  --shadow-glow: 0 0 30px rgba(79,70,229,0.15);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

img { display: block; border-radius: 3px; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
a { text-decoration: none; color: inherit; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

/* ================================================
   HEADER
   ================================================ */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 64px;
  background: rgba(13,13,20,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.5px;
}
.logo-icon {
  font-size: 1.3rem;
  color: var(--primary-h);
  filter: drop-shadow(0 0 8px var(--primary));
}
.logo-text strong { color: var(--accent); }

.header-meta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--live);
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.25);
  padding: 5px 12px;
  border-radius: 999px;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.header-clock {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

/* ================================================
   HERO
   ================================================ */
.hero {
  position: relative;
  padding: 120px 24px 60px;
  text-align: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 0%, rgba(79,70,229,0.22) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 50%, rgba(6,182,212,0.1) 0%, transparent 60%);
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 60%, var(--primary-h) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 14px;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-2);
  margin-bottom: 20px;
}

.hero-flags {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.hero-flags img {
  width: 28px;
  height: 20px;
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.2s;
}
.hero-flags img:hover { opacity: 1; transform: scale(1.1); }

/* ================================================
   TOOLBAR
   ================================================ */
.toolbar {
  position: sticky;
  top: 64px;
  z-index: 90;
  background: rgba(13,13,20,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.toolbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Search */
.search-wrap {
  position: relative;
  max-width: 540px;
  width: 100%;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 11px 44px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.97rem;
  font-family: var(--font);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.18);
}
.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 0.85rem;
  padding: 4px;
  border-radius: 50%;
  transition: color 0.2s;
}
.search-clear:hover { color: var(--text); }

/* Categories */
.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.categories::-webkit-scrollbar { display: none; }

.cat-btn {
  white-space: nowrap;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.2s;
  flex-shrink: 0;
}
.cat-btn:hover {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border2);
  transform: translateY(-1px);
}
.cat-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 16px rgba(79,70,229,0.35);
}

/* ================================================
   MAIN CONTENT
   ================================================ */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 60px;
}

/* Stats bar */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.stats-count {
  font-size: 0.9rem;
  color: var(--text-2);
  font-weight: 600;
}
.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  transition: all 0.2s;
}
.refresh-btn:hover { color: var(--accent); border-color: var(--accent); }
.refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================
   EVENTS GRID
   ================================================ */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

/* ---- SKELETON ---- */
.skeleton-wrap {
  display: contents;
}
.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid var(--border);
}
.sk-head {
  height: 52px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 16px;
}
.sk-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 10px;
}
.sk-line.l1 { width: 70%; }
.sk-line.l2 { width: 45%; }
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ---- EVENT CARD ---- */
.event-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  cursor: pointer;
  position: relative;
}
.event-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card), 0 0 24px rgba(79,70,229,0.12);
  border-color: var(--border2);
}
.event-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Card accent strip */
.event-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity 0.25s;
}
.event-card:hover::before { opacity: 1; }
.event-card.is-live::before { opacity: 1; background: linear-gradient(90deg, var(--live), #059669); }

/* Card header */
.card-header {
  padding: 18px 18px 14px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.card-flags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.card-flag {
  width: 36px;
  height: 25px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.card-vs {
  font-size: 0.65rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.5px;
}
.card-info { flex: 1; min-width: 0; }
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.card-time {
  font-size: 0.82rem;
  color: var(--text-2);
  font-weight: 600;
}
.card-cat {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  background: rgba(6,182,212,0.1);
  border: 1px solid rgba(6,182,212,0.2);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Card body - stream count */
.card-body {
  padding: 0 18px 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-streams-info {
  font-size: 0.83rem;
  color: var(--text-3);
  font-weight: 600;
}
.card-links-preview {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

/* Language/quality mini badges */
.mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.mini-badge img {
  width: 14px; height: 10px;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.mb-es { background: rgba(46,204,113,0.12); color: #2ecc71; border: 1px solid rgba(46,204,113,0.25); }
.mb-us { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.25); }
.mb-br { background: rgba(251,191,36,0.12); color: #fbbf24; border: 1px solid rgba(251,191,36,0.25); }
.mb-other { background: rgba(148,163,184,0.1); color: #94a3b8; border: 1px solid rgba(148,163,184,0.2); }

/* Card CTA */
.card-cta {
  padding: 0 18px 18px;
}
.card-watch-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font);
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-h));
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
  border: none;
}
.card-watch-btn:hover {
  background: linear-gradient(135deg, var(--primary-h), var(--accent));
  box-shadow: 0 6px 20px rgba(79,70,229,0.45);
  transform: translateY(-1px);
}
.card-watch-btn.is-live-btn {
  background: linear-gradient(135deg, var(--live), #059669);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}

/* Live pulse indicator on card */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--live);
}
.live-indicator-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

/* ================================================
   EMPTY / ERROR STATES
   ================================================ */
.no-results, .error-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}
.no-results-icon, .error-icon { font-size: 3rem; display: block; margin-bottom: 16px; }
.no-results p, .error-state p { font-size: 1rem; margin-bottom: 20px; }
.btn-secondary {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border2);
  transition: all 0.2s;
}
.btn-secondary:hover { background: var(--surface); border-color: var(--primary); color: var(--primary-h); }

/* ================================================
   MODAL
   ================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  background: var(--bg3);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border2);
  width: 100%;
  max-width: 900px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7), var(--shadow-glow);
  animation: modal-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(79,70,229,0.08) 0%, transparent 100%);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.modal-flags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.modal-flag {
  width: 44px; height: 30px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.modal-vs {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--gold);
}

.modal-event-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
}
.modal-event-time {
  font-size: 0.85rem;
  color: var(--text-2);
  font-weight: 600;
}

.modal-close-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text-2);
  font-size: 1rem;
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.modal-close-btn:hover { background: #ef4444; color: #fff; border-color: #ef4444; }

.modal-body { padding: 20px 22px 24px; }

/* Stream selector */
.selector-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 14px;
}

.stream-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stream-option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}
.stream-option-btn:hover {
  background: var(--surface2);
  border-color: var(--primary);
  transform: translateX(3px);
}

.sopt-lang-flag {
  width: 28px; height: 20px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}

.sopt-info { flex: 1; min-width: 0; }
.sopt-server {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.sopt-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.q-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
}
.qb-sd { background: rgba(148,163,184,0.12); color: #94a3b8; border: 1px solid rgba(148,163,184,0.2); }
.qb-hd { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.qb-fhd { background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.2); }
.qb-4k { background: rgba(245,158,11,0.12); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
}
.sb-live { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.25); }
.sb-pronto, .sb-next { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.25); }
.sb-finished { background: rgba(71,85,105,0.12); color: #64748b; border: 1px solid rgba(71,85,105,0.25); }

.sopt-bitrate {
  font-size: 0.7rem;
  color: var(--text-3);
}

.sopt-arrow {
  color: var(--primary-h);
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Player wrap */
.player-wrap { }

.player-top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.player-back-btn {
  font-size: 0.88rem;
  font-weight: 700;
  font-family: var(--font);
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  transition: all 0.2s;
}
.player-back-btn:hover { color: var(--text); border-color: var(--border2); }

.player-current-label {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-2);
}

.player-fullscreen-btn {
  font-size: 1.2rem;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  transition: all 0.2s;
}
.player-fullscreen-btn:hover { color: var(--accent); border-color: var(--accent); }

.iframe-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
}
.iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ================================================
   FOOTER
   ================================================ */
.footer {
  text-align: center;
  padding: 28px 24px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.85rem;
  line-height: 1.8;
}
.footer-note { font-size: 0.78rem; opacity: 0.6; }

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 768px) {
  .hero { padding: 90px 16px 40px; }
  .hero h1 { font-size: 2.2rem; }

  .toolbar-inner { padding: 0 16px; }
  .search-wrap { max-width: 100%; }

  .main-content { padding: 16px 16px 48px; }
  .events-grid { grid-template-columns: 1fr; gap: 14px; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-panel {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 95vh;
  }
  @keyframes modal-in {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .header-inner { padding: 0 16px; }
  .header-clock { display: none; }
}

@media (max-width: 480px) {
  .logo-text { font-size: 1.2rem; }
  .live-badge { font-size: 0.65rem; padding: 4px 10px; }
  .cat-btn { padding: 7px 14px; font-size: 0.83rem; }
}
