/* Rota (/rota): centre Previous — week range — Next as one block (mobile + desktop) */
.rota-week-nav {
    justify-content: center;
    flex-wrap: wrap;
}

.rota-week-nav #week-range {
    text-align: center;
}

/* Rota: week range — larger + semi-bold on desktop only */
@media (min-width: 992px) {
    .rota-week-nav #week-range {
        font-size: 1.25rem;
        font-weight: 600;
    }
}

@media (max-width: 1199.98px) {

    /* Left Sidebar
    .content-area {
        min-width: 100%;
    }

    .layout-fullwidth .content-area {
        min-width: calc(100% - 245px);
    }

    .left-sidebar {
        min-width: 0;
        padding: 24px 0;
    }

    .layout-fullwidth .left-sidebar {
        min-width: 245px;
        padding: 24px 20px;
    } */
}

@media (max-width: 991.98px) {
    /* page-action-sidebar / FAB: see styles.css (linked after this file) */

    /*
     * Bottom inset for modal sheet: same as body padding-bottom (styles.css) — bar + safe-area once.
     * Top inset uses --mobile-sticky-header-offset (layout.js measures #header, incl. mobile title row).
     */
    html {
        /* Bottom bar height already includes safe-area padding (see styles.css). */
        --mobile-modal-bottom-reserved: var(--mobile-bottom-reserved, var(--mobile-bottom-bar-offset));
    }

    .module-grid {
        margin-top: 25px;
    }

    /*
     * Full-viewport .modal sits above #header (styles.css: .modal 2110 vs .header 2000), so the navbar
     * sits under an invisible layer and sticky no longer behaves. Pin it above the modal while open.
     * Keep z-index below .mobile-page-actions (7000) so the bottom bar stays on top.
     */
    body:not(.inertia-app-layout).modal-open #header.header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100vw;
        z-index: 8000;
        box-sizing: border-box;
    }

    /*
     * Header becomes position:fixed while a modal is open (see #header rule above). Without this,
     * that removes the header from normal flow and the page behind jumps up; on close it snaps back
     * (flicker). Padding matches --mobile-sticky-header-offset (set from measured #header in layout).
     */
    body:not(.inertia-app-layout).modal-open {
        padding-top: var(--mobile-sticky-header-offset, 118px);
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    /* iOS / some browsers scroll the root element; keep the page behind the sheet from moving */
    @supports selector(:has(*)) {
        html:has(body:not(.inertia-app-layout).modal-open) {
            overflow: hidden !important;
            overscroll-behavior: none;
            min-height: var(--app-shell-height, 100dvh);
        }
    }

    /*
     * Modal sheet: inset from top by fixed header stack, from bottom by mobile action bar.
     * Override Bootstrap .modal-dialog-centered min-height: calc(100% - …), which otherwise fills the viewport.
     */
    .modal .modal-dialog:not([class*="modal-fullscreen"]) {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        /* Sheet should start directly under the breadcrumb/title stack. */
        margin-top: var(--mobile-sticky-header-offset, 118px) !important;
        margin-bottom: var(--mobile-modal-bottom-reserved) !important;
        height: calc(var(--app-shell-height, 100dvh) - var(--mobile-sticky-header-offset, 118px) - var(--mobile-modal-bottom-reserved)) !important;
        max-height: calc(var(--app-shell-height, 100dvh) - var(--mobile-sticky-header-offset, 118px) - var(--mobile-modal-bottom-reserved)) !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
    }

    .modal .modal-dialog:not([class*="modal-fullscreen"]) .modal-content {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        width: 100% !important;
        align-self: stretch !important;
        display: flex !important;
        flex-direction: column !important;
        overflow-x: clip !important;
        overflow-y: hidden !important;
    }

    @supports not (overflow: clip) {
        .modal .modal-dialog:not([class*="modal-fullscreen"]) .modal-content {
            overflow-x: visible !important;
        }
    }

    .modal .modal-dialog:not([class*="modal-fullscreen"]) .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: clip;
    }

    /* Mobile: keep a small inner gutter so content isn't flush to edges. */
    .modal .modal-dialog:not([class*="modal-fullscreen"]) .modal-header,
    .modal .modal-dialog:not([class*="modal-fullscreen"]) .modal-body {
        padding-left: 0.9rem !important;
        padding-right: 0.9rem !important;
    }

    /* Booking modals: neutralize Bootstrap row negative margins so modal padding is respected */
    .bookings-edit-booking-modal .modal-body > .row,
    .bookings-new-booking-modal .modal-body > .row {
        margin-left: 0;
        margin-right: 0;
    }

    /* Footer actions mirrored into the mobile bottom bar (layout.js); hide duplicate footer chrome */
    .modal .modal-footer {
        display: none !important;
    }

    .modal .modal-header .btn-close {
        display: none !important;
    }

    .modal {
        --bs-modal-padding: 1.125rem;
        --bs-modal-margin: 0;
        /* No open/close animation on phones (Bootstrap fade + dialog transform) */
        --bs-modal-transition: none;
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        overflow: hidden !important;
    }

    .modal.fade {
        transition: none !important;
    }

    .modal.fade .modal-dialog {
        transition: none !important;
        transform: none !important;
    }

    .modal-backdrop {
        display: none !important;
        pointer-events: none !important;
    }

    .modal-content {
        border-radius: 0 !important;
    }

    /*
     * Event modals: native file “Browse…” is often shorter than the .form-control box on mobile.
     * Stretch the upload button to the same min-height as other inputs (WebKit + Firefox).
     */
    #event_cover_image.form-control[type="file"],
    #edit_event_cover_image.form-control[type="file"] {
        --bookings-event-cover-file-h: calc(1.5em + 0.75rem * 2 + 2px);
        min-height: var(--bookings-event-cover-file-h);
        padding: 0 0.75rem 0 0;
        line-height: 1.5;
    }

    #event_cover_image.form-control[type="file"]::file-selector-button,
    #edit_event_cover_image.form-control[type="file"]::file-selector-button {
        min-height: var(--bookings-event-cover-file-h);
        margin-right: 0.75rem;
        padding: 0.375rem 0.9rem;
        border: 0;
        border-right: 1px solid var(--bs-border-color);
        border-radius: var(--bs-border-radius, 2px) 0 0 var(--bs-border-radius, 2px);
        background-color: var(--bs-tertiary-bg);
        color: var(--bs-body-color);
        font: inherit;
        font-weight: 500;
        cursor: pointer;
    }

    #event_cover_image.form-control[type="file"]::-webkit-file-upload-button,
    #edit_event_cover_image.form-control[type="file"]::-webkit-file-upload-button {
        min-height: var(--bookings-event-cover-file-h);
        margin-right: 0.75rem;
        padding: 0.375rem 0.9rem;
        border: 0;
        border-right: 1px solid var(--bs-border-color);
        border-radius: var(--bs-border-radius, 2px) 0 0 var(--bs-border-radius, 2px);
        background-color: var(--bs-tertiary-bg);
        color: var(--bs-body-color);
        font: inherit;
        font-weight: 500;
        cursor: pointer;
    }

    #edit_booking #edit_booking_customer_mobile_host {
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
    }

    #edit_booking #edit_booking_customer_mount {
        max-width: 100%;
    }

    /* Mobile: keep modal header visible (no breadcrumb mirroring needed). */
    .modal-dialog:not([class*="modal-fullscreen"]) .modal-header:not(.d-none) {
        display: flex !important;
    }
    .modal-dialog:not([class*="modal-fullscreen"]) .modal-header.d-none {
        display: none !important;
    }

    /* Mobile modals: style header title/subtitle like mobile header */
    .modal .modal-header .modal-title {
        font-size: 1.13rem !important;
        line-height: 1.22 !important;
        font-weight: 700 !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }

    /* Many booking titles are "Title<br><small>Subtitle</small>" */
    .modal .modal-header .modal-title br {
        display: none;
    }

    .modal .modal-header .modal-title small {
        display: block;
        margin-top: 0.2rem;
        font-size: 0.8125rem !important;
        line-height: 1.28 !important;
        font-weight: 500 !important;
        color: rgba(255, 255, 255, 0.88) !important;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        max-width: 100%;
    }

    .modal-backdrop.fade {
        transition: none !important;
    }

    /* Header: profile — inset from right edge; larger avatar (name hidden below lg) */
    .header .navbar-right > li:last-child {
        padding-right: 0.65rem !important;
    }

    .header .profile-dropdown img {
        width: 38px !important;
        height: 38px !important;
        max-width: 38px;
    }

    .left-sidebar {
        position: fixed;
        z-index: 11 !important;
        top: 136px;
        height: 100%;
        left: -250px;
    }

    body.open .left-sidebar {
        left: 0;
        padding: 24px;
        width: 245px;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--sidebar-overlay-bg);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
        z-index: 10;
    }

    body.open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    .content-area {
        min-width: 100%;
    }

    /* Page Heading */
    .page-heading .welcome-text p {
        font-size: 14px;
    }

    /* Modules */
    .page-modules .module-item .module-title {
        font-size: 16px;
    }

    .modal .page-modules .module-item .module-box {
        padding: 27px;
    }
    .modal .page-modules .module-item .module-box svg {
        height: 50px;
        width: 50px;
    }
}

