/* 
 * Layout Responsive CSS - للتصميم المتجاوب الخاص بالـ Layout
 * تم نقل هذا الملف خارج Razor لتجنب مشاكل @@ syntax
 */

/* Navbar responsive improvements */
.navbar {
    padding: 0.75rem 1rem;
}

.navbar-collapse {
    flex-grow: 0;
}

.nav-item .badge {
    font-size: 0.7rem;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
}

/* Academic year indicator responsive */
.badge.bg-light {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

/* Notifications dropdown responsive */
.dropdown-menu {
    min-width: 280px;
    max-width: 90vw;
    max-height: 60vh;
    overflow-y: auto;
}

/* Large screens (1200px and up) */
@media (min-width: 1200px) {
    .sidebar-header .ess-logo {
        max-height: 70px;
        max-width: 180px;
    }
    
    .navbar-brand .ess-logo {
        height: 45px;
    }
    
    .badge.bg-light {
        font-size: 0.95rem;
        padding: 0.6rem 1.2rem;
    }
}

/* Medium screens (992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .sidebar-header .ess-logo {
        max-height: 60px;
        max-width: 150px;
    }
    
    .navbar-brand .ess-logo {
        height: 40px;
    }
    
    .badge.bg-light {
        font-size: 0.9rem;
        padding: 0.55rem 1.1rem;
    }
}

/* Small screens (768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .sidebar-header .ess-logo {
        max-height: 50px;
        max-width: 130px;
    }
    
    .navbar-brand .ess-logo {
        height: 35px;
    }
    
    .badge.bg-light {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .dropdown-menu {
        min-width: 250px;
    }
}

/* Mobile screens (less than 768px) */
@media (max-width: 767px) {
    .navbar {
        padding: 0.5rem 0.75rem;
    }
    
    .sidebar-header .ess-logo {
        max-height: 45px;
        max-width: 120px;
    }
    
    .navbar-brand .ess-logo {
        height: 30px;
    }
    
    .navbar-brand span {
        font-size: 0.9rem;
    }
    
    /* Academic year indicator mobile */
    .badge.bg-light {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        display: block;
        margin-bottom: 0.5rem;
    }
    
    .badge.bg-light i {
        display: none;
    }
    
    /* Stack navbar items */
    .navbar-nav {
        flex-direction: column;
        width: 100%;
    }
    
    .nav-item {
        margin-bottom: 0.5rem;
    }
    
    /* Notifications dropdown mobile */
    .dropdown-menu {
        position: fixed !important;
        top: 60px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
        transform: none !important;
        margin: 0 !important;
    }
    
    /* Sidebar toggle button mobile */
    #sidebarCollapse {
        padding: 0.5rem;
        font-size: 1.1rem;
    }
    
    #sidebarCollapse i {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Mobile sidebar positioning and behavior */
    #sidebar {
        position: fixed !important;
        left: -270px !important;
        top: 0 !important;
        height: 100vh !important;
        z-index: 10001 !important;
        transition: all 0.3s ease !important;
        min-width: 270px !important;
        max-width: 270px !important;
        pointer-events: auto !important;
    }
    
    #sidebar.show {
        left: 0 !important;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5) !important;
        pointer-events: auto !important;
    }
    
    /* Ensure sidebar content is interactive */
    #sidebar * {
        pointer-events: auto !important;
    }
    
    #sidebar .nav-link,
    #sidebar .dropdown-item,
    #sidebar button,
    #sidebar a {
        pointer-events: auto !important;
        cursor: pointer !important;
    }
    
    .page-content {
        margin-right: 0 !important;
        width: 100% !important;
        padding: 0 10px !important;
    }
    
    /* Mobile overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 10000;
        pointer-events: auto;
        cursor: pointer;
    }
    
    .sidebar-overlay.show {
        display: block !important;
        pointer-events: auto !important;
    }
    
    /* Ensure accountant and inventory menus work properly on mobile */
    #sidebar.accountant-menu,
    #sidebar.inventory-menu {
        position: fixed !important;
        left: -270px !important;
        transform: none !important;
        animation: none !important;
    }
    
    #sidebar.accountant-menu.show,
    #sidebar.inventory-menu.show {
        left: 0 !important;
        transform: translateX(0) !important;
    }
    
    /* Force mobile behavior for all sidebar types */
    #sidebar.mobile-ready {
        position: fixed !important;
        left: -270px !important;
        top: 0 !important;
        height: 100vh !important;
        z-index: 10001 !important;
        transform: none !important;
        animation: none !important;
    }
    
    #sidebar.mobile-ready.show {
        left: 0 !important;
    }
    
    /* Ensure sidebar content is always accessible on mobile */
    #sidebar.mobile-ready *,
    #sidebar.mobile-ready .nav-link,
    #sidebar.mobile-ready .dropdown-item,
    #sidebar.mobile-ready button,
    #sidebar.mobile-ready a {
        pointer-events: auto !important;
        cursor: pointer !important;
    }
}

/* Extra small screens (less than 576px) */
@media (max-width: 575px) {
    .navbar {
        padding: 0.4rem 0.5rem;
    }
    
    .navbar-brand {
        font-size: 0.85rem;
    }
    
    .navbar-brand .ess-logo {
        height: 25px;
    }
    
    .sidebar-header .ess-logo {
        max-height: 40px;
        max-width: 100px;
    }
    
    .badge.bg-light {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }
    
    .dropdown-menu {
        left: 5px !important;
        right: 5px !important;
    }
    
    /* Footer responsive */
    .footer .row {
        text-align: center;
    }
    
    .footer .col-md-6 {
        margin-bottom: 1rem;
    }
    
    .footer .social-links a {
        margin: 0 0.5rem;
    }
}

/* Charts Responsive Fixes */
.chart-container {
    position: relative !important;
    overflow: hidden !important;
    display: block !important;
}

.chart-container canvas {
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
}

/* Prevent chart overflow and infinite scaling */
canvas {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* Financial Dashboard specific fixes */
#revenueExpensesChart,
#expenseDistributionChart {
    max-width: 100% !important;
    max-height: 300px !important;
    width: auto !important;
    height: auto !important;
}

/* Responsive chart containers */
@media (max-width: 767px) {
    .chart-container {
        height: 250px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }
    
    #revenueExpensesChart,
    #expenseDistributionChart {
        max-height: 250px !important;
    }
    
    /* Stack charts vertically on mobile */
    .row .col-md-8,
    .row .col-md-4 {
        margin-bottom: 1rem;
    }
}

@media (max-width: 575px) {
    .chart-container {
        height: 200px !important;
    }
    
    #revenueExpensesChart,
    #expenseDistributionChart {
        max-height: 200px !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
    }
    
    /* Remove hover effects on touch devices */
    .hover-card:hover {
        transform: none;
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
    }
    
    /* Charts touch optimization */
    .chart-container {
        touch-action: manipulation;
    }
}
