/* Responsive shell: mobile, tablet, laptop, desktop.
   Desktop look stays as-is above 1100px. */

html {
    -webkit-text-size-adjust: 100%;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

img, video, canvas, svg {
    max-width: 100%;
}

.dashboard-wrapper,
.main-content,
.content-body,
#ajax-content,
#default-dashboard-content {
    min-width: 0;
    max-width: 100%;
}

#ajax-content :where(div, section, article, form):has(> table) {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

input, select, textarea, button {
    max-width: 100%;
}

.edos-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    flex: 0 0 auto;
}

.edos-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1900;
}

body.edos-nav-open .edos-nav-backdrop {
    display: block;
}

/* Laptop: slightly tighter chrome, sidebar still visible */
@media (max-width: 1280px) {
    .content-body {
        padding-right: 16px;
    }
    .dashboard-header {
        padding: 0 16px;
    }
    .welcome-banner h1,
    .welcome-text h1 {
        font-size: clamp(1.15rem, 2.2vw, 1.6rem);
    }
}

/* Tablet and phone: sidebar becomes an overlay */
@media (max-width: 1100px) {
    .dashboard-wrapper {
        display: block;
    }

    .sidebar,
    .sidebar.collapsed {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 2000;
        width: min(86vw, 300px);
        height: 100vh;
        height: 100dvh;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        overflow: auto;
        scrollbar-width: none;
        background: #000000;
        padding-bottom: 16px;
    }

    .sidebar.collapsed .system-name,
    .sidebar.collapsed .user-name,
    .sidebar.collapsed .profile-info,
    .sidebar.collapsed .sidebar-nav span,
    .sidebar.collapsed .sidebar-nav .arrow {
        display: inline !important;
    }

    .sidebar.collapsed .sidebar-nav a {
        justify-content: flex-start;
        padding: 10px 15px;
    }

    body.edos-nav-open .sidebar {
        transform: none;
        box-shadow: 8px 0 28px rgba(15, 23, 42, 0.28);
    }

    .main-content,
    .content-body {
        width: 100%;
        margin-left: 0;
    }

    .edos-menu-btn {
        display: inline-flex;
    }

    .dashboard-header {
        height: auto;
        min-height: 56px;
        padding: 8px 12px;
        gap: 8px;
    }

    .welcome-banner,
    .welcome-banner > div {
        flex-direction: column !important;
    }

    .banner-icons {
        flex-wrap: wrap;
    }

    .col-left,
    .col-right,
    .stat-pair,
    .stats-row > * {
        min-width: 0 !important;
        flex: 1 1 100%;
    }

    .stats-row,
    .row {
        flex-direction: column;
    }

    /* Keep the add-form and its list side by side, tops aligned, until the screen is actually narrow. */
    .row:has(> .col-left):has(> .col-right) {
        flex-direction: row !important;
        align-items: flex-start !important;
        flex-wrap: nowrap !important;
    }

    .row:has(> .col-left):has(> .col-right) > .col-left {
        flex: 0 0 460px !important;
        width: 460px !important;
        max-width: 460px !important;
    }

    .row:has(> .col-left):has(> .col-right) > .col-right {
        flex: 1 1 auto !important;
        width: auto !important;
        max-width: none !important;
    }

    #ajax-content [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    #ajax-content [style*="display:flex"]:not(.edos-list-bar):not(.sd-pager),
    #ajax-content [style*="display: flex"]:not(.edos-list-bar):not(.sd-pager) {
        flex-wrap: wrap !important;
    }

    #ajax-content [style*="min-width"] {
        min-width: 0 !important;
    }

    .edos-list-bar,
    .sd-pager {
        flex-wrap: wrap !important;
        height: auto !important;
        row-gap: 8px;
    }

    .profile-icon span,
    .header-user-name {
        display: none;
    }
}

/* Phone */
@media (max-width: 640px) {
    .row:has(> .col-left):has(> .col-right) {
        flex-direction: column !important;
    }

    .row:has(> .col-left):has(> .col-right) > .col-left,
    .row:has(> .col-left):has(> .col-right) > .col-right {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .content-body {
        padding: 0 10px 16px 10px;
    }

    .dashboard-header {
        padding: 8px 10px;
    }

    h1, .welcome-text h1 {
        font-size: clamp(1.05rem, 5vw, 1.35rem);
        line-height: 1.25;
    }

    .card, .card-body, .modal-content, .custom-modal .modal-box {
        max-width: 100%;
    }

    .edos-list-bar,
    .sd-pager {
        justify-content: flex-start !important;
        padding: 8px !important;
        gap: 8px !important;
    }

    .edos-list-bar .edos-list-info,
    .sd-pager .edos-list-info {
        margin-left: 0 !important;
        width: 100%;
    }
}

/* Wide desktop keeps the fixed sidebar */
@media (min-width: 1101px) {
    .edos-menu-btn,
    .edos-nav-backdrop {
        display: none !important;
    }
}
