/* ========================================
   StreamZone - TV Streaming Website
   Dark Theme with Black & Blue Color Scheme
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
  /* Colors */
  --color-bg-primary: #0a0e1a;
  --color-bg-secondary: #0f1629;
  --color-bg-card: #111827;
  --color-bg-card-hover: #1a2340;
  --color-bg-elevated: #151d30;
  --color-bg-glass: rgba(15, 22, 41, 0.75);
  --color-bg-input: rgba(15, 22, 41, 0.9);
  --color-border: rgba(30, 58, 110, 0.35);
  --color-border-hover: rgba(30, 144, 255, 0.5);
  --color-border-focus: #1e90ff;

  --color-text-primary: #e8edf5;
  --color-text-secondary: #8899b8;
  --color-text-muted: #5a6d8a;
  --color-text-accent: #1e90ff;

  --color-accent: #1e90ff;
  --color-accent-hover: #4da6ff;
  --color-accent-glow: rgba(30, 144, 255, 0.3);
  --color-accent-dark: #0066cc;
  --color-live: #ff3b3b;
  --color-live-glow: rgba(255, 59, 59, 0.4);

  --color-success: #00c853;
  --color-warning: #ffab00;
  --color-sponsor-badge: #ff6d00;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--color-accent-glow);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-Index Scale */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;

  /* Safe areas for notch devices */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

img {
  max-width: 100%;
  display: block;
}

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

input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

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

ul, ol {
  list-style: none;
}

/* --- Skip Link (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-accent);
  color: white;
  border-radius: var(--radius-sm);
  z-index: var(--z-toast);
  font-weight: 600;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-md);
}

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(30, 58, 110, 0.15) 25%,
    rgba(30, 58, 110, 0.3) 50%,
    rgba(30, 58, 110, 0.15) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
}

.skeleton--pulse {
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton--rect {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
}

.skeleton--text {
  height: 14px;
  width: 70%;
  margin-top: var(--space-sm);
}

.skeleton--short {
  width: 40%;
}

.skeleton--circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 0;
}

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

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--color-bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-md);
}

.header__container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  height: 60px;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

.header__logo:hover {
  opacity: 0.85;
}

.header__logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header__logo-accent {
  color: var(--color-accent);
}

.header__nav {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.header__nav::-webkit-scrollbar {
  display: none;
}

.header__categories {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.category-pill {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--color-text-secondary);
  background: rgba(30, 58, 110, 0.15);
  border: 1px solid transparent;
  transition: all var(--transition-base);
}

.category-pill:hover {
  color: var(--color-text-primary);
  background: rgba(30, 58, 110, 0.3);
  border-color: var(--color-border);
}

.category-pill--active {
  color: white;
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.category-pill--active:hover {
  color: white;
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* Mobile menu toggle */
.header__menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.header__menu-toggle:hover {
  background: rgba(30, 58, 110, 0.3);
}

.header__menu-bar {
  width: 22px;
  height: 2px;
  background: var(--color-text-primary);
  border-radius: 2px;
  transition: all var(--transition-base);
}

/* --- Video Player Section --- */
.player-section {
  position: relative;
  width: 100%;
  background: #000;
}

.player-wrapper {
  position: relative;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

/* In fullscreen, allow popup to overflow the player wrapper */
.player-wrapper:fullscreen,
.player-wrapper:-webkit-full-screen,
.player-wrapper:-moz-full-screen {
  overflow: visible;
}

.player-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.player-video::-webkit-media-controls-panel {
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

.player-skeleton {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-skeleton .skeleton {
  width: 100%;
  height: 100%;
}

.player-skeleton.hidden {
  display: none;
}

/* Player overlay */
.player-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  pointer-events: none;
  z-index: 2;
  opacity: 1;
  transition: opacity var(--transition-base);
}

.player-overlay.fade-out {
  opacity: 0;
}

.player-overlay__content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--space-md);
}

.player-overlay__left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.player-overlay__right {
  flex-shrink: 0;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--color-live);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.live-badge__dot {
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.player-overlay__title {
  font-size: 1rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Fullscreen player adjustments */
.player-wrapper:fullscreen,
.player-wrapper:-webkit-full-screen {
  max-width: 100%;
  border-radius: 0;
}

.player-wrapper:fullscreen .player-overlay,
.player-wrapper:-webkit-full-screen .player-overlay {
  padding: var(--space-lg) var(--space-xl);
}

.player-wrapper:fullscreen .player-overlay__title,
.player-wrapper:-webkit-full-screen .player-overlay__title {
  font-size: 1.5rem;
}

/* --- Info Bar --- */
.info-bar {
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-lg);
}

.info-bar__container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.info-bar__left {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.channel-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.channel-info__logo-wrapper {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.channel-info__logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 2px solid var(--color-border);
  position: relative;
  z-index: 1;
  transition: border-color var(--transition-base);
}

.channel-info__logo:hover {
  border-color: var(--color-accent);
}

.skeleton-wrapper {
  position: relative;
}

.channel-info__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-info__name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.channel-info__meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.stream-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stream-status--live {
  color: var(--color-live);
}

.stream-status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-live);
  box-shadow: 0 0 6px var(--color-live-glow);
  animation: livePulse 1.5s ease-in-out infinite;
}

