/* ==========================================================================
   STYLE.CSS — CORE PREMIUM IPTV LAYOUT & COMPONENTS
   ========================================================================== */

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

button {
  font-family: inherit;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

input {
  font-family: inherit;
  color: inherit;
}

a {
  text-decoration: none;
  color: inherit;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--background);
}
::-webkit-scrollbar-thumb {
  background: var(--surface-light);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* App Wrapper */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 76px; /* space for mobile bottom nav */
}

@media (min-width: 1024px) {
  .app-container {
    padding-bottom: 32px;
  }
}

/* --------------------------------------------------------------------------
   A. HEADER
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
  .app-header {
    height: 68px;
    padding: 0 24px;
  }
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  user-select: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-stats {
  display: none;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-light);
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid var(--border);
}

@media (min-width: 640px) {
  .header-stats {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
}

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

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--surface-light);
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Search Bar (Collapsible or in-header) */
.search-container {
  display: none;
  position: relative;
  width: 100%;
  max-width: 360px;
}

@media (min-width: 768px) {
  .search-container {
    display: block;
  }
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon-left {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-icon-left svg {
  width: 16px;
  height: 16px;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.15);
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-light);
  color: var(--muted);
}

.search-clear-btn.visible {
  display: flex;
}

/* Mobile Search Drawer */
.mobile-search-bar {
  display: none;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.mobile-search-bar.active {
  display: block;
}

/* --------------------------------------------------------------------------
   B. FEATURED LIVE TV HERO SECTION
   -------------------------------------------------------------------------- */
.featured-section {
  position: relative;
  margin: 14px 16px;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(135deg, #0F172A 0%, #1E1B4B 60%, #0F2338 100%);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
}

@media (min-width: 768px) {
  .featured-section {
    margin: 20px 24px;
    border-radius: 24px;
  }
}

.featured-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.35;
  filter: blur(2px);
  transform: scale(1.05);
}

.featured-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(8, 11, 18, 0.95) 0%, rgba(8, 11, 18, 0.75) 50%, rgba(8, 11, 18, 0.4) 100%);
}

[data-theme="light"] .featured-scrim {
  background: linear-gradient(90deg, rgba(248, 250, 252, 0.95) 0%, rgba(248, 250, 252, 0.8) 50%, rgba(248, 250, 252, 0.5) 100%);
}

.featured-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 16px;
}

@media (min-width: 640px) {
  .featured-content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 32px 28px;
  }
}

.featured-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.featured-logo-wrapper {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--surface);
  border: 2px solid var(--border-active);
  box-shadow: var(--active-glow);
  overflow: hidden;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .featured-logo-wrapper {
    width: 90px;
    height: 90px;
    border-radius: 22px;
  }
}

.featured-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.featured-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.featured-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-live-pulse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  background: var(--badge-live);
  color: #FFFFFF;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 0 12px var(--badge-live-glow);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FFFFFF;
  animation: pulseDot 1.4s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.featured-category-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.featured-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}

@media (min-width: 768px) {
  .featured-title {
    font-size: 1.75rem;
  }
}

.featured-desc {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 480px;
  line-height: 1.45;
}

.featured-watch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #FFFFFF;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 4px 18px rgba(0, 212, 255, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.featured-watch-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(0, 212, 255, 0.5);
}

.featured-watch-btn:active {
  transform: scale(0.98);
}

/* --------------------------------------------------------------------------
   C. CATEGORY NAVIGATION (HORIZONTAL SCROLLER)
   -------------------------------------------------------------------------- */
.categories-wrapper {
  position: sticky;
  top: 60px;
  z-index: 30;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

@media (min-width: 768px) {
  .categories-wrapper {
    top: 68px;
    padding: 12px 24px;
  }
}

.categories-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.categories-scroll::-webkit-scrollbar {
  display: none;
}

.category-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: all 0.2s ease;
  user-select: none;
}

.category-tab:hover {
  background: var(--surface-light);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.category-tab.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
}

.category-tab-count {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
}

/* --------------------------------------------------------------------------
   D. MAIN CONTENT AREA & CHANNEL GRID
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  padding: 16px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 768px) {
  .main-content {
    padding: 20px 24px;
  }
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

.section-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--surface-light);
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid var(--border);
}

/* Channels Grid */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .channel-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
}

@media (min-width: 900px) {
  .channel-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
}

