/* ---------------------------------------------------
   ULTIMATE PLAYER V8.4 - STYLING UPDATE
   Update: Category Badges & Flex Fixes
   --------------------------------------------------- */

/* SECURITY & CORE */
body { 
    -webkit-user-select: none; 
    -ms-user-select: none; 
    user-select: none; 
    background-color: #0f1014; 
    color: white; 
    font-family: 'Segoe UI', sans-serif; 
    overflow: hidden; 
    height: 100vh; 
    margin: 0;
}

/* ENABLE SELECT/PASTE FOR INPUTS */
input, textarea { 
    -webkit-user-select: text !important; 
    user-select: text !important; 
}

:root { 
    --primary: #e50914; 
    --bg-glass: rgba(20, 20, 20, 0.95); 
    --accent: #ffc107; 
    --text-grey: #b3b3b3; 
    --modal-bg: #0b1120; 
}

/* FOCUS & ANIMATION */
.focusable:focus, .focusable:hover { outline: 3px solid var(--primary) !important; transform: scale(1.05); z-index: 100; box-shadow: 0 0 15px var(--primary); }
.animate-pop { transition: transform 0.2s; }

/* BACKGROUND */
#dynamicBg { position: fixed; inset: 0; z-index: -1; background-image: url('https://wallpapers.com/images/hd/netflix-background-gs7hjuwvv2g0e9fj.jpg'); background-size: cover; filter: blur(20px) brightness(0.4); transition: background-image 0.5s ease-in-out; }

