/* favourites-style.css */

:root {
  /* Core Variables */
  --sidebar-width: 350px;
  --header-height: 70px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Light Theme Colors */
  --bg-app: #f4f6f8;
  --bg-sidebar: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f0f4f8;
  --bg-surface-active: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --accent-primary: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.4);
  --border-color: #e2e8f0;
  --input-bg: #f8fafc;
  --danger: #ef4444;
  --slot-bg: #000000;
  --slot-border: #cbd5e1;
}

body.dark-mode {
  /* Dark Theme Colors */
  --bg-app: #090b10;
  --bg-sidebar: #11141d;
  --bg-surface: #1a1f2e;
  --bg-surface-hover: #23293b;
  --bg-surface-active: #2c344a;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-primary: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.3);
  --border-color: #1e293b;
  --input-bg: #0f131c;
  --slot-bg: #000000;
  --slot-border: #1e293b;
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg-app); color: var(--text-primary);
  font-family: var(--font-main); height: 100vh; overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container { display: flex; height: 100vh; width: 100vw; overflow: hidden; position: relative; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--bg-sidebar); display: flex; flex-direction: column;
  border-right: 1px solid var(--border-color); z-index: 100;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s;
}

.container.collapsed .sidebar { 
  margin-left: calc(var(--sidebar-width) * -1);
  border: none;
}

.sidebar-header {
  padding: 0 24px; height: var(--header-height); display: flex;
  align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-color);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 1.5rem; }
.brand h2 { margin: 0; font-size: 1.1rem; font-weight: 700; letter-spacing: 0.5px; }
.home-link { text-decoration: none; color: var(--accent-primary); font-size: 0.85rem; font-weight: 600; transition: opacity 0.2s;}
.home-link:hover { opacity: 0.8; }

/* Search */
.search-wrapper { padding: 16px 24px; position: relative; }
.search-icon { position: absolute; left: 38px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: 0.5; }
#search {
  width: 100%; padding: 12px 16px 12px 40px; background: var(--input-bg);
  border: 1px solid var(--border-color); color: var(--text-primary);
  border-radius: 12px; outline: none; font-size: 0.95rem; font-family: var(--font-main);
  transition: all 0.2s;
}
#search:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }

/* Channel List */
#channelList { flex: 1; overflow-y: auto; padding: 0 16px 20px 16px; }

.channel {
  background: transparent; border-radius: 12px; padding: 12px 16px;
  margin-bottom: 4px; cursor: grab; border: 1px solid transparent; transition: all 0.2s ease;
}
.channel:hover { background: var(--bg-surface-hover); }
.channel:active { cursor: grabbing; }
.channel-info { display: flex; justify-content: space-between; align-items: center; }
.channel-main-info { display: flex; align-items: center; gap: 12px; }
.channel-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(135deg, var(--accent-primary), #6366f1);
  box-shadow: 0 2px 8px var(--accent-glow);
}
.channel-name-text { font-size: 0.95rem; font-weight: 500; }

/* Stream Links (Desktop) */
.links-container { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-left: 48px; }
.stream-link { font-size: 11px; font-weight: 600; color: var(--text-secondary); padding: 4px 10px; border-radius: 20px; background: var(--input-bg); border: 1px solid var(--border-color); transition: all 0.2s; cursor: pointer; }
.stream-link:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.stream-link.active-link { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); box-shadow: 0 2px 8px var(--accent-glow); }

/* Player Area & Nav */
.playerArea { flex: 1; background: var(--bg-app); display: flex; flex-direction: column; min-width: 0; position: relative; }

.top-nav { height: var(--header-height); padding: 0 30px; display: flex; align-items: center; justify-content: space-between; z-index: 10; transition: padding-left 0.3s ease; }
.nav-left, .nav-right { display: flex; align-items: center; gap: 12px; }
.now-playing-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); letter-spacing: 0.3px; }

/* Dropdown */
.view-selector { background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-primary); padding: 8px 12px; border-radius: 10px; font-size: 0.9rem; font-weight: 500; font-family: var(--font-main); outline: none; cursor: pointer; transition: all 0.2s; }
.view-selector:hover { border-color: var(--accent-primary); }

/* Buttons */
.icon-btn { background: var(--bg-surface); border: 1px solid var(--border-color); color: var(--text-secondary); width: 40px; height: 40px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--accent-primary); border-color: var(--accent-primary); background: var(--bg-surface-hover); }

