/* ============================================================================
   ADMIN DASHBOARD — RESPONSIVE MEDIA QUERIES
   Mobile <= 768px | Tablet 769px - 1024px | Desktop 1025px+
   ============================================================================ */

/* ── Hamburger toggle button (hidden on desktop & tablet) ──────────────── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    background: var(--sidebar-bg, #1e293b);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: #334155;
}

/* Overlay behind the open sidebar on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1050;
}

.sidebar-overlay.active {
    display: block;
}

/* ── Table containers: always allow horizontal scroll ─────────────────── */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   DESKTOP — 1025px+
   ============================================================================ */
@media (min-width: 1025px) {
    /* Enforce exactly 3 cards per row on desktop */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ============================================================================
   TABLET — 769px to 1024px
   ============================================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Sidebar: collapse to icons */
    .sidebar {
        width: 80px;
        padding: 1.5rem 0.5rem;
        align-items: center;
    }

    .logo {
        margin-bottom: 2.5rem;
        justify-content: center;
    }
    
    .logo span {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .nav-item span {
        display: none;
    }

    .badge, .badge-3d {
        display: none !important;
    }

    .user-profile {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        padding-top: 1rem;
    }

    .user-info {
        display: none;
    }

    /* Stats grid: exactly 2 cards per row */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Main content styling */
    .main-content {
        padding: 1.5rem;
    }

    /* Header styling */
    .top-bar {
        align-items: center;
    }

    .search-box {
        width: auto;
    }
}

/* ============================================================================
   MOBILE — max-width: 768px
   ============================================================================ */
@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }

    /* Show hamburger */
    .sidebar-toggle {
        display: flex;
    }

    /* Sidebar: off-canvas drawer */
    .admin-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 260px;
        z-index: 1060;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        padding: 1.5rem;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Main content: full width, shift for hamburger button */
    .main-content {
        width: 100%;
        padding: 4.5rem 1rem 1.5rem;
        overflow-y: visible;
        min-height: 100vh;
    }

    /* Top bar: Stack elements */
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }

    .top-bar h2 {
        font-size: 1.5rem;
    }
    
    .date-display {
        font-size: 0.85rem;
    }

    /* Stats grid: 1 card per row */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .stat-card {
        padding: 1.25rem;
        border-radius: 12px;
    }

    /* Disable 3D tilt on touch devices */
    .stat-card:hover {
        transform: none !important;
    }

    /* Recent grid: stack */
    .recent-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem;
    }

    .glass-panel {
        padding: 1rem;
        border-radius: 12px;
    }

    /* Tables */
    .table-container {
        margin: 0;
        border-radius: 8px;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .data-table tbody tr:hover {
        transform: none !important;
    }

    /* Section headers */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .section-header h3 {
        font-size: 1.1rem;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
    }

    .btn-refresh {
        width: 100%;
        justify-content: center;
    }
    
    .action-buttons {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-action {
        width: 100%;
        text-align: center;
        justify-content: center;
        margin-right: 0;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    .modal-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-actions button {
        width: 100%;
        margin-left: 0;
    }
}