/* Custom scrollbar for dark theme - MATCHING NEW THEME */
.custom-scroll::-webkit-scrollbar { width: 8px; }
.custom-scroll::-webkit-scrollbar-thumb { background-color: #444455; border-radius: 4px; }
.custom-scroll::-webkit-scrollbar-track { background: #191922; }

/* Global Reset and Colors - DEEP DARK PALETTE */
body { 
    font-family: 'Inter', system-ui, Arial, sans-serif; 
    background-color: #191922; /* Very dark primary background */
    margin: 0; 
    padding: 0; 
    color: #FAFAFA; 
    min-height: 100vh;
}
.accent-color { color: #00BFFF; } /* Vibrant Blue Accent */
.accent-bg { background-color: #00BFFF; }
.text-white { color: white; }
.text-gray-400 { color: #8F9BB3; } /* Muted gray for secondary text */
.text-red-400 { color: #FF6B6B; }

/* --- Animation CSS --- (Keep original) */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.spinner {
    display: inline-block;
    width: 1.25em; 
    height: 1.25em;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #00BFFF; 
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* NEW ANIMATIONS FOR TOAST SLIDE-IN/OUT FROM RIGHT CENTER */
@keyframes slideInFromRight {
    0% {
        transform: translate(100%, -50%); /* Start 100% off screen right, vertically centered */
        opacity: 0;
    }
    100% {
        transform: translate(0, -50%); /* End at 0 offset, vertically centered */
        opacity: 1;
    }
}

@keyframes slideOutToRight {
    0% {
        transform: translate(0, -50%); /* Start at current position, vertically centered */
        opacity: 1;
    }
    100% {
        transform: translate(100%, -50%); /* End 100% off screen right, vertically centered */
        opacity: 0;
    }
}

/* Layout */
.app-container {
    display: grid;
    grid-template-rows: 1fr; /* No header row */
    height: 100vh;
}
.hidden-app { display: none !important; }

/* Header Bar - REMOVED/HIDDEN */
.header-bar { display: none; }
.status-text { display: none; } 

/* Main Grid: FOUR COLUMN LAYOUT (Icon Nav + Categories + Channels + Player) */
.content-grid {
    display: grid;
    /* Col 1 (Icon Nav): 5rem | Col 2 (Categories): 15rem | Col 3 (Channels): 28rem | Col 4 (Player): 1fr */
    grid-template-columns: 5rem 15rem 28rem 1fr; 
    overflow: hidden;
    height: 100%;
    background-color: #191922;
}

/* NEW COLUMN 1: Icon Navigation Bar */
.icon-nav-bar {
    background-color: #191922; 
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-right: 1px solid #2C2C35;
    flex-shrink: 0;
}
.nav-icon-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.nav-icon-group.top { gap: 1.5rem; }
.nav-icon-group.bottom { gap: 1.5rem; margin-top: auto; }

.nav-icon, .icon-nav-placeholder {
    width: 3rem;
    height: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background-color: #2C2C35; /* Icon background */
    color: #8F9BB3; 
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}
.nav-icon:hover { background-color: #00BFFF; color: #191922; }
.active-nav-icon { 
    background-color: #00BFFF; 
    color: #191922 !important; 
    box-shadow: 0 0 10px rgba(0, 191, 255, 0.5);
}
.nav-icon svg { width: 1.5rem; height: 1.5rem; }
.icon-nav-placeholder { font-size: 1.5rem; margin-bottom: 2rem; }
.logout-icon { color: #FF6B6B; }
.logout-icon:hover { background-color: #FF6B6B; color: white; }


/* COLUMN 2: Categories Sidebar - STYLED FOR FLAG LIST */
.sidebar-categories {
    background-color: #191922;
    overflow-y: hidden; 
    display: flex;
    flex-direction: column; 
    padding-top: 2rem; 
    border-right: 1px solid #2C2C35;
}
.category-header {
    padding: 0 1rem; 
    flex-shrink: 0;
}
.categories-nav {
    overflow-y: auto;
    flex-grow: 1;
    padding: 0.5rem 1rem 1rem 1rem; 
}
.cat {
    padding: 0.75rem 0; 
    margin-bottom: 0.5rem;
    cursor: pointer;
    background-color: transparent;
    color: #8F9BB3;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: color 0.15s;
    border-left: none; 
}
.cat:hover { 
    color: white; 
    background-color: transparent;
}
.cat.active { 
    font-weight: 700; 
    color: white; 
    background-color: transparent;
}
.cat.active .cat-count {
    background-color: #2C2C35; 
    color: #00BFFF; 
    font-weight: 700;
}
.cat-count {
    background-color: #191922;
    color: #8F9BB3;
    padding: 0 0.5rem;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 0.75rem;
    min-width: 20px;
    text-align: center;
}
.cat span:first-child { 
    display: flex;
    align-items: center;
}


/* COLUMN 3: Channel List - STYLED AS FLOATING CARDS */
.channels-column {
    background-color: #2C2C35; 
    display: flex; 
    flex-direction: column; 
    overflow-y: hidden; 
    border-right: 1px solid #2C2C35;
    padding: 2rem; 
}
.channel-list-header {
    flex-shrink: 0;
    padding: 0 0 1.5rem 0;
    border-bottom: 1px solid #383845;
    margin-bottom: 1.5rem;
}
#category-title-display {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.channels-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem; 
    overflow-y: auto; 
    padding: 0; 
    flex-grow: 1;
    min-height: 0;
}
.ch {
    display: flex;
    align-items: center;
    padding: 1.5rem; 
    background-color: #383845; 
    border-radius: 0.75rem; 
    cursor: pointer;
    transition: background-color 0.15s, transform 0.15s, border 0.15s;
    border: 1px solid transparent;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); 
    position: relative;
}
.ch:hover { 
    background-color: #444455; 
    transform: translateY(-3px); 
    border: 1px solid #00BFFF;
}
.ch.selected {
    background-color: #444455; 
    border: 1px solid #00BFFF; 
    transform: none;
}

/* --- Channel Logo Styles --- */
.channel-logo {
    width: 70px; 
    height: 70px;
    object-fit: contain;
    margin-right: 0.8rem;
    border-radius: 8px;
    background-color: #191922; 
    flex-shrink: 0;
}
.channel-logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #00BFFF;
    border: 1px solid #444455;
}
.channel-name {
    font-weight: 700;
    color: white;
    font-size: 1.1rem;
}
.ch-id {
    font-size: 0.9rem;
    color: #8F9BB3;
}
/* Favorite Icon (star) positioning inside card */
.favorite-icon { 
    position: absolute;
    top: 10px;
    right: 10px;
    color: #8F9BB3;
    fill: none;
    width: 1.5rem;
    height: 1.5rem;
    cursor: pointer;
}
.favorite-icon.favorited {
    fill: #FF6B6B !important; 
    stroke: #FF6B6B !important;
}
.favorite-icon:hover {
     transform: scale(1.1);
}


/* COLUMN 4: Player + EPG Section */
.player-column {
    /* MODIFIED FOR UX: Pushed down 100px for time/weather clearance (Desktop/Large Screen) */
    padding: 100px 0 0 0; 
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
    background-color: #191922; 
    position: relative;
}

.right-info-bar {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem; 
    color: #FAFAFA; 
    z-index: 10;
    background-color: rgba(25, 25, 34, 0.5); 
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    backdrop-filter: blur(4px);
}
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #00BFFF;
    background-image: url('https://i.imgur.com/HPRRl1K.png'); /* Mock avatar */
    background-size: cover;
    border: 2px solid white;
}

/* 泙 RESPONSIVE VIDEO CONTAINER FIX (16:9 Aspect Ratio) 泙 */
.video-container {
    width: 100%;
    position: relative;
    padding-top: 56.25%; /* 16:9 Aspect Ratio (9/16) */
    overflow: hidden;
    background-color: #191922;
    border-radius: 0;
    box-shadow: none;
    flex-shrink: 0; 
    
    background-image: url('https://i.imgur.com/HPRRl1K.png'); 
    background-size: cover;
    background-position: center;
}
#player-video, .video-js {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important; 
    height: 100% !important;
}
/* 泙 END OF FIX 泙 */

/* Player/EPG Info overlay section */
.player-info-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%; 
    background: transparent;
    padding: 2rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    border-bottom: none;
    gap: 0.5rem;
    z-index: 5;
    /* FIX: Allow clicks to pass through to the video player controls below */
    pointer-events: none; 
}
.player-info-bar h2 {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.5rem;
}
#nowInfo {
    font-size: 1rem;
    color: #FF6B6B;
    margin-left: 0 !important;
}

/* EPG section is removed from view to match the image's clean aesthetic */
.epg-section {
    display: none; 
}


/* Search Input */
.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #444455;
    background-color: #191922;
    color: white;
    border-radius: 0.5rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
    border-color: #00BFFF;
    box-shadow: 0 0 6px rgba(0, 191, 255, 0.6);
    outline: none;
}
.search-input::placeholder { color: #6B7280; }

/* Favorite Icons (Player) - Hidden as star is now on the card */
.favorite-icon-player {
    display: none !important; 
}

/* Toast Notifications and Auth Modal - ADAPTED COLORS */
.toast-success { border-left: 4px solid #00BFFF; }
.toast-error { border-left: 4px solid #FF6B6B; }
.toast-info { border-left: 4px solid #FBCF6B; }

/* TOAST CONTAINER: Positioned in the Center-Right */
#toast-container {
    position: fixed;
    top: 50%; /* Center vertically */
    right: 1rem; /* 1rem from the right edge */
    /* To perfectly center the container itself: */
    transform: translateY(-50%); 
    z-index: 2000;
    display: flex; 
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background-color: #383845;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 250px;
    /* Initial state before animation */
    opacity: 0; 
    transform: translate(100%, -50%); /* Start position must be consistent with the start of the slideInFromRight animation */
}

/* Classes to trigger the animations */
.toast.toast-show {
    animation: slideInFromRight 0.5s ease-out forwards;
}

.toast.toast-hide {
    animation: slideOutToRight 0.5s ease-in forwards;
}

/* --- AUTH MODAL STYLES (MATCHING BASIC LOGIN FORM IMAGE) --- */

.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #00C9FF 0%, #0070FF 100%); /* Blue gradient background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.auth-modal-content {
    background-color: #004D99; /* Darker blue background for the modal box */
    padding: 3rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px; /* Constrain the width */
    position: relative;
    text-align: center;
}

.auth-modal-content h2 {
    color: white; /* White for the main LOGIN title */
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.auth-modal-content p {
    color: #B3CCFF; /* Lighter blue for secondary text */
}

/* Close button (X) */
.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}
.close-btn:hover {
    color: #FF6B6B;
}

/* Input Group Styling */
.input-group {
    margin-bottom: 1.5rem;
}

.input-with-icon {
    display: flex;
    align-items: center;
    background-color: white; /* White background for the input area */
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.input-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #333; /* Dark icon color */
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.modal-input {
    flex-grow: 1;
    border: none;
    background-color: transparent;
    color: #333; /* Dark text color */
    padding: 0.5rem 0;
    font-size: 1rem;
    outline: none; /* Remove focus outline */
}
.modal-input::placeholder {
    color: #999;
}

/* Login Button */
.full-width-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-transform: uppercase;
}
.login-button {
    background-color: #00C9FF; /* Teal/Cyan-like color from the image */
    color: white; 
    margin-bottom: 1rem;
}
.login-button:hover { 
    background-color: #33DFFF; 
}
.login-button.loading {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Forgot Password Link */
.forgot-password {
    color: white; /* White text for contrast */
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}
.forgot-password:hover {
    color: #00C9FF;
}

/* Status and Copyright Text */
.login-status {
    font-weight: 600;
}
.copyright-text {
    font-size: 0.75rem;
    color: #00C9FF;
}

/* Fix for the sr-only label, ensuring it's not visible but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ======================================================= */
/* ====== RESPONSIVENESS (MOBILE AND SMALL MONITORS) ===== */
/* ======================================================= */

/* --- 1. Tablet/Mid-Sized Monitor Adjustments (Max 1200px) --- */
@media screen and (max-width: 1200px) {
    .content-grid {
        /* Reduce sidebar space to give more room to the player */
        /* Col 1: 4rem | Col 2: 12rem | Col 3: 20rem | Col 4: 1fr */
        grid-template-columns: 4rem 12rem 20rem 1fr; 
    }
    .icon-nav-bar {
        padding: 0.5rem 0;
    }
    .nav-icon, .icon-nav-placeholder {
        width: 2.5rem;
        height: 2.5rem;
    }
    .player-info-bar h2 {
        font-size: 2rem; /* Reduce title size for smaller screens */
    }
}

/* --- 2. Mobile/Smallest Screen Optimization (Max 768px) --- */
@media screen and (max-width: 768px) {
    .app-container {
        height: auto; 
    }
    .content-grid {
        /* Single column layout for mobile */
        grid-template-columns: 1fr; 
        grid-template-rows: auto 1fr; 
        overflow-y: auto;
    }
    
    /* Icon Nav Bar - Fixed to the top (Mobile Navigation) */
    .icon-nav-bar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row; /* Icons side-by-side */
        justify-content: space-around;
        align-items: center;
        padding: 0.5rem 0;
        border-right: none;
        border-bottom: 1px solid #2C2C35;
        z-index: 100;
        background-color: #111115; /* Darker background */
    }
    .nav-icon-group {
        flex-direction: row;
        gap: 1rem;
    }
    .nav-icon-group.top, .nav-icon-group.bottom { 
        gap: 1rem; 
        margin-top: 0;
    }
    .logout-icon { display: none; } /* Hide logout button to save space */
    .icon-nav-placeholder { display: none; } /* Hide logo placeholder to save space */

    /* Hide the Category and Channel List columns entirely on mobile */
    .sidebar-categories, .channels-column {
        display: none;
    }

    /* Player column starts after the fixed icon nav bar */
    .player-column {
        padding-top: 70px; /* Space for the fixed nav bar (Mobile) */
        height: auto;
        min-height: 100vh; /* Ensure the player column can fill the screen or scroll if needed */
    }

    /* Adjust info bar spacing */
    .player-info-bar {
        padding: 1rem;
        height: 50%;
    }
    .player-info-bar h2 {
        font-size: 1.5rem; 
    }
    
    /* Make right info bar (weather/time) fit better on mobile */
    .right-info-bar {
        position: absolute;
        top: 80px; /* Below the main fixed nav bar, plus a small gap */
        right: 1rem;
        padding: 0.3rem 0.6rem;
        gap: 0.5rem;
        font-size: 0.8rem;
    }
    .user-avatar {
        width: 24px;
        height: 24px;
    }
    
    .auth-modal-content {
        /* Smaller padding on mobile */
        padding: 2rem 1.5rem;
        max-width: 90%;
    }
}