/* Shared mobile/tablet adjustments. Keep overflow local to wide content. */
@media screen and (max-width: 1199.98px) {
    .main-wrapper, .layout-page, .content-wrapper,
    .card, .card-body, .row > *, .auth-form-container,
    .auth-form-wrapper, .profile-hero-content, .dataTables_wrapper,
    .content-grid > *, .coupons-grid > *, .prospects-grid > * {
        min-width: 0;
    }

    img, video, canvas, iframe, input, select, textarea {
        max-width: 100%;
    }

    video { height: auto; }

    h1, h2, h3, h4, h5, h6, p, label, .card-title,
    .breadcrumb-item, .alert, .list-group-item {
        overflow-wrap: anywhere;
    }

    pre, .table-responsive, .dataTables_scrollBody {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    /* Also cover legacy tables lacking Bootstrap's scroll wrapper. */
    table:not(.table-responsive table):not(.dataTables_scroll table):not(.custom-table table) {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    .table-responsive table { max-width: none; }

    .nav-tabs, .nav-pills, .form-wizard-steps,
    .pagination, .btn-toolbar, .dt-buttons {
        flex-wrap: wrap;
        gap: .375rem;
    }

    .form-wizard-steps {
        display: flex;
        padding-left: 0;
    }

    .form-wizard-steps li { margin-right: 0; }
    .card .d-flex.justify-content-between { flex-wrap: wrap; gap: .5rem; }

    .select2-container { max-width: 100%; }

    .modal-dialog {
        max-width: calc(100% - 2rem);
        margin-left: auto;
        margin-right: auto;
    }

    .modal-content { max-height: calc(100dvh - 2rem); }
    .modal-body { overflow-y: auto; min-height: 0; }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        max-width: 100%;
    }

    .dataTables_wrapper .dataTables_filter input {
        max-width: min(14rem, 60vw);
    }
}

@media screen and (max-width: 1199.98px) {
    /* The existing theme toggles this class on <html>. */
    html header .header-nav .main-menu-wrapper {
        display: block;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(320px, 90vw);
        height: 100vh;
        height: 100dvh;
        background: #fff;
        overflow-y: auto;
        visibility: hidden;
        transform: translateX(-100%);
        transition: transform .2s ease, visibility .2s ease;
        z-index: 1050;
    }

    html.menu-opened header .header-nav .main-menu-wrapper {
        visibility: visible;
        transform: translateX(0);
    }

    html.menu-opened { overflow: hidden; }

    html header .header-nav .main-menu-wrapper .main-nav {
        display: block;
        padding: 0 1rem;
    }
    html header .header-nav .main-menu-wrapper .menu-header { display: flex; }
    html header .navbar-header #mobile_btn { display: inline-flex; }
    .main-menu-wrapper .main-nav a { white-space: normal; }

    .sidebar-overlay.opened {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .4);
        z-index: 1040;
    }

    .auth-illustration, .auth-form-container { padding: 2rem; }
    .profile-hero .d-flex { flex-wrap: wrap; gap: .75rem; }
}

@media screen and (max-width: 767.98px) {
    .auth-container { flex-direction: column; min-height: 100dvh; }
    .auth-form-container { width: 100%; padding: 1.25rem; }
    .auth-form-wrapper { max-width: 100%; }
    .auth-form-wrapper { padding: 1.25rem; }
    .coupons-section, .coupon-card, .prospect-card { padding: 1rem; }
    .section-header { flex-wrap: wrap; gap: .75rem; }

    .breadcrumb-title, .hero-title, #titre-principal {
        font-size: clamp(1.5rem, 7vw, 2.5rem);
    }

    .breadcrumb { flex-wrap: wrap; }
    .profile-hero { padding: 1rem; }

    .btn, .form-control:not(textarea), .form-select,
    .main-menu-wrapper a, .list-group-item-action {
        min-height: 44px;
    }

    /* Prevent iOS from zooming the viewport when focusing a field. */
    input, select, textarea,
    input.form-control, textarea.form-control, select.form-control, .form-select {
        font-size: 16px;
    }
    .btn { white-space: normal; overflow-wrap: anywhere; }
    .btn-group { flex-wrap: wrap; max-width: 100%; }
    .input-group { min-width: 0; }
    .input-group > .form-control { min-width: 0; }

    .modal-dialog { max-width: calc(100% - 1rem); margin: .5rem auto; }
    .modal-content { max-height: calc(100dvh - 1rem); }
    .modal-header, .modal-footer { flex-wrap: wrap; gap: .5rem; }

    .swal2-popup { max-width: calc(100vw - 2rem); }
    #toast-container { max-width: calc(100vw - 1.5rem); }
    #toast-container > div { max-width: 100%; }

    .layout-navbar .navbar-nav-right { min-width: 0; }
    .layout-navbar .navbar-nav-right > .navbar-nav:first-child { min-width: 0; }
    .layout-navbar input { min-width: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .main-menu-wrapper { transition: none; }
}
