/* =====================================================
   RESPONSIVE DESIGN FIXES FOR ALL PAGES
   Mobile First Approach
===================================================== */

/* Base mobile styles (applies to all devices) */
:root {
    --mobile-spacing: 0.75rem;
    --tablet-spacing: 1rem;
    --desktop-spacing: 1.5rem;
}

/* Extra small devices (phones, 576px and down) */
@media (max-width: 576px) {
    /* General Layout */
    .wrapper {
        flex-direction: column;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: var(--mobile-spacing) !important;
        width: 100% !important;
    }
    
    /* Sidebar Mobile Menu */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: -100%;
        width: 85% !important;
        max-width: 300px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    .sidebar.active {
        left: 0 !important;
    }
    
    .sidebar-logo img {
        max-width: 120px !important;
    }
    
    .sidebar-menu-item {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Mobile Menu Toggle */
    .menu-toggle {
        display: flex !important;
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 1060;
        width: 40px;
        height: 40px;
        background: var(--neon-green);
        color: var(--dark-bg);
        border: none;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }
    
    /* Top Navigation */
    .top-nav {
        margin-top: 3.5rem !important;
        padding: 0.75rem !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    .page-title {
        font-size: 1.25rem !important;
        text-align: center;
    }
    
    .user-info {
        width: 100%;
        justify-content: center !important;
        flex-wrap: wrap;
    }
    
    .user-name {
        display: none !important;
    }
    
    /* Cards */
    .card {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .card-header {
        flex-direction: column !important;
        gap: 0.75rem !important;
        text-align: center;
    }
    
    .card-title {
        font-size: 1.1rem !important;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    
    .stat-card {
        padding: 1rem !important;
    }
    
    .stat-icon {
        width: 50px !important;
        height: 50px !important;
    }
    
    .stat-icon i {
        font-size: 1.5rem !important;
    }
    
    .stat-content h3 {
        font-size: 1.5rem !important;
    }
    
    /* Grid System */
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Tables */
    .table-responsive {
        margin: 0 -1rem;
        width: calc(100% + 2rem);
    }
    
    .table {
        font-size: 0.85rem !important;
    }
    
    .table th, 
    .table td {
        padding: 0.5rem !important;
        white-space: nowrap;
    }
    
    /* Forms */
    .form-control, 
    .form-select {
        font-size: 16px !important; /* Prevents zoom on mobile */
        padding: 0.6rem !important;
    }
    
    .input-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .input-group .form-control {
        border-radius: 8px !important;
    }
    
    /* Buttons */
    .btn {
        width: 100% !important;
        margin: 0.25rem 0 !important;
        padding: 0.75rem !important;
        font-size: 0.95rem !important;
    }
    
    .btn-group {
        flex-direction: column !important;
        width: 100%;
    }
    
    .btn-group .btn {
        border-radius: 8px !important;
        margin: 0.25rem 0 !important;
    }
    
    /* Attendance Card */
    .attendance-card .row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .attendance-card .col-md-4 {
        width: 100% !important;
        text-align: center !important;
    }
    
    /* Task Items */
    .task-item {
        padding: 0.75rem !important;
    }
    
    .task-header {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: flex-start !important;
    }
    
    .task-meta {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
    
    /* Modal */
    .modal-content {
        width: 95% !important;
        margin: 1rem auto !important;
        max-height: 90vh !important;
    }
    
    .modal-body {
        padding: 1rem !important;
    }
    
    .modal-footer {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .modal-footer .btn {
        width: 100% !important;
        margin: 0 !important;
    }
    
    /* Login Page */
    .login-container {
        padding: 1rem !important;
    }
    
    .login-card {
        padding: 1.5rem !important;
        width: 100% !important;
    }
    
    .login-logo img {
        max-width: 120px !important;
    }
    
    .login-title h2 {
        font-size: 1.5rem !important;
    }
    
    /* Dashboard Specific */
    .display-4 {
        font-size: 2rem !important;
    }
    
    .display-6 {
        font-size: 1.25rem !important;
    }
    
    /* Filter Forms */
    .filter-form .row {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .filter-form .col-md-3,
    .filter-form .col-md-4,
    .filter-form .col-md-6 {
        width: 100% !important;
    }
    
    /* Holiday Calendar */
    .holiday-table td {
        display: block;
        width: 100%;
        text-align: left;
        padding: 0.5rem !important;
        border: none;
    }
    
    .holiday-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 0.5rem;
    }
    
    /* Reports */
    .report-card {
        padding: 1rem !important;
    }
    
    .nav-tabs {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .nav-tabs .nav-link {
        width: 100% !important;
        text-align: center;
    }
    
    /* Charts */
    canvas {
        max-height: 250px !important;
    }
    
    /* Quick Actions */
    .quick-actions {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .quick-actions .btn {
        width: 100% !important;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-link {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Alerts */
    .alert {
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Dropdown */
    .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100%;
        border-radius: 20px 20px 0 0 !important;
        transform: none !important;
    }
    
    /* Tabs */
    .tab-content {
        padding: 1rem 0 !important;
    }
    
    /* Progress Bars */
    .progress {
        height: 6px !important;
    }
}

/* Small devices (tablets, 577px to 768px) */
@media (min-width: 577px) and (max-width: 768px) {
    .main-content {
        margin-left: 0 !important;
        padding: 1rem !important;
    }
    
    .sidebar {
        width: 240px !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .btn {
        width: auto !important;
    }
    
    .table {
        font-size: 0.9rem !important;
    }
    
    .table th, 
    .table td {
        padding: 0.6rem !important;
    }
    
    .modal-content {
        width: 90% !important;
    }
}

/* Medium devices (desktops, 769px to 992px) */
@media (min-width: 769px) and (max-width: 992px) {
    .main-content {
        margin-left: 260px !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-3, .grid-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Landscape mode for phones */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 60% !important;
    }
    
    .modal-content {
        max-height: 80vh !important;
        overflow-y: auto !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Fix for very small devices (320px and down) */
@media (max-width: 320px) {
    .stat-icon {
        width: 40px !important;
        height: 40px !important;
    }
    
    .stat-icon i {
        font-size: 1.2rem !important;
    }
    
    .stat-content h3 {
        font-size: 1.2rem !important;
    }
    
    .stat-content p {
        font-size: 0.75rem !important;
    }
    
    .btn {
        padding: 0.6rem !important;
        font-size: 0.85rem !important;
    }
    
    .card-title {
        font-size: 1rem !important;
    }
}