/* TOAST NOTIFICATION */
#toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 11000; display: flex; flex-direction: column; gap: 10px; }
.toast-msg { background: rgba(30,30,30,0.95); padding: 12px 24px; border-radius: 50px; border: 1px solid #444; display: flex; align-items: center; gap: 10px; animation: slideUp 0.3s ease; }
.toast-msg.success { border-color: #28a745; color: #28a745; }
.toast-msg.error { border-color: #dc3545; color: #dc3545; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* SECTIONS (Login, Profile, Dashboard) */
#profileSection, #loginSection { position: fixed; inset: 0; z-index: 10000; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow-y: auto; }
#loginSection { background: rgba(0,0,0,0.95); display: none; padding: 20px; }

/* --- UPDATED PROFILE MANAGER STYLES --- */
.profile-wrapper { position: relative; margin: 20px; }

.profile-avatar { 
    width: 100px; height: 100px; 
    border-radius: 50%; 
    background: #222; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 40px; color: #fff; 
    cursor: pointer; 
    border: 3px solid transparent; 
    transition: 0.3s; 
    position: relative;
}
.profile-avatar:hover { border-color: var(--primary); }

/* Delete Button (Red - Top Right) */
.btn-delete-profile { 
    position: absolute; top: -5px; right: -5px; 
    background: red; color: white; 
    border: 2px solid white; border-radius: 50%; 
    width: 30px; height: 30px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 14px; cursor: pointer; 
    z-index: 50; 
    transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
.btn-delete-profile:hover { transform: scale(1.2); background: #b90909; }

/* Edit Button (Blue - Top Left) */
.btn-edit-profile { 
    position: absolute; top: -5px; left: -5px; 
    background: #007bff; color: white; 
    border: 2px solid white; border-radius: 50%; 
    width: 30px; height: 30px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 12px; cursor: pointer; 
    z-index: 50; 
    transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
.btn-edit-profile:hover { transform: scale(1.2); background: #0056b3; }

/* LOGIN BOX */
.login-box { background: #141414; padding: 30px; border-radius: 12px; width: 100%; max-width: 480px; border: 1px solid #333; margin-top: 50px; margin-bottom: 50px; }

/* QR & TABS */
#qr-reader { width: 100%; border-radius: 10px; overflow: hidden; margin-bottom: 15px; border: 2px solid var(--primary); display:none; }
.nav-tabs .nav-link { color: #aaa; border: none; cursor: pointer; }
.nav-tabs .nav-link.active { background: transparent; color: var(--primary); border-bottom: 2px solid var(--primary); font-weight: bold; }

/* PASSWORD TOGGLE */
.password-wrapper { position: relative; }
.password-toggle-icon { position: absolute; top: 50%; right: 15px; transform: translateY(-50%); cursor: pointer; color: #aaa; z-index: 10; }

/* QUICK LINKS */
.ql-section-title { font-size: 0.8rem; letter-spacing: 2px; color: #666; margin-bottom: 15px; margin-top: 25px; }
.btn-ql-main { background: rgba(30, 30, 40, 0.6); border: 1px solid #333; border-radius: 10px; padding: 15px; width: 100%; text-align: center; color: white; transition: 0.2s; margin-bottom: 10px; }
.btn-ql-main:hover { background: #222; border-color: var(--primary); }
.ql-sub-text { font-size: 0.75rem; color: #888; display: block; margin-bottom: 3px; }
.ql-main-text { font-size: 1rem; font-weight: bold; color: white; display: block; }

/* DASHBOARD */
#dashboardSection { display: none; height: 100vh; overflow-y: auto; padding: 20px; padding-bottom: 80px; }
.account-info-box { background: linear-gradient(45deg, #1a1a1a, #252525); border-radius: 8px; padding: 10px 15px; font-size: 0.85rem; margin-top: 5px; border-left: 4px solid var(--primary); }
.btn-header { background: rgba(255,255,255,0.1); border: 1px solid #444; color: white; padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }

.dash-card { background: linear-gradient(145deg, rgba(26,26,26,0.9), rgba(17,17,17,0.9)); border: 1px solid #333; border-radius: 12px; padding: 30px; text-align: center; cursor: pointer; transition: 0.3s; height: 100%; }

/* --- PLAYER INTERFACE LAYOUT --- */
#playerInterface { display: none; height: 100vh; width: 100vw; flex-direction: column; overflow: hidden; }
.sidebar { width: 280px; background: #080808; border-right: 1px solid #222; display: flex; flex-direction: column; height: 100%; flex-shrink: 0; }
.main-view { flex: 1; display: flex; flex-direction: column; height: 100%; position: relative; }

.video-area { position: relative; background: #000; width: 100%; display: flex; flex-direction: row; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.vid-frame { flex: 1; height: 100%; position: relative; border-right: 1px solid #222; }
#secondaryPlayer { display: none; } 
.video-js { width: 100% !important; height: 100% !important; }

/* --- MINI PLAYER (FIXED DIMENSIONS & CLOSE BUTTON) --- */

.mini-player-active #playerInterface { 
    position: fixed; 
    bottom: 20px; 
    right: 20px; 
    width: 320px !important; 
    height: 180px !important; 
    z-index: 12000; 
    border: 2px solid var(--primary); 
    border-radius: 10px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.8); 
    display: flex !important; 
    overflow: hidden; 
    resize: none; 
    max-width: 320px; 
    max-height: 180px;
}

.mini-player-active .sidebar, 
.mini-player-active .controls-bar, 
.mini-player-active .content-scroll-area, 
.mini-player-active .info-overlay, 
.mini-player-active .epg-overlay, 
.mini-player-active .stats-overlay { 
    display: none !important; 
}

.mini-player-active .video-area { 
    height: 100% !important; 
    width: 100% !important; 
    min-height: 100% !important; 
}

.mini-player-overlay { 
    display: none; 
    position: absolute; 
    inset: 0; 
    z-index: 10; 
    cursor: pointer; 
    background: rgba(0,0,0,0.1); 
}
.mini-player-active .mini-player-overlay { display: block; }

.mini-close-btn { 
    position: absolute; 
    top: 5px; 
    right: 5px; 
    background: red; 
    color: white; 
    border: none; 
    border-radius: 50%; 
    width: 25px; 
    height: 25px; 
    font-size: 14px; 
    z-index: 20000 !important; 
    display: none; 
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
.mini-player-active .mini-close-btn { display: block; }

.controls-bar { background: #101010; padding: 10px; display: flex; gap: 8px; overflow-x: auto; border-bottom: 1px solid #222; flex-shrink: 0; z-index: 50; align-items: center; }
.btn-ctrl { background: #1f1f1f; border: 1px solid #333; color: #ccc; padding: 6px 12px; border-radius: 4px; white-space: nowrap; font-size: 0.75rem; display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* CONTENT SCROLL AREA (Grid container) */
.content-scroll-area { 
    flex-grow: 1; 
    overflow-y: auto; 
    padding: 0 15px 15px 15px; 
    position: relative; 
}
.sticky-header-container { position: sticky; top: 0; z-index: 100; background-color: #0f1014; padding-top: 15px; padding-bottom: 10px; border-bottom: 1px solid #222; margin-bottom: 15px; }

/* GRID ITEMS */
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; padding-bottom: 50px; }

.ch-item { 
    background: rgba(24,24,24,0.9); border-radius: 8px; padding: 8px; 
    text-align: center; cursor: pointer; transition: 0.2s; position: relative; 
    border: 1px solid transparent; height: 130px;
}
.ch-item:hover { transform: scale(1.03); background: #222; border-color: var(--primary); z-index: 10; }
.ch-img { width: 100%; height: 70px; object-fit: contain; margin-bottom: 5px; }

/* FAVORITE ICON */
.fav-icon-overlay { 
    position: absolute; top: 5px; right: 5px; 
    z-index: 50; 
    color: rgba(255,255,255,0.6); 
    font-size: 1.2rem; cursor: pointer; 
    text-shadow: 1px 1px 2px black; 
    transition: 0.2s;
}
.fav-icon-overlay:hover { transform: scale(1.2); color: white; }
.fav-icon-overlay.active { color: #e50914; opacity: 1; }

/* MODALS & OVERLAYS */
.custom-modal-content { background-color: var(--modal-bg); border: 1px solid #333; border-radius: 10px; }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; max-height: 60vh; overflow-y: auto; }
.cat-btn { background: #0f1825; border: 1px solid #1e2a3b; color: #ccc; padding: 12px; text-align: center; border-radius: 5px; cursor: pointer; min-height: 50px; display: flex; align-items: center; justify-content: center; }
.cat-btn:hover { border-color: var(--primary); color: white; background: #162235; }

.empty-state { text-align: center; margin-top: 50px; color: #555; }
.info-overlay { position: absolute; top: 15px; right: 15px; z-index: 20; display: flex; gap: 10px; pointer-events: none; }
.info-badge { background: rgba(0,0,0,0.7); border: 1px solid rgba(255,255,255,0.1); color: var(--accent); padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: bold; backdrop-filter: blur(5px); }

.stats-overlay { position: absolute; top: 50px; left: 20px; background: rgba(0,0,0,0.85); color: #00ff00; font-family: 'Courier New', monospace; font-size: 11px; padding: 15px; z-index: 30; pointer-events: none; border: 1px solid #333; border-radius: 5px; display: none; line-height: 1.5; min-width: 200px; backdrop-filter: blur(5px); }
.epg-overlay { position: absolute; bottom: 60px; left: 20px; z-index: 20; background: rgba(0,0,0,0.85); padding: 10px 15px; border-radius: 8px; max-width: 350px; display: none; pointer-events: none; border-left: 4px solid var(--primary); backdrop-filter: blur(5px); transition: opacity 0.5s ease; }
.settings-panel { position: absolute; bottom: 80px; right: 10px; width: 220px; background: rgba(15, 15, 15, 0.95); border: 1px solid #333; border-radius: 10px; z-index: 9999; display: none; backdrop-filter: blur(15px); }

/* Updated Desktop Sidebar Item Layout */
.settings-item { 
    padding: 12px 15px; 
    border-bottom: 1px solid #2a2a2a; 
    color: #ddd; 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; /* Ensures badge goes to right */
    align-items: center; 
    font-size: 0.9rem; 
}

/* Category Count Badge Style */
.cat-count-badge {
    font-size: 0.75rem;
    min-width: 30px;
}

.tmdb-backdrop { position: absolute; top:0; left:0; width:100%; height:200px; background-size: cover; background-position: center; mask-image: linear-gradient(to bottom, black, transparent); -webkit-mask-image: linear-gradient(to bottom, black, transparent); opacity: 0.6; }

/* --- RESPONSIVE FIXES (PC & MOBILE) --- */

/* MOBILE */
@media (max-width: 991px) { 
    .sidebar { display: none; } 
    .video-area { width: 100%; aspect-ratio: 16/9; height: auto !important; flex-shrink: 0; z-index: 100; } 
    .grid-container { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important; gap: 10px !important; padding: 10px !important; }
    .ch-item { height: auto !important; aspect-ratio: 1 / 1.1; }
    .ch-img { height: 60% !important; margin-top: 10px; }
    .ch-item div { font-size: 11px !important; line-height: 1.2; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 5px; }
}

/* PC / DESKTOP (Fix: LARGER PLAYER) */
@media (min-width: 992px) { 
    #playerInterface { flex-direction: row; } 
    .mobile-only { display: none !important; }
    
    /* INCREASED HEIGHT TO 60vh (Was 35vh) */
    .video-area { 
        height: 60vh !important; 
        min-height: 400px;
        max-height: 80vh;
        flex-shrink: 0; 
    } 
    
    .grid-container { 
        display: grid; 
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important; 
        gap: 10px; padding: 10px; 
    }
    
    /* Smaller Cards for PC List */
    .ch-item { height: 115px; }
}