@media (max-width: 767.98px) {
    .row > * {
        padding-right: calc(var(--bs-gutter-x) * .2);
        padding-left: calc(var(--bs-gutter-x) * .2);
    }

    /* Timeline: extra inset on small viewports (booking modals override below to match form columns) */
    .bsb-timeline-1 {
        padding-left: 20px;
        padding-right: 20px;
        box-sizing: border-box;
    }

    #new_booking .bsb-timeline-1,
    #edit_booking .bsb-timeline-1 {
        padding-left: 0;
        padding-right: 0;
    }

    /* Match form columns: inner row uses normal gutters + minimal pl for the rail dot (theme uses 1rem) */
    #new_booking .bookings-timeline-mobile-collapse .bsb-timeline-1 .timeline > .timeline-item .timeline-content,
    #edit_booking .bookings-timeline-mobile-collapse .bsb-timeline-1 .timeline > .timeline-item .timeline-content {
        padding-left: calc(var(--bsb-tl-circle-offset, 9px) + 0.3rem) !important;
    }

    .content-area {
        padding-top: 0;
    }

    /* Drop Bootstrap g-* vertical gutter above the first main column (paired row + col reset) */
    .content-area > .container-fluid > .row:first-child {
        margin-top: 0 !important;
    }

    .content-area > .container-fluid > .row:first-child > .col-12:first-child {
        margin-top: 0 !important;
    }

    .content-area > div {
        padding: 0 !important;
    }

    footer.small {
        margin-top: 0 !important;
    }

    #module-search {
        margin-top: 1.5rem !important;
    }

    /* Header — logo matches desktop max width on small screens; scales down on very narrow viewports */
    .header .logo {
        width: min(58vw, 190px);
        min-width: 0;
        padding-right: 12px;
    }

    .header .logo img {
        max-width: 100%;
        width: 100%;
        height: auto;
    }
    .header .logo small {
        line-height: normal;
    }
    .page-modules .module-item .module-box,
    .modal .page-modules .module-item .module-box{
        padding: 26px;
    }
    .modal .page-modules .module-item .module-box svg {
        height: 40px;
        width: 40px;
    }

    .header .dropdown-menu.notifications {
        width: 300px;
        overflow-y: auto;
    }

    .header .dropdown-menu.notifications a {
        width: 276px;
    }

    .page-breadcrumbs {
        top: 61px;
    }

    /* Modules */
    .left-sidebar {
        top: 104px;
    }
    body.open .left-sidebar {
        width: 280px;
    }
    .left-sidebar .nav-sidebar{
        width: 100%;
    }

    .sub-layout .content-wrapper {
        background-color: var(--bs-body-bg);
    }

    .inner-layout .left-bar {
        height: calc(var(--app-shell-height, 100dvh) - 104px);
    }

    .sub-layout .body-area {
        border-radius: 0;
        width: 100%;
        height: calc(var(--app-shell-height, 100dvh) - 106px);
    }

    .sub-layout .body-area .ai-image-card {
        width: 100%;
    }

    .login-container > .row{
        min-height: var(--app-shell-height, 100dvh);
    }

    /* table list and mobile grid view */
    .table-row-grid tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 5px;
        padding: 16px 0;
    }

    .table-row-grid tr td {
        width: 100%;
        text-align: center;
    }

    .event-list tr td img {
        width: 330px !important;
    }

    .page-modules .module-item {
        width: calc(50% - 0.5rem);
    }

    .page-modules .module-item .module-box {
        padding: 18px;
    }

    .page-modules .module-item .module-title {
        font-size: 0.95rem;
        line-height: 1.25rem;
    }

    .content-area .container-fluid,
    .page-heading .container,
    .page-modules .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* Main page cards: use full viewport width on phones */
    .content-wrapper .content-area > .container-fluid > .row > .col-12 > .card {
        border-radius: 0 !important;
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        border-left: 0;
        border-right: 0;
    }

    /* Mobile: card headers should visually match breadcrumb sizing/spacing */
    .card-header {
        min-height: 56px;
        padding: 0.5rem 0.75rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        line-height: 1.2;
    }

    .card-header,
    .card-header .card-title,
    .card-header h1,
    .card-header h2,
    .card-header h3,
    .card-header h4,
    .card-header h5,
    .card-header h6 {
        font-weight: 600;
        font-size: 1.1rem;
    }

    .mobile-header-actions {
        width: 100%;
    }

    .mobile-header-actions .btn {
        width: 100%;
    }

    /* Checklist date/signed footer: centred, more space between stacked blocks */
    .checklist-signoff-col {
        text-align: center;
    }

    .checklist-signoff-col + .checklist-signoff-col {
        margin-top: 1.75rem !important;
    }

    .checklist-signoff-col + .checklist-signoff-col .form-label {
        margin-bottom: 0.5rem; /* mb-2: space below “Signed” before signature line */
    }

    /* Checklist fill: 2-column section header | control layout (section title in first th) */
    .checklist-mobile-table table {
        display: block;
        width: 100%;
        margin-bottom: 0;
    }

    .checklist-mobile-table thead,
    .checklist-mobile-table tbody {
        display: block;
        width: 100%;
    }

    .checklist-mobile-table thead tr,
    .checklist-mobile-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(96px, 140px);
        align-items: center;
        width: 100%;
    }

    .checklist-mobile-table thead tr {
        background-color: var(--checklist-section-bg);
        color: var(--checklist-section-color);
    }

    .checklist-mobile-table thead th {
        border: none !important;
        padding: 0.65rem 0.85rem;
        font-weight: 700;
    }

    .checklist-mobile-table thead th.checklist-section-th {
        font-size: 1.1rem;
        line-height: 1.25;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        text-align: left;
    }

    .checklist-mobile-table thead th.checklist-section-th-spacer {
        font-size: 0;
        font-weight: 700;
    }

    .checklist-mobile-table thead th:first-child {
        text-align: left;
    }

    .checklist-mobile-table thead th:last-child {
        text-align: center;
    }

    .checklist-mobile-table tbody tr {
        border: none;
        border-bottom: 1px solid var(--border-subtle);
        border-radius: 0;
        margin-bottom: 0;
        padding: 0;
        background: var(--table-card-bg);
    }

    .checklist-mobile-table tbody tr:last-child {
        border-bottom: none;
    }

    .checklist-mobile-table tbody tr td {
        display: block;
        width: 100%;
        border: 0;
        padding: 0.65rem 0.85rem;
        text-align: left !important;
        vertical-align: middle;
    }

    .checklist-mobile-table tbody tr td:last-child {
        border-left: 1px solid var(--checklist-cell-border);
        text-align: center !important;
        align-self: stretch;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--table-row-odd-bg);
    }

    .checklist-mobile-table .checklist_item {
        justify-content: center;
        width: 100%;
    }

    .logbook-mobile-table tbody tr td:first-child {
        font-weight: 700;
    }
}

/* ── Touch-target accessibility (mobile) ──────────────────────────── */
@media (max-width: 767.98px) {
    /* Ensure all tappable elements meet the 44×44px minimum */
    .btn,
    .nav-link,
    .dropdown-item,
    .page-link,
    .list-group-item-action,
    .mobile-table-cards td[data-mobile-label],
    a.badge {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Dropdown items and nav links should be block-level flex */
    .dropdown-item,
    .nav-link,
    .list-group-item-action {
        display: flex;
    }
}