/* Server Selector */
.info-bar__right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.server-selector {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.server-selector__label {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.server-selector__dropdown {
  padding: 6px 32px 6px 12px;
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238899b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.server-selector__dropdown:hover {
  border-color: var(--color-border-hover);
}

.server-selector__dropdown:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
  outline: none;
}

/* --- Banner Ad Section --- */
.banner-ad-section {
  padding: var(--space-lg);
  background: var(--color-bg-primary);
}

.banner-ad-section__container {
  max-width: 1400px;
  margin: 0 auto;
}

.banner-ad {
  display: block;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--color-border);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}

.banner-ad:hover {
  border-color: var(--color-border-hover);
  box-shadow: 0 0 20px rgba(30, 144, 255, 0.1);
}

.banner-ad__img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 250px;
  object-fit: cover;
  border-radius: var(--radius-xl);
}

/* --- Sponsor Section --- */
.sponsor-section {
  padding: var(--space-lg);
  background: var(--color-bg-primary);
}

.sponsor-carousel {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

.sponsor-card {
  position: relative;
  padding: var(--space-xl) var(--space-2xl);
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-md);
  transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.sponsor-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  z-index: 0;
}

.sponsor-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(30,144,255,0.08) 0%, transparent 60%);
  z-index: 1;
}

.sponsor-card > * {
  position: relative;
  z-index: 2;
}

.sponsor-card__badge {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  padding: 4px 12px;
  background: var(--color-sponsor-badge);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-full);
  z-index: 3;
}

.sponsor-card__title {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.02em;
}

.sponsor-card__description {
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
  max-width: 500px;
}

.sponsor-card__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 28px;
  background: var(--color-accent);
  color: white;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
  align-self: flex-start;
  box-shadow: 0 4px 15px rgba(30, 144, 255, 0.3);
}

.sponsor-card__cta:hover {
  background: var(--color-accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(30, 144, 255, 0.5);
}

.sponsor-card__cta:active {
  transform: translateY(0);
}

.sponsor-card__cta svg {
  transition: transform var(--transition-fast);
}

.sponsor-card__cta:hover svg {
  transform: translateX(3px);
}

/* Sponsor dots */
.sponsor-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.sponsor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  padding: 0;
}

.sponsor-dot--active {
  background: var(--color-accent);
  width: 24px;
  border-radius: var(--radius-full);
}

/* --- Chat Section (Full Width) --- */
.chat-section--fullwidth {
  background: var(--color-bg-secondary);
  border: none;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  height: auto;
  position: static;
  overflow: visible;
  padding: var(--space-lg) 0;
}

.chat-section__container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
  display: flex;
  flex-direction: column;
  height: 400px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* --- Channel List Section (Full Width) --- */
.channel-list-section--fullwidth {
  background: var(--color-bg-primary);
  padding: var(--space-lg) 0;
}

.channel-list-section__container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-title__icon {
  color: var(--color-accent);
}

.channel-count {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Search */
.search-wrapper {
  position: relative;
  margin-bottom: var(--space-md);
}

.search-icon {
  position: absolute;
  top: 50%;
  left: var(--space-md);
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px var(--space-md) 10px 42px;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: 0.88rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.search-input:hover {
  border-color: var(--color-border-hover);
}

.search-input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

/* Channel Grid */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
}

.channel-grid--loading {
  display: grid;
}

.channel-grid--loading.hidden {
  display: none;
}

/* Channel Card */
.channel-card {
  position: relative;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-base);
  animation: fadeInUp 0.4s ease backwards;
}

.channel-card:hover {
  border-color: var(--color-border-hover);
  background: var(--color-bg-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.channel-card--active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent), var(--shadow-glow);
}

.channel-card--active:hover {
  border-color: var(--color-accent);
}

