/* =========================================
   RESPONSIVE OVERRIDES
   ========================================= */

/* 
   TABLET / LAPTOP (max-width: 1440px) 
   - Expanded range to cover standard laptops (1366x768, 1280x720)
   - Scale cards
   - Adjust sidebars
*/
@media screen and (max-width: 1440px) {
    /* GLOBAL: Force Fit-to-Screen (TV Style) for Tablet too */
    html, body {
        overflow: hidden !important;
        height: 100% !important; /* Fix body height */
    }
    
    /* Content View Container (Live TV, Movies, etc.) */
    .app-container {
        height: 100vh !important;
        min-height: 0 !important;
        overflow: hidden !important;
        display: flex;
        flex-direction: column;
        
        /* Safe Area Padding - Internal Pages (Live TV, Movies, Series) - Minimal Spacing */
        padding-top: max(5px, env(safe-area-inset-top)) !important; 
        padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
    
    /* Dashboard Specific: Force 1 Viewport Height (TV Style) */
    .dashboard-container {
        height: 100vh !important;
        display: flex;
        flex-direction: column;
        overflow: hidden !important; /* Prevent vertical scroll */
        /* Dashboard Header - Keep Safe Space (30px) as requested */
        padding-top: max(30px, env(safe-area-inset-top)) !important; 
        padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    /* Dashboard Cards - Fit in remaining vertical space */
    .dash-cards-row {
        flex: 1; /* Grow to fill space between header and footer */
        min-height: 0; /* Allow shrinking */
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 5px;
        margin-bottom: 5px;
        align-items: center; /* Center cards vertically in the row */
        justify-content: center; /* Align Center per user request */
    }

    .dash-card {
        width: 28%; /* Reduced width */
        min-width: 180px;
        height: 75%; /* Reduced relative height */
        max-height: 220px; /* Reduced max height */
        min-height: 140px; 
        flex-shrink: 0;
    }
    
    .dash-card[data-target="live-tv"] {
        margin-right: 15px; 
    }
    .dash-card[data-target="live-tv"]:focus,
    .dash-card[data-target="live-tv"].focus-visible {
        transform: rotate(-3deg) scale(1.05) !important;
    }

    /* Content Layout - Fit to Screen */
    .content-wrapper {
        flex: 1; /* Take remaining height */
        min-height: 0; /* Allow shrinking */
        display: flex;
        padding: 0 15px 5px 15px; /* Adjust padding */
        overflow: hidden; /* Prevent wrapper scroll */
    }
    
    /* Columns scroll internally */
    .column {
        height: 100% !important;
        overflow-y: auto !important;
        padding-bottom: 20px;
    }
    
    .categories-column { width: 25%; }
    .channels-column { width: 30%; }
    .preview-column { flex-grow: 1; }
    
    /* Settings Modal */
    .settings-layout {
        width: 95%;
        height: 90vh; /* Restore fixed height for settings modal */
        max-width: none;
    }
    
    .settings-sidebar { width: min(220px, 25%); }  
    .settings-content-area { padding: 30px; }

    /* HEADER / NAV COMPACTING for Tablet */
    .top-bar {
       gap: 1px !important;
    }
    
    /* Ensure LOGO is visible and not collapsed */
    .header-logo-area {
        display: flex !important;
        opacity: 1 !important; /* Force full opacity */
        min-width: 110px !important; /* Ensure minimum width */
        margin-right: 5px !important; /* Reduce margin slightly */
        flex-shrink: 0 !important; /* NEVER SHRINK LOGO */
    }
    
    .header-logo-area img {
        height: 28px !important;
        width: 28px !important; /* Force width */
        min-width: 28px !important; 
        display: block !important;
        object-fit: contain;
    }

    .top-bar .nav-menu {
        gap: 5px !important; /* EXTROME COMPACTING: 5px gap */
        flex: 1 !important; /* Take available space */
        justify-content: center !important; /* Center the buttons */
        margin: 0 !important;
    }
    
    .top-bar .nav-item {
        padding: 4px 8px !important; /* EXTREME COMPACTING: Small padding */
        min-height: 32px !important; 
    }
    
    .top-bar .nav-item .nav-label {
        font-size: 11px !important; /* Smaller text */
        letter-spacing: 0 !important;
    }
    
    /* COLLAPSE SEARCH TO ICON ONLY to save space */
    .top-bar .nav-item.search-pill {
        width: 44px !important; /* Circle size */
        height: 44px !important;
        min-height: 44px !important;
        padding: 0 !important;
        justify-content: center !important;
        border-radius: 50% !important; /* Circle */
        background: transparent !important;
    }
    
    .top-bar .nav-item.search-pill span,
    .top-bar .nav-item.search-pill .fa-microphone {
        display: none !important; /* Hide text/mic, keep only search icon */
    }
    
    .top-bar .nav-item.search-pill i.fa-search {
        margin: 0 !important;
        font-size: 18px !important;
    }

    /* Right Side Container */
    .top-bar > div:last-child {
        gap: 5px !important; /* Override inline 20px gap */
        margin-left: 5px !important; /* Reduce auto margin separation if needed */
    }
    
    /* Target the Settings/Exit group inside it */
    .top-bar > div:last-child .nav-menu {
        gap: 5px !important; 
    }
    
    /* Right Side Items specific compacting */
    .top-bar > div:last-child .nav-item {
        padding: 5px 10px !important;
        min-height: 34px !important;
    }
    
    .system-status {
        font-size: 12px !important;
    }
}

/* 
   MOBILE (max-width: 768px) 
   - Stack everything
   - Enable scrolling
   - Simplify interactions
*/
@media screen and (max-width: 0px) { /* DISABLED MOBILE LAYOUT per user request */
    
    /* GLOBAL SCROLLING ALREADY ENABLED (from tablet rule cascade or repeat here for specificity) */
    html, body {
        overflow: auto !important;
    }
    
    .app-container,
    .dashboard-container,
    .view-container {
        height: auto !important;
        min-height: 100vh;
        overflow: visible !important;
        display: flex;
        flex-direction: column;
    }

    /* 
       DASHBOARD MOBILE 
    */
    .dashboard-container {
        padding: 20px;
    }

    .dash-top-bar {
        flex-direction: column;
        gap: 15px;
        align-items: center;
        margin-bottom: 30px;
    }

    .dash-search-container {
        width: 100%;
        margin: 0; /* Remove horizontal margin */
        max-width: none;
    }
    
    .dash-top-right-icons {
        width: 100%;
        justify-content: center;
        gap: 20px;
    }

    .dash-cards-row {
        flex-direction: column;
        width: 100%;
        gap: 20px;
    }

    .dash-card {
        width: 100%;
        height: 200px; /* Reduced height */
        margin: 0 !important;
    }

    .dash-card[data-target="live-tv"] {
        /* Keep rotation on mobile too if possible, or slight reduction */
        transform: rotate(-3deg);
        margin-bottom: 25px !important; /* Extra space for rotation */
    }
    
    .dash-bottom-bar {
        display: none; /* Hide bottom bar info on mobile to save space, or stack it */
    }

    /* 
       CONTENT VIEW MOBILE 
    */
    .top-bar {
        height: auto;
        flex-direction: column;
        padding: 15px;
        gap: 15px;
        margin-bottom: 20px;
    }

    .header-logo-area {
        margin-right: 0 !important;
        width: 100%;
        justify-content: space-between;
    }

    .nav-menu {
        width: 100%;
        overflow-x: auto; /* Horizontal scroll for nav items */
        justify-content: flex-start;
        padding-bottom: 5px;
    }
    
    .nav-item {
        flex-shrink: 0;
    }

    .content-wrapper {
        flex-direction: column;
        overflow: visible; /* Let it flow */
    }

    .column {
        width: 100% !important;
        height: auto; /* Allow auto height */
        max-height: 400px; /* Cap list height so we can reach player */
        overflow-y: auto;
        margin-bottom: 20px;
        border-radius: 12px; /* Add radius back for mobile cards look */
        border: 1px solid rgba(255,255,255,0.05);
    }
    
    .categories-column, 
    .channels-column {
        height: 300px; /* Fix height for lists to be scrollable internally */
    }
    
    .preview-column {
        width: 100%;
        height: auto;
        overflow: visible;
    }
    
    .mini-player-container {
        position: sticky;
        top: 0;
        z-index: 100;
        margin-bottom: 20px;
    }
    
    /* 
       SETTINGS MOBILE 
    */
    .settings-layout {
        flex-direction: column;
        height: auto;
        min-height: 90vh;
        overflow: visible;
        width: 100%;
        border-radius: 0;
        margin-top: 20px; /* slight spacer */
    }
    
    .settings-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 15px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .settings-sidebar-header {
        display: none; /* Hide header text on mobile to save space */
    }
    
    .settings-nav {
        flex-direction: row;
        width: 100%;
        padding: 0;
        margin: 0;
    }
    
    .settings-nav-item {
        padding: 10px 15px;
        white-space: nowrap;
    }
    
    .settings-content-area {
        padding: 20px;
        overflow: visible;
    }
    
    .account-grid {
        flex-direction: column;
        gap: 20px;
    }
    
    .qr-card, .contact-card {
        width: 100%;
    }
    
    /* 
       ONBOARDING MOBILE 
    */
    .ob-central-layout {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    
    .center-hero-section {
        display: none; /* Hide hero on mobile, just show activation */
    }
    
    .center-activation-card {
        width: 100%;
        max-width: none;
    }
    
    /* 
       RADIO MOBILE 
    */
    .radio-body {
        flex-direction: column;
    }
    
    .radio-list-container {
        width: 100%;
        height: 300px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .radio-tuner-container {
        width: 100%;
        padding: 20px;
    }
}