.icon-btn-small { background: transparent; border: none; color: var(--text-secondary); width: 30px; height: 30px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.icon-btn-small:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.icon-btn-small svg { width: 16px; height: 16px; }

.pill-btn { background: var(--bg-surface); border: 1px solid var(--border-color); color: var(--text-primary); padding: 0 16px; height: 40px; border-radius: 20px; cursor: pointer; font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 8px; transition: all 0.2s; }
.pill-btn:hover { background: var(--bg-surface-hover); }
.fav-btn.is-fav { border-color: var(--danger); background: rgba(239, 68, 68, 0.1); color: var(--danger); }
#favIcon { font-size: 14px; }

/* Sidebar Toggle Logic */
.open-sidebar-btn { display: none; }
@media (min-width: 769px) { .container.collapsed .open-sidebar-btn { display: flex; } }

/* Grid Cinematic Area */
.cinematic-wrapper { flex: 1; padding: 0 30px 30px 30px; display: flex; flex-direction: column; height: calc(100vh - var(--header-height)); }
#videoContainer { display: grid; gap: 8px; flex: 1; background: transparent; min-height: 0; }
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr !important; }
.grid-6 { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr !important; }

/* Video Slots */
.video-slot { user-select: none; position: relative; background: var(--slot-bg); border: 1px solid var(--slot-border); border-radius: 12px; display: flex; align-items: center; justify-content: center; overflow: hidden; transition: border-color 0.2s, box-shadow 0.2s; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.video-slot.drag-over { border-color: var(--accent-primary); box-shadow: 0 0 0 4px var(--accent-glow); }

.drag-handle { position: absolute; top: 0; left: 0; width: 100%; height: 30px; z-index: 100; cursor: grab; background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent); display: flex; justify-content: center; align-items: flex-start; padding-top: 4px; opacity: 0; transition: opacity 0.3s; }
.video-slot:hover .drag-handle { opacity: 1; }
.drag-handle::before { content: "⠿"; color: rgba(255,255,255,0.7); font-size: 16px; letter-spacing: 2px; }
.drag-handle:active { cursor: grabbing; }

.is-dragging .drag-handle { height: 100%; background: rgba(59, 130, 246, 0.1); opacity: 1; }
.is-dragging iframe, .is-dragging video { pointer-events: none; }

.slot-label { position: absolute; top: 12px; left: 12px; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); color: #fff; padding: 6px 12px; font-size: 0.8rem; font-weight: 500; z-index: 105; pointer-events: none; border-radius: 8px; max-width: 80%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: 1px solid rgba(255,255,255,0.1); opacity: 0.8; transition: opacity 0.3s; }
.video-slot:hover .slot-label { opacity: 1; }

.slot-controls { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 110; opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease; transform: translateY(-5px); }
.video-slot:hover .slot-controls { opacity: 1; transform: translateY(0); }

.slot-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2); cursor: pointer; display: flex; align-items: center; justify-content: center; color: white; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); transition: all 0.2s; }
.slot-btn:hover { transform: scale(1.05); }
.remove-btn:hover { background: var(--danger); border-color: var(--danger); }
.refresh-btn:hover { background: var(--accent-primary); border-color: var(--accent-primary); }
.refresh-btn svg, .remove-btn svg { width: 16px; height: 16px; }

iframe, video { width: 100%; height: 100%; border: none; background: #000; display: block; max-height: 100%; object-fit: contain; }

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Sidebar Footer / Notice */
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-color); background: var(--bg-surface-hover); }
.ad-notice { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.6; }
.notice-title { margin: 0 0 8px 0; font-weight: 700; color: var(--text-primary); }
.notice-list { margin: 0; padding-left: 16px; }

/* Mobile Responsiveness */
.back-btn { display: none; }
@media (max-width: 768px) {
    /* changed from 850px) */
  .sidebar { position: absolute; width: 100%; height: 100%; left: 0; top: 0; }
  .container.match-selected .sidebar { transform: translateX(-100%); }
  #closeSidebarBtn { display: none !important; }
  .back-btn { display: flex !important; }
  
  /* Management Requirement: Hide layout buttons and now playing text on mobile */
  #layoutMenuContainer { display: none !important; }
  /*#nowPlaying { display: none !important; }*/
  
  .drag-handle { display: none !important; }
  
  .top-nav { padding: 0 16px; }
  .now-playing-title { font-size: 1rem; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  
  .cinematic-wrapper { padding: 0; border-radius: 0; }
  .video-slot { border-radius: 0; border: none; border-bottom: 1px solid var(--border-color); }
  .slot-controls { opacity: 1 !important; transform: translateY(0); }
  .slot-label { opacity: 1; top: 12px; bottom: auto; background: rgba(0,0,0,0.8); }

  .container:not(.match-selected) .playerArea { visibility: hidden; }
  #videoContainer iframe { height: 35vh; width: 100%; }
  
  .mobile-links-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 12px; background: var(--bg-sidebar); border-bottom: 1px solid var(--border-color); }
  .sidebar-footer { display: none; }
  #favText { display: none; }
}
/* changed from 851px) */
@media (min-width: 769px) { .mobile-links-bar { display: none; } }
/* changed from 851px) */

