/* ============================================
   RESET & BASE
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  transition:
    background 0.3s ease,
    color 0.3s ease;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}

/* ============================================
   VARIABLES THEMES (clair / sombre)
   ============================================ */
[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1c2333;
  --card-bg: #1c2333;
  --card-hover: #2d333b;
  --text: #f0f6fc;
  --text-secondary: #8b949e;
  --border: #30363d;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  --accent: #2d8bfd;
  --accent-hover: #1f6feb;
  --input-bg: #0d1117;
  --input-border: #30363d;
  --overlay-bg: rgba(0, 0, 0, 0.85);
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-hover: #f0f2f5;
  --card-bg: #ffffff;
  --card-hover: #f0f2f5;
  --text: #24292f;
  --text-secondary: #57606a;
  --border: #d0d7de;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  --accent: #2d8bfd;
  --accent-hover: #1f6feb;
  --input-bg: #ffffff;
  --input-border: #d0d7de;
  --overlay-bg: rgba(0, 0, 0, 0.7);
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-center {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-center button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-center button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.nav-center button.active {
  color: #fff;
  background: var(--accent);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-right button {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}

.nav-right button:hover {
  background: var(--surface-hover);
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* ============================================
   SEARCH BAR
   ============================================ */
.search-bar {
  margin-bottom: 28px;
}

.search-bar input {
  width: 100%;
  max-width: 600px;
  padding: 14px 20px;
  border-radius: 40px;
  border: 2px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
  transition: border 0.3s;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
}

.search-bar input::placeholder {
  color: var(--text-secondary);
}

/* ============================================
   CATEGORIES ROW (avec icônes)
   ============================================ */
.categories-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  padding: 12px 0 20px;
  margin-bottom: 20px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.categories-row::-webkit-scrollbar {
  height: 4px;
}

.categories-row::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.category-icon {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 18px;
  min-width: 80px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
}

.category-icon:hover {
  transform: translateY(-4px);
  background: var(--card-hover);
  box-shadow: var(--shadow);
}

.category-icon .cat-emoji {
  font-size: 2rem;
  line-height: 1.2;
}

.category-icon .cat-name {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 4px;
  white-space: nowrap;
}

.category-icon .cat-count {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ============================================
   SECTIONS (Vedettes, Suggestions, Catégories)
   ============================================ */
.section {
  margin-bottom: 40px;
}

.section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section h2 .see-all {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--accent);
  cursor: pointer;
  margin-left: auto;
}

.section h2 .see-all:hover {
  text-decoration: underline;
}

/* ============================================
   CHANNEL GRID (cartes Netflix-like)
   ============================================ */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.channel-card {
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
  cursor: pointer;
  position: relative;
  border: 1px solid var(--border);
}

.channel-card:hover {
  transform: scale(1.04);
  box-shadow: var(--shadow);
  z-index: 2;
}

.channel-card img {
  width: 100%;
  height: 130px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  transition: transform 0.3s;
}

.channel-card:hover img {
  transform: scale(1.05);
}

.channel-card .channel-name {
  display: block;
  padding: 8px 12px 12px;
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badge qualité */
.quality-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* Statut en ligne / hors ligne */
.status {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--card-bg);
}

.status.online {
  background: #2ea043;
}

.status.offline {
  background: #da3633;
}

/* Bouton favori */
.fav-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   BROWSE (Toutes les chaînes) - Filtres
   ============================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  align-items: center;
}

.filter-bar input,
.filter-bar select {
  padding: 10px 16px;
  border-radius: 30px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border 0.3s;
  flex: 1 1 150px;
  min-width: 120px;
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--accent);
}

.filter-bar input::placeholder {
  color: var(--text-secondary);
}

.load-more {
  display: block;
  margin: 30px auto;
  padding: 12px 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 40px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.load-more:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================
   PLAYER OVERLAY (plein écran)
   ============================================ */
.player-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-bg);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.close-player {
  position: absolute;
  top: 20px;
  right: 30px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 40px;
  transition: background 0.2s;
  z-index: 10;
}

.close-player:hover {
  background: rgba(255, 255, 255, 0.2);
}

.player-container {
  width: 100%;
  max-width: 1200px;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.player-container h3 {
  color: #fff;
  padding: 16px 20px 0;
  font-size: 1.2rem;
  background: #000;
}

.player-container video {
  width: 100%;
  max-height: 75vh;
  background: #000;
  display: block;
}

.player-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  color: grey;
}

.player-controls label {
  font-weight: 500;
  font-size: 0.9rem;
}

.player-controls select {
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: grey;
  font-size: 0.9rem;
  cursor: pointer;
}

.player-controls .fav-btn {
  position: static;
  background: transparent;
  font-size: 1.4rem;
  padding: 4px 10px;
  border-radius: 8px;
  color: #fff;
}

.player-controls .fav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   SETTINGS PAGE
   ============================================ */
.settings-panel {
  max-width: 600px;
  margin: 20px auto;
  background: var(--surface);
  padding: 32px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.settings-panel h2 {
  font-size: 1.8rem;
  margin-bottom: 24px;
}

.setting-group {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.setting-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.setting-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.setting-group select,
.setting-group button {
  padding: 10px 18px;
  border-radius: 30px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
}

.setting-group button:hover {
  background: var(--surface-hover);
}

.theme-btn {
  margin-right: 8px;
}

.setting-group p {
  margin-bottom: 8px;
}

/* ============================================
   FAVORITES VIEW
   ============================================ */
.view-favorites h2 {
  margin-bottom: 20px;
}

.view-favorites p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  text-align: center;
  padding: 40px 0;
}

/* Barre de filtres */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.filter-bar select,
.filter-bar input {
  padding: 10px 16px;
  border-radius: 30px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  flex: 1 1 150px;
  min-width: 120px;
}

.filter-bar select:focus,
.filter-bar input:focus {
  border-color: var(--accent);
}

/* Amélioration des catégories dans la sidebar */
.sidebar-categories .category-item {
  /* ... existant */
  border-radius: 12px;
  padding: 8px 12px;
}

.sidebar-categories .cat-emoji {
  font-size: 1.8rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-hover);
  border-radius: 50%;
}

.sidebar-categories .active .cat-emoji {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 992px) {
  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
  }
}

@media (max-width: 768px) {
  .navbar {
    padding: 10px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .nav-center {
    justify-content: center;
  }

  .nav-right {
    justify-content: center;
  }

  .nav-brand {
    justify-content: center;
  }

  main {
    padding: 12px 16px 30px;
  }

  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
  }

  .channel-card img {
    height: 100px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar input,
  .filter-bar select {
    flex: 1 1 auto;
  }

  .categories-row {
    gap: 8px;
    padding: 8px 0 16px;
  }

  .category-icon {
    min-width: 64px;
    padding: 8px 12px;
  }

  .category-icon .cat-emoji {
    font-size: 1.5rem;
  }

  .category-icon .cat-name {
    font-size: 0.7rem;
  }

  .player-overlay {
    padding: 10px;
  }

  .close-player {
    top: 10px;
    right: 16px;
    font-size: 1.5rem;
    padding: 4px 12px;
  }

  .player-container h3 {
    font-size: 1rem;
    padding: 12px 16px 0;
  }

  .player-controls {
    padding: 12px 16px;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }

  .channel-card img {
    height: 80px;
    padding: 6px;
  }

  .channel-card .channel-name {
    font-size: 0.75rem;
    padding: 4px 8px 8px;
  }

  .quality-badge {
    font-size: 0.55rem;
    padding: 1px 6px;
    top: 6px;
    right: 6px;
  }

  .fav-btn {
    width: 26px;
    height: 26px;
    font-size: 0.9rem;
    top: 6px;
    left: 6px;
  }

  .status {
    width: 10px;
    height: 10px;
    bottom: 6px;
    right: 6px;
  }

  .section h2 {
    font-size: 1.2rem;
  }
}

/* ============================================
   UTILITAIRES
   ============================================ */
.text-center {
  text-align: center;
}

.mt-20 {
  margin-top: 20px;
}

.mb-20 {
  margin-bottom: 20px;
}

/* ===== HOME LAYOUT ===== */
.home-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* ===== SIDEBAR CATÉGORIES ===== */
.sidebar-categories {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 85vh;
  overflow-y: auto;
  padding-right: 8px;
  position: sticky;
  top: 80px;
}

.sidebar-categories .category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s;
  background: var(--surface);
  border: 1px solid transparent;
}

.sidebar-categories .category-item:hover {
  background: var(--card-hover);
  transform: translateX(4px);
}

.sidebar-categories .category-item.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.sidebar-categories .cat-emoji {
  font-size: 1.5rem;
}

.sidebar-categories .cat-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-categories .cat-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 20px;
}

.sidebar-categories .active .cat-count {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  min-width: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .home-layout {
    flex-direction: column;
  }

  .sidebar-categories {
    flex: none;
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
    position: static;
    padding-bottom: 8px;
    gap: 8px;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }

  .sidebar-categories .category-item {
    flex: 0 0 auto;
    padding: 8px 14px;
    white-space: nowrap;
  }

  .sidebar-categories .cat-count {
    display: none;
  }
}

/* Loader */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.loader-container p {
  margin-top: 16px;
  color: var(--text-secondary);
}
