/* 
   📱 MOBILE RESPONSIVE OVERRIDES
   Academy Portal system-wide optimization
*/

/* --- Base Enhancements --- */
:root {
    --safe-area-inset-bottom: env(safe-area-inset-bottom);
}

/* --- Flash Messages & Alerts --- */
.flash-messages {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 10001; /* Above almost everything */
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border: 1px solid transparent;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease-out;
}

.alert-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10B981;
}

.alert-error, .alert-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.05) 100%);
    border-color: rgba(239, 68, 68, 0.3);
    color: #EF4444;
}

.alert-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-color: rgba(245, 158, 11, 0.3);
    color: #F59E0B;
}

.alert-info {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.15) 0%, rgba(56, 189, 248, 0.05) 100%);
    border-color: rgba(56, 189, 248, 0.3);
    color: #38BDF8;
}

@media (max-width: 768px) {
    /* 1. Reset Global Containers */
    .container {
        padding: 1rem 0.5rem 5rem 0.5rem !important;
        overflow-x: hidden !important;
    }

    /* 2. Nuclear Grid & Flex Stacking */
    .grid, 
    [style*="display: grid"], 
    .responsive-grid,
    .responsive-grid-search,
    .responsive-grid-form,
    .form-grid-inner {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Universal Flex Stacking (except for small groups that should stay side-by-side) */
    [style*="display: flex"]:not(.no-stack):not(.ticker-wrap):not(.btn-group):not(.pagination):not(.header-content):not(.header-right):not(.user-info):not(.auth-links) {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    /* Ensure specific inline groups STAY inline */
    .header-right, .btn-group, .pagination, .auth-links, .user-info {
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
    }

    /* 6. Shell & Navigation */
    .sidebar {
        width: 280px !important;
        max-width: 85vw !important;
        left: -281px !important;
        position: fixed !important;
        top: 0; bottom: 0;
        transition: left 0.3s ease !important;
        z-index: 2000 !important;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5) !important;
    }
    .sidebar.active { left: 0 !important; }
    
    .responsive-grid-wrapper {
        grid-template-columns: 1fr !important;
        display: block !important;
        position: relative !important; /* Allow natural scrolling */
        height: auto !important;
        min-height: 100vh;
        overflow: visible !important;
    }

    .main-content-wrapper, .main-wrapper {
        width: 100% !important;
        margin-left: 0 !important;
        padding-bottom: 5rem !important;
        overflow: visible !important;
        position: relative !important;
    }

    .hamburger { 
        display: block !important; 
        cursor: pointer;
        padding: 8px;
        background: rgba(255,255,255,0.05);
        border-radius: 6px;
        color: white;
    }

    .location-time { display: none !important; }
    .mobile-hide { display: none !important; }
    .sidebar-overlay { 
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.6); z-index: 1500; backdrop-filter: blur(4px);
        display: none; visibility: hidden; pointer-events: none;
        transition: all 0.3s ease;
    }
    .sidebar-overlay.active {
        display: block !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    /* Advanced About Button Scaling (Final Failsafe) */
    #floatingAboutBtn, .floating-about-btn {
        display: flex !important;
        position: fixed !important;
        right: -5px !important;
        top: 50% !important;
        transform: translateY(-50%) scale(0.75) !important;
        transform-origin: right center !important;
        z-index: 99999 !important;
    }
}

    /* Reduce Glossy noise on mobile for better text clarity */
    .glossy-bg-overlay { opacity: 0.5 !important; }
    .watermark-overlay { opacity: 0.05 !important; }
}

/* --- Small Screen Optimization (iPhone SE etc.) --- */
@media (max-width: 375px) {
    .card {
        padding: 0.75rem !important;
    }
    
    .shortcut-btn {
        min-height: 90px !important;
        padding: 0.75rem !important;
    }
    
    .shortcut-btn .icon {
        font-size: 1.5rem !important;
    }

    .news-badge {
        display: none !important; /* Hide badge on tiny screens to save space */
    }
}