/* YouTube Overlays */
.yt-poster:hover div { transform: scale(1.1); transition: transform 0.2s; }

/* Action Dropdown Styling */
.action-dropdown { position: absolute; right: 0; top: 100%; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 100; min-width: 120px; overflow: hidden; margin-top: 5px; }
.action-item { padding: 10px 15px; font-size: 13px; cursor: pointer; transition: background 0.2s; white-space: nowrap; }
.action-item:hover { background: var(--bg-surface-hover); }
.hidden { display: none !important; }

/* Optional: Subtle indicator for locked channels */
.channel.is-locked { border-right: none; }

.parental-badge { font-size: 10px; padding: 2px 6px; border-radius: 999px; background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.25); margin-left: 8px; font-weight: 700; }
.parental-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(6px); z-index: 999999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.parental-modal { width: 100%; max-width: 360px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 16px; padding: 24px; box-shadow: 0 20px 40px rgba(0,0,0,0.45); }
.parental-modal h3 { margin: 0 0 8px; font-size: 1.1rem; }
.parental-modal p { margin: 0 0 16px; color: var(--text-secondary); font-size: 0.9rem; }
.parental-input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--border-color); background: var(--input-bg); color: var(--text-primary); padding: 0 14px; outline: none; font-size: 1rem; margin-bottom: 12px; }
.parental-actions { display: flex; gap: 10px; margin-top: 24px; }
.parental-actions .pill-btn { flex: 1; justify-content: center; }
.parental-actions button { flex: 1; }
.parental-lock-btn { transition: all 0.2s ease; }
.parental-lock-btn.active { background: rgba(239, 68, 68, 0.15) !important; color: var(--danger) !important; }

