/* ============================================
   TVMama — Modern Live TV Streaming UI
   ============================================ */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #11162a;
  --bg-card: #161d36;
  --bg-card-hover: #1d2649;
  --border: #232b48;
  --text-primary: #f5f7fa;
  --text-secondary: #a3acc2;
  --text-muted: #6b7494;
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --accent-2: #8b5cf6;
  --accent-3: #06b6d4;
  --gradient: linear-gradient(135deg, #ef4444 0%, #8b5cf6 100%);
  --gradient-2: linear-gradient(135deg, #06b6d4 0%, #8b5cf6 100%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f3f9;
  --border: #e4e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Hind Siliguri', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s ease;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ============== NAVBAR ============== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] .navbar { background: rgba(255, 255, 255, 0.85); }

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 22px;
  flex-shrink: 0;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: var(--gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

.logo-accent {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.search-box {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 14px;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.search-box i.fa-search {
  color: var(--text-muted);
  margin-right: 10px;
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  padding: 12px 0;
  font-family: inherit;
}

.search-box input::placeholder { color: var(--text-muted); }

.clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: none;
}

.clear-btn:hover { background: var(--border); color: var(--text-primary); }
.clear-btn.show { display: block; }

.nav-actions { display: flex; gap: 8px; align-items: center; }

.nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: var(--transition);
  position: relative;
}

.nav-btn:hover { background: var(--bg-card-hover); border-color: var(--accent); transform: translateY(-1px); }
.nav-btn i { color: var(--accent); }

.badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

#themeToggle { padding: 10px 14px; }

/* ============== HERO ============== */
.hero {
  position: relative;
  max-width: 1400px;
  margin: 32px auto 24px;
  padding: 56px 32px;
  border-radius: 24px;
  background: linear-gradient(135deg, #1a1f3a 0%, #11162a 100%);
  border: 1px solid var(--border);
  overflow: hidden;
}

[data-theme="light"] .hero {
  background: linear-gradient(135deg, #ffffff 0%, #f0f3f9 100%);
}

.hero-glow {
  position: absolute;
  top: -100px;
  right: -100px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(239, 68, 68, 0.3) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content { position: relative; z-index: 1; max-width: 700px; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  margin-bottom: 18px;
}

.hero-badge i { animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hero h1 {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: 17px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 580px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 600px;
}

.stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  backdrop-filter: blur(10px);
  transition: var(--transition);
}

[data-theme="light"] .stat { background: rgba(0, 0, 0, 0.03); }

.stat:hover { transform: translateY(-3px); border-color: var(--accent); }

.stat strong {
  display: block;
  font-size: 26px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat span {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* ============== CATEGORIES ============== */
.categories {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 8px;
}

.cat-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 0;
  scrollbar-width: thin;
}

.cat-scroll::-webkit-scrollbar { height: 4px; }

.cat-tab {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.cat-tab:hover { background: var(--bg-card-hover); color: var(--text-primary); transform: translateY(-2px); }

.cat-tab.active {
  background: var(--gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

.cat-tab .cat-count {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.cat-tab.active .cat-count { background: rgba(255, 255, 255, 0.25); }

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-head h2 {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-head h2 i { color: var(--accent); }

.result-count {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

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

.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.channel-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.channel-card:hover .play-overlay { opacity: 1; }
.channel-card:hover .card-logo img { transform: scale(1.08); }

.card-logo {
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #1a1f3a 0%, #0a0e1a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .card-logo {
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
}

.card-logo img {
  max-width: 75%;
  max-height: 75%;
  object-fit: contain;
  transition: transform 0.4s ease;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.card-logo .fallback-logo {
  width: 70px;
  height: 70px;
  background: var(--gradient);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 26px;
  font-weight: 800;
}

.live-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--accent);
  color: white;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 2;
}

.live-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.fav-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  border: none;
  z-index: 2;
  transition: var(--transition);
  font-size: 13px;
}

.fav-icon:hover { background: var(--accent); transform: scale(1.1); }
.fav-icon.active { background: var(--accent); }
.fav-icon.active i { color: white; }

.play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 1;
}

.play-overlay .play-icon {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.5);
  padding-left: 4px;
}

.card-info {
  padding: 14px;
}

.card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.card-cat {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-cat i { font-size: 9px; }

/* ============== EMPTY STATE ============== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 { font-size: 20px; color: var(--text-secondary); margin-bottom: 6px; }

/* ============== PLAYER MODAL ============== */
.player-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.player-modal.open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 1100px;
  max-height: 92vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.now-playing { display: flex; align-items: center; gap: 14px; min-width: 0; }

.now-playing img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg-primary);
  padding: 4px;
  flex-shrink: 0;
}

.np-info { min-width: 0; }

.np-info h3 {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 350px;
}

.np-category {
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse 1.5s infinite;
  vertical-align: middle;
}

.modal-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 40px;
  height: 40px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: var(--transition);
}

.icon-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); transform: translateY(-1px); }
.icon-btn.close-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.icon-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.video-wrapper {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  width: 100%;
}

#videoPlayer { width: 100%; height: 100%; display: block; background: #000; }

.video-loader, .video-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  gap: 12px;
}

.video-error i { font-size: 48px; color: var(--accent); }
.video-error h3 { font-size: 20px; }
.video-error p { color: #aaa; text-align: center; }

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.related-channels {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  max-height: 180px;
  overflow-y: auto;
}

.related-channels h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.related-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.related-card {
  flex: 0 0 130px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  text-align: center;
}

.related-card:hover { transform: translateY(-3px); border-color: var(--accent); }

.related-card img {
  width: 60px;
  height: 40px;
  object-fit: contain;
}

.related-card span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* ============== FOOTER ============== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  margin-top: 60px;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 48px 24px 24px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
}

.footer-brand p {
  color: var(--text-secondary);
  margin-top: 14px;
  max-width: 380px;
  font-size: 14px;
}

.footer-col h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.footer-col ul { list-style: none; }

.footer-col ul li {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.footer-col ul li:hover { color: var(--accent); }

.social { display: flex; gap: 10px; }

.social a {
  width: 38px;
  height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}

.social a:hover {
  background: var(--gradient);
  color: white;
  border-color: transparent;
  transform: translateY(-3px);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 900px) {
  .footer-inner { grid-template-columns: 1fr; gap: 28px; }
  .nav-label { display: none; }
  .nav-btn { padding: 10px 12px; }
  .hero { padding: 36px 22px; margin: 20px 16px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .nav-inner { padding: 12px 14px; gap: 12px; flex-wrap: wrap; }
  .logo-text { font-size: 18px; }
  .search-box { order: 3; flex-basis: 100%; max-width: none; }
  .hero { margin: 16px 12px; padding: 28px 18px; border-radius: 18px; }
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 14px; }
  .main, .categories { padding: 8px 14px; }
  .main { padding-bottom: 40px; }
  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
  .card-info { padding: 10px; }
  .card-name { font-size: 13px; }
  .card-cat { font-size: 11px; }
  .modal-content { max-height: 100vh; border-radius: 12px; }
  .np-info h3 { font-size: 14px; max-width: 180px; }
  .icon-btn { width: 36px; height: 36px; }
  .related-channels { padding: 12px; }
}

@media (max-width: 400px) {
  .channel-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat strong { font-size: 20px; }
}