.channel-card__thumb {
  position: relative;
  aspect-ratio: 16/10;
  background: linear-gradient(135deg, var(--color-bg-secondary), var(--color-bg-elevated));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.channel-card__img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  object-fit: contain;
  transition: transform var(--transition-base);
  z-index: 1;
}

.channel-card:hover .channel-card__img {
  transform: scale(1.1);
}

.channel-card__live-badge {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(255, 59, 59, 0.9);
  color: white;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.channel-card__live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: white;
}

.channel-card__category {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  padding: 3px 8px;
  background: rgba(10, 14, 26, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--color-text-secondary);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.channel-card__body {
  padding: var(--space-md);
}

.channel-card__name {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-card__servers {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Channel Card Skeleton */
.channel-card-skeleton {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 0;
}

.channel-card-skeleton .skeleton--rect {
  border-radius: 0;
  aspect-ratio: 16/10;
}

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

/* --- Chat Section (shared styles) --- */
.chat-section {
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
}

.chat-header__title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.95rem;
  font-weight: 700;
}

.chat-header__icon {
  color: var(--color-accent);
}

.chat-header__online {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.chat-header__online::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 58, 110, 0.4) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(30, 58, 110, 0.4);
  border-radius: var(--radius-full);
}

.chat-msg {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  animation: chatMsgIn 0.3s ease;
}

.chat-msg:hover {
  background: rgba(30, 58, 110, 0.12);
}

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

.chat-msg__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
}

.chat-msg__content {
  flex: 1;
  min-width: 0;
}

