/**
 * CEPR — Mobile / small-screen layout (admin + platform + auth)
 * Prevents horizontal page scroll; tables scroll inside their containers only.
 */

html {
    overflow-x: hidden;
}

body.cepr-admin-unified,
body.cepr-platform,
body.cepr-auth-page {
    overflow-x: hidden;
    max-width: 100vw;
}

/* —— Admin shell: drawer sidebar on small screens —— */
.cepr-admin-layout {
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.cepr-admin-main {
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.cepr-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.45);
}

.cepr-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border-radius: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.65);
    color: #111827;
    cursor: pointer;
    transition: background 0.15s ease;
}

.cepr-sidebar-toggle:hover {
    background: #fff;
}

.cepr-sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-left: auto;
    border: none;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
}

.cepr-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cepr-sidebar__head {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.cepr-sidebar__head .cepr-sidebar__brand {
    flex: 1;
    min-width: 0;
}

@media (max-width: 1023px) {
    .cepr-admin-layout .cepr-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 50;
        height: 100dvh;
        height: 100vh;
        width: min(85vw, 16rem);
        max-width: 16rem;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    }

    .cepr-admin-layout.cepr-sidebar-open .cepr-sidebar {
        transform: translateX(0);
    }

    body.cepr-admin-sidebar-open {
        overflow: hidden;
    }

    .cepr-admin-topbar {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .cepr-admin-topbar > div:last-child {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .cepr-admin-unified main {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .cepr-admin-unified .mx-6 {
        margin-left: 1rem !important;
        margin-right: 1rem !important;
    }
}

@media (min-width: 1024px) {
    .cepr-sidebar-backdrop,
    .cepr-sidebar-toggle,
    .cepr-sidebar-close {
        display: none !important;
    }
}

[x-cloak] {
    display: none !important;
}

/* —— Platform header & subnav —— */
.cepr-platform-header {
    padding-left: 1rem;
    padding-right: 1rem;
}

.cepr-platform-header__inner {
    max-width: 100%;
}

.cepr-platform-header__org-name {
    max-width: 100%;
}

@media (max-width: 639px) {
    .cepr-platform-header__org-name {
        font-size: 0.875rem;
    }

    .cepr-platform-subnav {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        overflow-x: visible;
        gap: 0.25rem;
    }

    .cepr-platform-subnav__link {
        padding: 0.4rem 0.65rem;
        font-size: 0.8125rem;
        white-space: normal;
        text-align: center;
        line-height: 1.25;
    }
}

/* —— Main content: contain wide children —— */
body.cepr-admin-unified main,
body.cepr-platform main {
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
}

body.cepr-admin-unified main img,
body.cepr-platform main img,
body.cepr-admin-unified main video,
body.cepr-platform main video {
    max-width: 100%;
    height: auto;
}

body.cepr-admin-unified main pre,
body.cepr-platform main pre,
body.cepr-admin-unified main .note-editor,
body.cepr-platform main .note-editor {
    max-width: 100%;
}

/* Tables: horizontal scroll only inside wrapper */
body.cepr-admin-unified .overflow-x-auto,
body.cepr-platform .overflow-x-auto,
body.cepr-admin-unified .table-responsive,
body.cepr-admin-unified .cepr-table-scroll {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

body.cepr-admin-unified main table,
body.cepr-platform main table {
    max-width: 100%;
}

/* Filter / toolbar rows */
@media (max-width: 639px) {
    .cepr-directory-toolbar > *,
    .cepr-filter-row > * {
        flex: 1 1 100%;
        min-width: 0 !important;
        width: 100%;
    }

    body.cepr-platform main .flex.flex-wrap > .min-w-\[200px\],
    body.cepr-platform main .flex.flex-wrap > .min-w-\[180px\],
    body.cepr-platform main .flex.flex-wrap > .min-w-\[12rem\] {
        min-width: 0 !important;
        width: 100%;
    }
}

/* User menu panel stays on screen */
@media (max-width: 479px) {
    .cepr-user-menu__panel {
        right: 0;
        left: auto;
        max-width: min(18rem, calc(100vw - 1.5rem));
    }
}

/* Guide */
.cepr-guide__nav-row,
.cepr-guide__step-actions {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cepr-guide__outline-grid {
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .cepr-guide__outline-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Auth */
@media (max-width: 1023px) {
    .cepr-auth {
        min-height: 100dvh;
    }

    .cepr-auth-brand {
        min-height: auto;
        padding: 1.5rem 1.25rem;
    }

    .cepr-auth main,
    .cepr-auth > section:not(.cepr-auth-brand) {
        padding: 1.25rem;
        max-width: 100%;
    }
}

/* Livewire / form grids */
body.cepr-admin-unified .grid,
body.cepr-platform .grid {
    min-width: 0;
}

body.cepr-admin-unified .cepr-legacy-page .card-body,
body.cepr-admin-unified .cepr-legacy-page .container-fluid {
    max-width: 100%;
    overflow-x: auto;
}
