/* ===== CSS Reset & Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #6366f1;
  --primary-dark: #4f46e5;
  --secondary-color: #8b5cf6;
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-tertiary: #1a1a1a;
  --border-color: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --hover-overlay: rgba(99, 102, 241, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  background: linear-gradient(135deg, var(--bg-primary) 0%, #0d0d0f 100%);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  min-height: 100vh;
  overflow: hidden;
}

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  max-width: 1920px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
}

.logo-icon {
  font-size: 1.75rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.logo-text {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

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

.btn-icon:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.mobile-menu-toggle {
  display: none;
}

/* ===== Main Container ===== */
.main-container {
  margin-top: 72px;
  height: calc(100vh - 72px);
  overflow: hidden;
}

.container {
  display: flex;
  gap: 1.5rem;
  max-width: 1920px;
  margin: 0 auto;
  padding: 1.5rem;
  height: 100%;
}

/* ===== Video Section ===== */
.video-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.video-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

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

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.video-overlay.active {
  opacity: 1;
  pointer-events: all;
}

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

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

.loading-text {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 420px;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
  position: relative;
}

.btn-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  z-index: 100;
}

.btn-close:hover {
  background: #ef4444;
  border-color: #ef4444;
}

/* ===== Category Tabs ===== */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex-shrink: 0;
  padding: 0.625rem 1.25rem;
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
  text-transform: capitalize;
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--hover-overlay);
  border-color: var(--primary-color);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border-color: transparent;
  color: var(--text-primary);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* ===== Channel Grid ===== */
.channel-grid {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) var(--bg-tertiary);
}

.channel-category {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 1rem;
  animation: fadeIn 0.4s ease;
}

.channel-category.hidden {
  display: none;
}

/* ===== Channel Buttons ===== */
.channel-btn {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.channel-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--hover-overlay) 0%, rgba(139, 92, 246, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.channel-btn:hover {
  border-color: var(--primary-color);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.channel-btn:hover::before {
  opacity: 1;
}

.channel-btn.active {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
  transform: scale(1.05);
}

.channel-btn.active::after {
  content: '▶';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-size: 0.625rem;
  z-index: 2;
}

.channel-logo {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.channel-btn:hover .channel-logo {
  transform: scale(1.1);
}

.channel-name {
  position: relative;
  z-index: 1;
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  word-break: break-word;
  padding: 0.5rem;
  line-height: 1.3;
}

/* ===== Scrollbar Styling ===== */
.channel-grid::-webkit-scrollbar {
  width: 8px;
}

.channel-grid::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.channel-grid::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

.channel-grid::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* ===== Responsive Design ===== */

/* Large Desktop */
@media (max-width: 1600px) {
  .sidebar {
    width: 380px;
  }
  
  .channel-category {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

/* Desktop */
@media (max-width: 1400px) {
  .sidebar {
    width: 350px;
  }
  
  .header-content {
    padding: 0.875rem 1.25rem;
  }
}

/* Tablet Landscape */
@media (max-width: 1200px) {
  .container {
    gap: 1rem;
    padding: 1rem;
  }
  
  .sidebar {
    width: 320px;
  }
  
  .channel-category {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 0.75rem;
  }
  
  .channel-grid {
    padding: 1rem;
  }
}

/* Tablet Portrait */
@media (max-width: 1024px) {
  .main-container {
    margin-top: 64px;
    height: calc(100vh - 64px);
  }
  
  .header-content {
    padding: 0.75rem 1rem;
  }
  
  .logo {
    font-size: 1.125rem;
  }
  
  .logo-icon {
    font-size: 1.5rem;
  }
  
  .container {
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.75rem;
  }
  
  .video-section {
    height: 50vh;
    min-height: 300px;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    flex: 1;
    min-height: 0;
  }
  
  .channel-category {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

/* Mobile Landscape */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
  
  .sidebar {
    position: fixed;
    top: 64px;
    right: -100%;
    bottom: 0;
    width: 85%;
    max-width: 380px;
    z-index: 999;
    border-radius: 0;
    animation: slideIn 0.3s ease forwards;
  }
  
  .sidebar.active {
    right: 0;
  }
  
  .btn-close {
    display: flex;
  }
  
  .container {
    padding: 0.5rem;
    gap: 0.5rem;
  }
  
  .video-section {
    height: calc(100vh - 64px - 1rem);
    border-radius: 12px;
  }
  
  .category-tabs {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  
  .tab-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
  }
  
  .channel-grid {
    padding: 1rem;
  }
  
  .channel-category {
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 0.75rem;
  }
}

/* Mobile Portrait */
@media (max-width: 640px) {
  .header-content {
    padding: 0.625rem 0.75rem;
  }
  
  .logo {
    font-size: 1rem;
  }
  
  .logo-icon {
    font-size: 1.375rem;
  }
  
  .btn-icon {
    width: 36px;
    height: 36px;
  }
  
  .mobile-menu-toggle {
    display: none;
  }
  
  .main-container {
    margin-top: 56px;
    height: auto;
    min-height: calc(100vh - 56px);
  }
  
  .container {
    flex-direction: column;
    padding: 0;
    gap: 0;
    height: auto;
  }
  
  .sidebar {
    position: relative;
    right: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border-color);
    height: auto;
    min-height: calc(100vh - 56px - 56vw);
  }
  
  .btn-close {
    display: none;
  }
  
  .video-section {
    width: 100%;
    height: 56vw;
    max-height: 350px;
    min-height: unset;
    border-radius: 0;
    flex-shrink: 0;
  }
  
  .channel-info {
    padding: 0.5rem 0.75rem;
    top: 0.75rem;
    left: 0.75rem;
  }
  
  .live-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
  }
  
  .channel-name-display {
    font-size: 0.8rem;
  }
  
  .category-tabs {
    padding: 0.75rem 0.75rem;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  
  .category-tabs::-webkit-scrollbar {
    display: none;
  }
  
  .tab-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
  }
  
  .channel-grid {
    padding: 0.75rem;
    max-height: calc(100vh - 56px - 56vw - 120px);
    overflow-y: auto;
  }
  
  .channel-category {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.625rem;
  }
  
  .channel-btn {
    border-radius: 8px;
  }
  
  .channel-name {
    font-size: 0.7rem;
    padding: 0.375rem;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .video-section {
    height: 56vw;
    max-height: 280px;
  }
  
  .channel-category {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
  
  .channel-name {
    font-size: 0.65rem;
  }
  
  .category-tabs {
    padding: 0.625rem 0.75rem;
    gap: 0.375rem;
  }
  
  .tab-btn {
    padding: 0.5rem 0.875rem;
    font-size: 0.75rem;
  }
}

/* Extra Small Mobile */
@media (max-width: 380px) {
  .channel-category {
    grid-template-columns: repeat(2, 1fr);
  }
}