@media (min-width: 1200px) {
  .channel-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
  }
}

@media (min-width: 1400px) {
  .channel-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
  }
}

/* Channel Card */
.channel-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), 
              border-color 0.22s ease, 
              box-shadow 0.22s ease;
  user-select: none;
}

.channel-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.channel-card:active {
  transform: scale(0.98);
}

.channel-card.active-playing {
  border-color: var(--accent);
  box-shadow: var(--active-glow);
}

/* Card Media / Logo Area */
.channel-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--surface-light);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
}

.channel-logo {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
  transition: transform 0.25s ease;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.channel-card:hover .channel-logo {
  transform: scale(1.08);
}

.channel-logo-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
}

.channel-logo-fallback svg {
  width: 32px;
  height: 32px;
  opacity: 0.6;
}

.channel-logo-fallback span {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  max-width: 90px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card Overlays */
.card-live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--badge-live);
  color: #FFFFFF;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.card-favorite-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(4px);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  z-index: 5;
}

.card-favorite-btn:hover {
  transform: scale(1.15);
  color: #EF4444;
}

.card-favorite-btn.is-favorite {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
}

.card-favorite-btn svg {
  width: 16px;
  height: 16px;
}

/* Card Content / Info */
.channel-meta {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.channel-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.channel-category-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   E. SKELETON LOADERS
   -------------------------------------------------------------------------- */
.skeleton-card {
  border-radius: 16px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  overflow: hidden;
}

.skeleton-media {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: linear-gradient(90deg, var(--surface-light) 25%, var(--surface-card) 50%, var(--surface-light) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
}

.skeleton-text-group {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-bar {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-light) 25%, var(--surface-card) 50%, var(--surface-light) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
}

.skeleton-bar.short {
  width: 50%;
  height: 10px;
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --------------------------------------------------------------------------
   F. EMPTY & ERROR STATES
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 16px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 20px;
  margin: 20px 0;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--surface-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.empty-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}

.empty-desc {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 360px;
  line-height: 1.45;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 12px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 0.875rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* Error Banner / Toast */
.error-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin: 12px 16px;
  border-radius: 14px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
  font-size: 0.85rem;
}

.error-banner.active {
  display: flex;
}

/* --------------------------------------------------------------------------
   G. MOBILE BOTTOM NAVIGATION (FIXED ANCHOR)
   -------------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
}

@media (min-width: 1024px) {
  .bottom-nav {
    display: none; /* Desktop uses top header links or tabs */
  }
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  color: var(--muted);
  transition: color 0.2s ease;
  position: relative;
}

.nav-item.active {
  color: var(--accent);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 0.625rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  font-size: 0.675rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Desktop Header Navigation Links */
.desktop-nav-links {
  display: none;
  align-items: center;
  gap: 6px;
}

@media (min-width: 1024px) {
  .desktop-nav-links {
    display: flex;
  }
}

.desktop-nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  transition: all 0.2s ease;
}

.desktop-nav-tab:hover {
  color: var(--text);
  background: var(--surface-light);
}

.desktop-nav-tab.active {
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* Language Switcher Button in Header */
.lang-btn {
  width: auto;
  min-width: 40px;
  padding: 0 12px;
  gap: 6px;
  font-size: 0.775rem;
  font-weight: 700;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all 0.2s ease;
}

.lang-btn:hover {
  background: var(--surface-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   SPONSORED ADVERTISEMENT BANNER (Clean, Non-intrusive, High-CTR)
   -------------------------------------------------------------------------- */
.ad-banner-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 16px auto;
  padding: 10px 16px;
  max-width: 900px;
  width: calc(100% - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-align: center;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.ad-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  opacity: 0.7;
}

.ad-slot-300x250 {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 300px;
  height: 250px;
  min-width: 300px;
  min-height: 250px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-light);
}

.ad-slot-300x250 iframe {
  border: none;
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   OFFICIAL FOOTER & INFORMATION LINKS
   -------------------------------------------------------------------------- */
.app-footer {
  margin-top: 40px;
  padding: 32px 20px 48px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.footer-logo {
  height: 38px;
  width: auto;
}

.footer-tagline {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-disclaimer {
  font-size: 0.725rem;
  color: var(--muted);
  max-width: 680px;
  line-height: 1.5;
  opacity: 0.8;
}

.footer-copyright {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

