/* ================ TABLET (768px - 1199px) ================ */
@media (max-width: 1199px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .sidebar {
        transform: translateX(-100%);
        visibility: hidden;
        opacity: 0;
        box-shadow: none;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        visibility: visible;
        opacity: 1;
        box-shadow: var(--shadow-lg);
    }

    .header {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar-toggle {
        display: flex;
    }

    body.sidebar-collapsed .header { left: 0; }
    body.sidebar-collapsed .main-content { margin-left: 0; width: 100%; }
    
    .sidebar-overlay {
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .admin-name {
        display: none;
    }

    .admin-footer {
        margin-left: 0;
        width: 100%;
    }

    body.sidebar-collapsed .admin-footer {
        margin-left: 0;
        width: 100%;
    }
}

/* ================ MOBILE (< 768px) ================ */
@media (max-width: 767px) {
    .content-area {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .form-row, .form-row-3 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header h1 {
        font-size: 18px;
        word-break: break-word;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar .form-control {
        width: 100%;
        min-width: auto;
    }

    .export-btns {
        margin-left: 0;
        justify-content: flex-start;
    }

    .datatable-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .datatable-search {
        max-width: none;
    }

    .datatable-pagination {
        flex-direction: column;
        align-items: center;
    }

    .login-card {
        padding: 24px;
    }

    .modal {
        margin: 10px;
        max-width: calc(100vw - 20px);
    }

    .btn-group {
        width: 100%;
    }

    .btn-group .btn {
        flex: 1;
        justify-content: center;
    }

    .header {
        padding: 0 16px;
    }

    .header-left h4 {
        font-size: 16px;
    }

    .card {
        padding: 16px;
        max-width: 100% !important;
        overflow-x: auto;
    }

    .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .card-header h3 {
        font-size: 14px;
    }

    .datatable {
        font-size: 12px;
    }

    .datatable th,
    .datatable td {
        padding: 8px 6px;
        white-space: nowrap;
    }

    #permissionsGrid {
        overflow-x: auto;
    }

    #permissionsGrid .datatable {
        min-width: 400px;
    }

    .theme-toggle span {
        display: none;
    }

    .theme-toggle {
        width: 36px;
        padding: 0;
    }
}
