/* Reset & Global Colors */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #07080b;
  --bg-workspace: #0b0c10;
  --card-dark: #0f1118;
  --card-hover: #161822;
  --border-color: #1a1d28;
  --red-accent: #e50914;
  --text-main: #ffffff;
  --text-gray: #8c8d99;
  --text-dim: #5c5d69;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOP NAV ── */
.top-nav {
  height: 48px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
}

.top-nav-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.brand-title {
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

/* ── MAIN WORKSPACE (DESKTOP) ── */
.main-hub {
  flex: 1;
  display: flex;
  overflow: hidden;
  padding: 12px;
  background: var(--bg-workspace);
}

.center-workspace {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  height: 100%;
}

/* ── LEFT: VIDEO THEATER ── */
.video-theater {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.player-container {
  width: 100%;
  flex: 1;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  position: relative;
}

/* Top Player Controls Bar */
.player-top-bar {
  height: 38px;
  background: #0d0f15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.source-badge {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-badge i { color: var(--red-accent); }

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

.action-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-gray);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.action-icon-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.btn-refresh-stream {
  color: var(--red-accent);
  font-weight: 600;
}

/* Video Grid Area */
.player-grid {
  flex: 1;
  width: 100%;
  height: 100%;
  display: grid;
  background: #000;
}

.player-grid.grid-1 { grid-template-columns: 1fr; }
.player-grid.grid-2 { grid-template-columns: 1fr 1fr; }
.player-grid.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.screen-slot {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

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

/* Under Player Bar */
.under-player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 10px;
  flex-shrink: 0;
}

.now-watching-pill {
  flex: 1;
  background: #12141c;
  border: 1px solid #232736;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-gray);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-watching-pill i { color: #fff; font-size: 10px; }
.st-title { color: #fff; font-weight: 700; }

.cinema-mode-btn {
  background: #12141c;
  border: 1px solid #232736;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--red-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}

.cinema-mode-btn:hover {
  background: rgba(229, 9, 20, 0.15);
  border-color: var(--red-accent);
}

/* ── RIGHT SIDEBAR HUB ── */
.sidebar-hub {
  width: 380px;
  height: 100%;
  background: var(--card-dark);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* 4 Navigation Tabs */
.nav-tabs-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #0d0f15;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.tab-item {
  background: transparent;
  border: none;
  color: var(--text-gray);
  font-size: 11px;
  font-weight: 800;
  padding: 12px 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-item:hover { color: #fff; }

.tab-item.active {
  color: var(--red-accent);
  background: rgba(229, 9, 20, 0.04);
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--red-accent);
}

/* Search input */
.search-wrap {
  padding: 8px 10px;
  background: var(--card-dark);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.search-wrap input {
  width: 100%;
  background: #0f1118;
  border: 1px solid #232736;
  border-radius: 4px;
  padding: 8px 12px;
  color: #fff;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.search-wrap input:focus { border-color: var(--red-accent); }

/* Tab Panels */
.tab-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel.active { display: flex; }

.matches-scroll-list,
.channels-scroll-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: #2f3447 transparent;
}

/* ── EXACT MATCH CARD ROW (CLS = 0) ── */
.comp-match-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #12141c;
  border: 1px solid #1f2230;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 52px;
}

.comp-match-row:hover {
  background: var(--card-hover);
  border-color: #2f3448;
}

.comp-match-row.active {
  border-color: var(--red-accent);
  background: rgba(229, 9, 20, 0.08);
}

.mr-team {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
}

.mr-team.away {
  justify-content: flex-end;
}

.mr-logo-box {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
}

.mr-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
  display: block;
}

.mr-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.mr-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 8px;
  flex: 0 0 auto;
  min-width: 62px;
}

.mr-time-red {
  color: var(--red-accent);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.mr-league-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--text-gray);
  margin-top: 2px;
  white-space: nowrap;
  max-width: 75px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 7/24 CHANNELS LIST ITEM ── */
.comp-ch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #12141c;
  border: 1px solid #1f2230;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 52px;
}

.comp-ch-row:hover {
  background: var(--card-hover);
  border-color: #2f3448;
}

.comp-ch-row.active {
  border-color: var(--red-accent);
  background: rgba(229, 9, 20, 0.08);
}

.ch-logo-box {
  width: 62px;
  height: 32px;
  min-width: 62px;
  background: #0a0c13;
  border: 1px solid #232736;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px;
  flex-shrink: 0;
}

.ch-logo-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.ch-badge-txt {
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.ch-text-block {
  flex: 1;
  min-width: 0;
}

.ch-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ch-sub {
  font-size: 10px;
  color: var(--text-gray);
  margin-top: 2px;
}

.ch-quality-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  background: #1a1e2d;
  color: var(--red-accent);
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── MULTISCREEN PANEL ── */
.multiscreen-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ms-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.ms-grid-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ms-btn {
  background: #12141c;
  border: 1px solid #232736;
  border-radius: 6px;
  padding: 12px;
  color: var(--text-gray);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.ms-btn:hover {
  background: var(--card-hover);
  color: #fff;
  border-color: #3f465e;
}

.ms-btn.active {
  background: rgba(229, 9, 20, 0.12);
  border-color: var(--red-accent);
  color: #fff;
}

.ms-info {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── INFO PANEL ── */
.info-content-panel {
  padding: 16px;
  font-size: 12px;
  color: var(--text-gray);
  line-height: 1.6;
}

.info-content-panel h3 {
  font-size: 13px;
  color: #fff;
  margin: 12px 0 6px;
}

/* ── CINEMA MODE ── */
body.cinema-mode .top-nav,
body.cinema-mode .sidebar-hub,
body.cinema-mode .under-player-bar {
  display: none;
}

body.cinema-mode .main-hub {
  padding: 0;
}

body.cinema-mode .player-container {
  border-radius: 0;
  border: none;
}

/* ==========================================================================
   MOBILE RESPONSIVE ENGINE (< 900px)
   ========================================================================== */
@media (max-width: 899px) {
  html {
    height: -webkit-fill-available;
  }

  body {
    height: auto;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 16px);
  }

  .main-hub {
    padding: 0;
    display: block;
    overflow: visible;
    height: auto;
  }

  .center-workspace {
    flex-direction: column;
    width: 100%;
    gap: 0;
    height: auto;
    max-width: 100%;
  }

  .video-theater {
    width: 100%;
    height: auto;
    flex: none;
    position: relative;
    z-index: 10;
  }

  .player-container {
    width: 100%;
    height: auto;
    flex: none;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    overflow: visible;
  }

  .player-grid {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    flex: none;
    position: relative;
    overflow: hidden;
    background: #000;
  }

  .player-top-bar {
    height: 34px;
    padding: 0 10px;
    background: #0d0f15;
  }

  .source-badge {
    font-size: 11px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .under-player-bar {
    margin: 8px 10px 10px;
  }

  .cinema-mode-btn {
    display: none;
  }

  .sidebar-hub {
    width: 100%;
    height: auto;
    flex: none;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border-color);
    overflow: visible;
    background: var(--bg-workspace);
  }

  /* Sticky navigation below player */
  .nav-tabs-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(13, 15, 21, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
  }

  .tab-item {
    min-height: 46px;
    font-size: 11px;
    padding: 12px 2px;
    touch-action: manipulation;
  }

  .search-wrap {
    position: sticky;
    top: 46px;
    z-index: 25;
    background: var(--card-dark);
    padding: 8px 10px;
  }

  /* 16px prevents iOS Safari auto-zoom on input focus */
  .search-wrap input {
    font-size: 16px;
    height: 40px;
    padding: 8px 12px;
  }

  .tab-panel {
    overflow: visible;
    height: auto;
  }

  .matches-scroll-list,
  .channels-scroll-list {
    overflow: visible;
    height: auto;
    padding: 8px 10px;
    gap: 6px;
  }

  .player-grid.grid-2 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

/* ── Narrow Mobile Screens (320px - 480px) ── */
@media (max-width: 480px) {
  .comp-match-row {
    padding: 8px 8px;
    gap: 4px;
    min-height: 48px;
  }

  .mr-team {
    gap: 6px;
    flex: 1 1 0;
    min-width: 0;
  }

  .mr-logo-box {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
  }

  .mr-logo {
    width: 22px;
    height: 22px;
  }

  .mr-name {
    font-size: 11.5px;
    font-weight: 700;
  }

  .mr-center {
    padding: 0 4px;
    min-width: 58px;
    flex: 0 0 auto;
  }

  .mr-time-red {
    font-size: 12.5px;
  }

  .mr-league-info {
    font-size: 8.5px;
    gap: 2px;
    max-width: 60px;
  }

  .comp-ch-row {
    padding: 8px 10px;
    gap: 10px;
    min-height: 48px;
  }

  .ch-logo-box {
    width: 50px;
    height: 28px;
    min-width: 50px;
  }

  .ch-title {
    font-size: 12px;
  }

  .ch-sub {
    font-size: 9.5px;
  }
}

/* ── Ultra-Compact Mobile Screens (<= 350px) ── */
@media (max-width: 350px) {
  .mr-name {
    font-size: 10.5px;
  }
  .mr-logo-box {
    width: 18px;
    height: 18px;
    min-width: 18px;
  }
  .mr-logo {
    width: 18px;
    height: 18px;
  }
  .mr-center {
    min-width: 50px;
    padding: 0 2px;
  }
  .mr-time-red {
    font-size: 11px;
  }
}