.chat-msg__user {
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.chat-msg__text {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg__time {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Chat system message */
.chat-msg--system {
  justify-content: center;
  padding: var(--space-xs) 0;
}

.chat-msg--system .chat-msg__text {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-style: italic;
  text-align: center;
}

/* Chat Input */
.chat-input-area {
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}

.chat-input-wrapper {
  display: flex;
  gap: var(--space-sm);
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 4px 4px 4px var(--space-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-input-wrapper:focus-within {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.chat-input {
  flex: 1;
  padding: 6px 0;
  font-size: 0.85rem;
  color: var(--color-text-primary);
  background: transparent;
}

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

.chat-send-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  color: white;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.chat-send-btn:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
}

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

/* --- Mobile Channel Drawer --- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: var(--z-overlay);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.drawer-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 85vw;
  height: 100%;
  background: var(--color-bg-secondary);
  border-left: 1px solid var(--color-border);
  z-index: var(--z-modal);
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}

.drawer.open {
  transform: translateX(0);
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.drawer__title {
  font-size: 1.1rem;
  font-weight: 700;
}

.drawer__close {
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.drawer__close:hover {
  background: rgba(30, 58, 110, 0.3);
  color: var(--color-text-primary);
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

/* Drawer channel items */
.drawer-channel {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.drawer-channel:hover {
  background: rgba(30, 58, 110, 0.15);
}

.drawer-channel--active {
  background: rgba(30, 144, 255, 0.1);
  border-color: var(--color-accent);
}

.drawer-channel__logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.drawer-channel__info {
  flex: 1;
  min-width: 0;
}

.drawer-channel__name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-channel__meta {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* --- Footer --- */
.footer {
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
  padding: var(--space-xl) var(--space-lg);
  margin-top: var(--space-2xl);
}

.footer__container {
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}

.footer__text {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.footer__disclaimer {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* --- Responsive Design --- */

/* Tablet (<= 1024px) */
@media (max-width: 1024px) {
  .banner-ad__img {
    max-height: 200px;
  }

  .chat-section__container {
    height: 380px;
  }

  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* Mobile (<= 768px) */
@media (max-width: 768px) {
  .header__nav {
    display: none;
  }

  .header__menu-toggle {
    display: flex;
  }

  .player-overlay__title {
    font-size: 0.85rem;
  }

  .info-bar {
    padding: var(--space-sm) var(--space-md);
  }

  .info-bar__container {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .channel-info__logo-wrapper {
    width: 40px;
    height: 40px;
  }

  .channel-info__logo {
    width: 40px;
    height: 40px;
  }

  .channel-info__name {
    font-size: 0.95rem;
  }

  .sponsor-card {
    padding: var(--space-lg);
    min-height: 130px;
  }

  .sponsor-card__title {
    font-size: 1.15rem;
  }

  .sponsor-card__description {
    font-size: 0.82rem;
  }

  .banner-ad__img {
    max-height: 160px;
  }

  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-sm);
  }

  .channel-card__img {
    width: 44px;
    height: 44px;
  }

  .channel-card__body {
    padding: var(--space-sm) var(--space-md);
  }

  .channel-card__name {
    font-size: 0.82rem;
  }

  .chat-section__container {
    height: 320px;
  }
}

/* Small mobile (<= 480px) */
@media (max-width: 480px) {
  :root {
    --space-lg: 16px;
    --space-xl: 24px;
  }

  .header__container {
    height: 52px;
  }

  .header__logo-text {
    font-size: 1.05rem;
  }

  .player-overlay {
    padding: var(--space-sm) var(--space-md);
  }

  .player-overlay__title {
    font-size: 0.78rem;
  }

  .live-badge {
    font-size: 0.6rem;
    padding: 3px 8px;
  }

  .channel-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .banner-ad-section {
    padding: var(--space-md);
  }

  .banner-ad__img {
    max-height: 130px;
  }

  .chat-section__container {
    height: 280px;
  }

  .chat-section--fullwidth {
    padding: var(--space-md) 0;
  }

  .channel-list-section--fullwidth {
    padding: var(--space-md) 0;
  }

  .sponsor-card {
    padding: var(--space-md);
  }

  .sponsor-card__cta {
    padding: 8px 20px;
    font-size: 0.82rem;
  }
}

/* Landscape mobile - notch safe */
@media (max-width: 768px) and (orientation: landscape) {
  .player-wrapper {
    aspect-ratio: auto;
    height: calc(100vh - 60px);
    max-height: 70vw;
  }
}

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

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Scrollbar for body */
body::-webkit-scrollbar {
  width: 8px;
}

body::-webkit-scrollbar-track {
  background: var(--color-bg-primary);
}

body::-webkit-scrollbar-thumb {
  background: rgba(30, 58, 110, 0.4);
  border-radius: var(--radius-full);
}

body::-webkit-scrollbar-thumb:hover {
  background: rgba(30, 58, 110, 0.6);
}

/* No channels found state */
.no-channels {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-muted);
}

.no-channels__icon {
  font-size: 2rem;
  margin-bottom: var(--space-md);
  display: block;
}

.no-channels__text {
  font-size: 0.92rem;
}

/* ========================================
   Server Tip Toast Styles
   ======================================== */

.server-tip {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: linear-gradient(135deg, rgba(15, 22, 41, 0.95), rgba(10, 14, 26, 0.92));
  border: 1px solid rgba(30, 144, 255, 0.3);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  padding-right: var(--space-xl);
  max-width: 560px;
  width: calc(100% - 32px);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 0 20px rgba(30, 144, 255, 0.15),
    0 8px 32px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.server-tip.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.server-tip__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(30, 144, 255, 0.2), rgba(30, 144, 255, 0.08));
  border: 1px solid rgba(30, 144, 255, 0.25);
  border-radius: 50%;
  color: var(--color-accent);
  animation: tipIconPulse 2s ease-in-out infinite;
}

@keyframes tipIconPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30, 144, 255, 0.25); }
  50% { box-shadow: 0 0 0 6px rgba(30, 144, 255, 0); }
}

.server-tip__content {
  flex: 1;
  min-width: 0;
}

.server-tip__text {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.server-tip__text strong {
  color: var(--color-accent);
  font-weight: 700;
}

.server-tip__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 58, 110, 0.3);
  border: 1px solid rgba(30, 58, 110, 0.3);
  border-radius: 50%;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 2;
}

.server-tip__close:hover {
  background: rgba(255, 59, 59, 0.2);
  border-color: rgba(255, 59, 59, 0.4);
  color: #ff6b6b;
}

/* Auto-dismiss progress bar */
.server-tip__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(30, 58, 110, 0.2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}

.server-tip__progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-hover));
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  transform-origin: left;
  animation: tipProgressShrink 8s linear forwards;
}

@keyframes tipProgressShrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* Tip responsive */
@media (max-width: 768px) {
  .server-tip {
    top: 50px;
    max-width: calc(100% - 24px);
    padding: var(--space-sm) var(--space-md);
    padding-right: var(--space-lg);
    gap: var(--space-sm);
  }

  .server-tip__icon {
    width: 30px;
    height: 30px;
  }

  .server-tip__icon svg {
    width: 16px;
    height: 16px;
  }

  .server-tip__text {
    font-size: 0.76rem;
  }
}

@media (max-width: 480px) {
  .server-tip {
    top: 40px;
    max-width: calc(100% - 16px);
    padding: var(--space-sm) var(--space-md);
  }

  .server-tip__text {
    font-size: 0.72rem;
  }
}

/* ========================================
   Promo Popup Styles
   ======================================== */

.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

/* When popup is inside playerWrapper (fullscreen mode),
   use absolute positioning to fill the fullscreen area */
