/* Responsive layout — Magic UI SaaS */

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

img, video, canvas, svg {
    max-width: 100%;
}

/* ---- 1920 / wide desktop ---- */
@media (min-width: 1600px) {
    .page-content {
        max-width: 1520px;
        padding: 1.75rem 2.25rem 2.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* ---- 1440 ---- */
@media (max-width: 1440px) {
    .page-content {
        max-width: 1280px;
    }
}

/* ---- 1024 tablet landscape / small laptop ---- */
@media (max-width: 1024px) {
    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .topbar-search {
        min-width: 160px;
    }

    .topbar-user-name {
        display: none;
    }
}

/* ---- 900 sidebar collapse (matches app.css) ---- */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 88vw);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
        background: rgba(2, 6, 18, 0.65);
        backdrop-filter: blur(4px);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--surface);
        border-color: var(--border);
    }

    .page-content {
        padding: 1.15rem 1rem 1.75rem;
    }

    .topbar {
        padding: 0 0.85rem;
    }

    .topbar-actions .btn-label {
        display: none;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-bar input,
    .filters-bar select {
        min-width: 0 !important;
        width: 100%;
    }
}

/* ---- 768 tablet ---- */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card .value {
        font-size: 1.45rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
    }

    .card-header {
        flex-wrap: wrap;
    }

    .chart-wrap {
        height: 220px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}

/* ---- 600 / hide topbar search ---- */
@media (max-width: 600px) {
    .topbar h1 {
        font-size: 1rem;
    }

    .topbar-search {
        display: none !important;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .landing-hero {
        padding: 2rem 1rem !important;
    }
}

/* ---- 480 mobile ---- */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 1rem;
    }

    .page-content {
        padding: 1rem 0.75rem 1.5rem;
    }

    .btn-sm {
        padding: 0.35rem 0.65rem;
    }

    .topbar-actions {
        gap: 0.4rem;
    }

    .topbar-icon-btn {
        width: 34px;
        height: 34px;
    }

    .auth-card {
        padding: 1.5rem !important;
    }
}

/* ---- 375 small phones ---- */
@media (max-width: 375px) {
    .topbar h1 {
        font-size: 0.95rem;
        max-width: 140px;
    }

    .sidebar-brand span {
        font-size: 0.85rem;
    }

    .nav-link {
        font-size: 0.82rem;
    }
}

/* Prevent layout shift from sticky topbar */
.main-content {
    min-width: 0;
}

.table-wrap {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}