/* Subtitle Action & Sync Panel Controls */
.slot-controls { display: flex; gap: 6px; align-items: center; }
.subtitle-btn svg { width: 16px; height: 16px; }
.subtitle-sync-panel button:hover { background: rgba(255, 255, 255, 0.2) !important; color: var(--accent-primary) !important; }
video::cue { background: rgba(0, 0, 0, 0.75); color: #ffffff; font-family: 'Inter', sans-serif; font-size: 1.1rem; border-radius: 4px; }

/* Subtitle Sync Panel Updates */
.subtitle-sync-panel { opacity: 0 !important; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease !important; transform: translateX(-50%) translateY(8px) !important; }
.video-slot:hover .subtitle-sync-panel:not(.hidden) { opacity: 1 !important; pointer-events: auto; transform: translateX(-50%) translateY(0) !important; }
@keyframes syncFlash { 0% { color: var(--accent-primary); transform: scale(1.4); } 100% { color: #ffffff; transform: scale(1); } }
.sync-val-flash { display: inline-block; animation: syncFlash 0.3s ease-out; }
.sync-btn { transition: transform 0.1s ease, color 0.2s ease; }
.sync-btn:active { transform: scale(0.85); }

/* ========================================= */
/* ANDROID TV & SPATIAL NAVIGATION OVERRIDES */
/* ========================================= */

html.tv-mode {
  font-size: 115%; /* 10-foot viewing adjustment */
  --sidebar-width: 380px; /* Specific override for TV */
}

body.tv-mode .channel {
  padding: 16px 20px;
  margin-bottom: 8px;
}

body.tv-mode .pill-btn,
body.tv-mode .icon-btn,
body.tv-mode .icon-btn-small {
  min-height: 44px;
  min-width: 44px;
}

body.tv-mode .action-item {
  padding: 16px 20px;
  font-size: 1.1rem;
}

/* Hide Now Playing / Multiview / Select a Channel Text on Android TV */
html.tv-mode #nowPlaying {
    display: none !important;
}

/* TV Focus State D-Pad Indicators */

body.tv-mode *:focus {
  outline: 4px solid var(--accent-primary) !important;
  outline-offset: 2px !important;
  box-shadow: 0 10px 25px var(--accent-glow) !important;
  z-index: 1000;
  position: relative;
}


body.tv-mode .channel:focus {
  background: var(--bg-surface-hover);
  transform: scale(1.02);
  transition: transform 0.2s ease, background 0.2s ease;
}

/* Slot Control Visibility on Focus */
body.tv-mode .video-slot:focus-within .slot-controls,
body.tv-mode .video-slot:focus-within .subtitle-sync-panel:not(.hidden) {
  opacity: 1 !important;
  transform: translateY(0) !important;
  pointer-events: auto;
}

/* Ensure Dropdowns stay visible during focus exploration */
body.tv-mode .action-dropdown:focus-within {
  display: block !important;
}

/* Hide Drag handles natively on TV */
body.tv-mode .drag-handle {
  display: none !important;
}

/* Global Alert/Prompt Replace Modal Structure */
.app-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
  z-index: 100000; display: flex; align-items: center; justify-content: center;
}
.app-modal {
  background: var(--bg-surface); padding: 24px; border-radius: 12px;
  width: 90%; max-width: 420px; border: 1px solid var(--border-color);
  text-align: center; box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.app-modal h3 { margin-top: 0; color: var(--text-primary); }
.app-modal p { color: var(--text-secondary); font-size: 1rem; line-height: 1.4; }
.app-modal input {
  width: 100%; padding: 14px; margin: 16px 0; background: var(--input-bg);
  border: 1px solid var(--border-color); color: var(--text-primary);
  border-radius: 8px; font-size: 1rem; outline: none;
}
.app-modal input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }
.app-modal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.app-modal-actions button { flex: 1; justify-content: center; }

/* ========================================= */
/* ANDROID TV EPG FIXES      */
/* ========================================= */

body.tv-mode .epg-schedule-item:focus {
    background: var(--bg-surface-hover) !important;
    border-color: var(--accent-primary) !important;
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
    z-index: 100;
    position: relative;
}



/* ========================================= */
/* CUSTOM RADIO BUTTONS (PLAYLIST TYPES)     */
/* ========================================= */
.type-radio-btn {
    flex: 1 1 calc(50% - 4px);
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s ease;
}
.type-radio-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: 0 4px 10px var(--accent-glow);
}
.type-radio-btn:hover {
    border-color: var(--accent-primary);
}

/* ========================================= */
/* ENHANCED TV DROPDOWN FOCUS VISIBILITY     */
/* ========================================= */
body.tv-mode .action-item:focus {
    background: var(--accent-primary) !important;
    color: #ffffff !important;
    outline: none !important;
    transform: scale(1.02);
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
    z-index: 101;
}

/* ========================================= */
/* NAVBAR LAYOUT RADIO BUTTONS               */
/* ========================================= */
.nav-layout-btn {
    flex: none; /* Override the 50% width from the playlist menu */
    padding: 6px 12px;
    font-size: 0.85rem;
    margin: 0;
    border-radius: 8px;
    min-height: 36px;
}


/* ====================== PREMIUM PAYWALL FOR SAVED CHANNELS (FAVOURITES) ====================== */
.paywall-dialog {
  background: var(--bg-surface);
  padding: 30px;
  border-radius: 16px;
  width: 100%;
  max-width: 450px;
  border: 1px solid var(--accent-primary);
  box-shadow: 0 0 25px 5px var(--accent-glow);
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}

.premium-features {
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
}

/* TV PAYWALL OPTIMIZATION */
body.tv-mode #paywallModal {
  align-items: flex-start !important;
  justify-content: center;
  padding-top: 3vh; padding-bottom: 3vh;
  padding-left: 4vw; padding-right: 4vw;
}

body.tv-mode .paywall-dialog {
  width: 80vw; max-width: 900px;
  max-height: 94vh; padding: 2.5vh 2vw;
}

body.tv-mode .premium-features {
  grid-template-columns: 1fr 1fr;
  gap: 1vh 2vw; font-size: 1.8vh;
}

body.tv-mode .paywall-dialog h2 { font-size: 3vh; margin-bottom: 1.5vh; }
body.tv-mode #webPaymentBlock a, body.tv-mode #webviewPaymentBlock button,
body.tv-mode #paywallActivateBtn, body.tv-mode #closePaywallBtn {
  min-height: 6vh; font-size: 1.8vh;
}