.player-wrapper .popup-overlay {
  position: absolute;
}

/* When popup is in body (normal mode), use fixed positioning for full viewport */
body > .popup-overlay {
  position: fixed;
}

.popup-overlay.active {
  opacity: 1;
  visibility: visible;
}

.popup-card {
  position: relative;
  background: linear-gradient(145deg, rgba(15, 22, 41, 0.95), rgba(10, 14, 26, 0.98));
  border: 1px solid rgba(30, 144, 255, 0.25);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl) var(--space-xl);
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow:
    0 0 40px rgba(30, 144, 255, 0.15),
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: scale(0.85) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.popup-overlay.active .popup-card {
  transform: scale(1) translateY(0);
}

/* Animated gradient border glow */
.popup-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: var(--radius-xl);
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(30, 144, 255, 0.4),
    transparent 40%,
    transparent 60%,
    rgba(30, 144, 255, 0.4)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: popupBorderRotate 4s linear infinite;
  pointer-events: none;
}

@keyframes popupBorderRotate {
  0% { background: linear-gradient(0deg, rgba(30,144,255,0.4), transparent 40%, transparent 60%, rgba(30,144,255,0.4)); }
  25% { background: linear-gradient(90deg, rgba(30,144,255,0.4), transparent 40%, transparent 60%, rgba(30,144,255,0.4)); }
  50% { background: linear-gradient(180deg, rgba(30,144,255,0.4), transparent 40%, transparent 60%, rgba(30,144,255,0.4)); }
  75% { background: linear-gradient(270deg, rgba(30,144,255,0.4), transparent 40%, transparent 60%, rgba(30,144,255,0.4)); }
  100% { background: linear-gradient(360deg, rgba(30,144,255,0.4), transparent 40%, transparent 60%, rgba(30,144,255,0.4)); }
}

/* Decorative background particles */
.popup-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(30, 144, 255, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(30, 144, 255, 0.05) 0%, transparent 50%);
  animation: popupBgFloat 6s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes popupBgFloat {
  0% { transform: translate(0, 0); }
  100% { transform: translate(10px, -10px); }
}

.popup-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 58, 110, 0.3);
  border: 1px solid rgba(30, 58, 110, 0.4);
  border-radius: 50%;
  color: var(--color-text-secondary);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 2;
}

.popup-close:hover {
  background: rgba(255, 59, 59, 0.2);
  border-color: rgba(255, 59, 59, 0.5);
  color: #ff6b6b;
  transform: rotate(90deg);
}

.popup-icon {
  position: relative;
  z-index: 1;
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(30, 144, 255, 0.15), rgba(30, 144, 255, 0.05));
  border: 1px solid rgba(30, 144, 255, 0.2);
  border-radius: 50%;
  color: var(--color-accent);
  animation: popupIconPulse 2s ease-in-out infinite;
}

@keyframes popupIconPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30, 144, 255, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(30, 144, 255, 0); }
}

.popup-title {
  position: relative;
  z-index: 1;
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: var(--space-sm);
  background: linear-gradient(135deg, var(--color-text-primary), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.popup-text {
  position: relative;
  z-index: 1;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
}

.popup-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 32px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  color: white;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 15px rgba(30, 144, 255, 0.3);
}

.popup-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(30, 144, 255, 0.45);
  background: linear-gradient(135deg, var(--color-accent-hover), var(--color-accent));
}

.popup-btn:active {
  transform: translateY(0);
}

.popup-timer {
  position: relative;
  z-index: 1;
  margin-top: var(--space-md);
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* Popup responsive */
@media (max-width: 480px) {
  .popup-card {
    padding: var(--space-xl) var(--space-lg);
    margin: var(--space-md);
  }

  .popup-icon {
    width: 64px;
    height: 64px;
  }

  .popup-icon svg {
    width: 36px;
    height: 36px;
  }

  .popup-title {
    font-size: 1.15rem;
  }

  .popup-text {
    font-size: 0.82rem;
  }

  .popup-btn {
    padding: 10px 24px;
    font-size: 0.85rem;
  }
}

/* ========================================
   Security Styles - Anti-inspect protection
   ======================================== */

/* Disable text selection on all elements except inputs */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Re-enable selection for input fields */
input,
textarea {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

/* Disable image dragging */
img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* Allow pointer events only on channel card images for click */
.channel-card__img,
.channel-info__logo,
.drawer-channel__logo {
  pointer-events: auto;
}

/* Disable touch callout on mobile */
* {
  -webkit-touch-callout: none;
}

/* Prevent printing */
@media print {
  body {
    display: none !important;
  }
}
