/*
 * App look on phones, tablets and computers (shared by OPS and OPS Master, same file in both):
 *  - the page never slides sideways and never zooms in by itself when a box is tapped
 *  - taps feel like an app (no grey flash, no double-tap delay)
 *  - room for the iPhone home bar when opened from the home screen
 *  - one loader for every page change (see rdt-app.js)
 */
html, body { max-width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
* { -webkit-tap-highlight-color: transparent; }
a, button, .btn, label, select, summary, [role="button"] { touch-action: manipulation; }
img, video, canvas, iframe { max-width: 100%; }

/* phones and tablets: boxes at 16px or more, so iPhone / iPad Safari does not zoom in (and push the page left) */
@media (max-width: 1199.98px) {
    input.form-control, textarea.form-control, select.form-select, .form-control, .form-select,
    .input-group > .form-control, .input-group > .form-select, .offcanvas .form-control, .offcanvas .form-select,
    .modal .form-control, .modal .form-select, .rdt-ss input { font-size: 16px !important; }
    .form-control-sm, .form-select-sm, .input-group-sm > .form-control, .input-group-sm > .form-select { font-size: 16px !important; padding-top: .3rem; padding-bottom: .3rem; }
}

/* opened from the home screen: leave room for the iPhone home bar at the bottom */
@supports (padding: max(0px)) {
    @media (display-mode: standalone) {
        body { padding-bottom: env(safe-area-inset-bottom); }
        .offcanvas-end, .offcanvas-start { padding-bottom: env(safe-area-inset-bottom); }
    }
}

/* nothing wider than the screen on phones */
@media (max-width: 767.98px) {
    .page-content, .main-content, .container-fluid { max-width: 100vw; }
    .table-responsive { -webkit-overflow-scrolling: touch; }
    pre, code { white-space: pre-wrap; word-break: break-word; }
}

/* ---- tables become cards (rdt-app.js): always on phones, and on any screen (iPad, small laptop) where the table
   would not fit and would scroll sideways. Every cell carries its column name (data-label).
   One card per row: the first cell is the title, then "label  value" lines, buttons and links at the bottom. */
.table-responsive:has(> table.rdt-cardview) { overflow: visible !important; }
table.rdt-cardview, table.rdt-cardview > tbody, table.rdt-cardview > tfoot, table.rdt-cardview > tbody > tr, table.rdt-cardview > tfoot > tr { display: block; width: 100%; }
table.rdt-cardview { border: 0; background: transparent; margin-bottom: 0 !important; }
table.rdt-cardview > thead { display: none; }
table.rdt-cardview > tbody > tr, table.rdt-cardview > tfoot > tr {
    background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: 12px;
    margin: 0 0 10px; padding: 10px 12px; box-shadow: 0 2px 8px rgba(16, 48, 58, .06); position: relative; }
table.rdt-cardview > tbody > tr > td, table.rdt-cardview > tbody > tr > th,
table.rdt-cardview > tfoot > tr > td, table.rdt-cardview > tfoot > tr > th {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; width: 100% !important;
    border: 0 !important; padding: 4px 0 !important; text-align: right !important; background: transparent !important;
    box-shadow: none !important; position: static !important; min-width: 0 !important; white-space: normal !important; font-size: .9rem; }
table.rdt-cardview > tbody > tr > [data-label]::before, table.rdt-cardview > tfoot > tr > [data-label]::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 48%; text-align: left; color: var(--bs-secondary-color, #6c757d);
    font-size: .8rem; font-weight: 500; padding-top: 1px; }
table.rdt-cardview > tbody > tr > [data-label=""]::before, table.rdt-cardview > tfoot > tr > [data-label=""]::before { content: none; }
table.rdt-cardview > tbody > tr > [data-label=""], table.rdt-cardview > tfoot > tr > [data-label=""] { justify-content: flex-end; }
/* the first cell is the card title */
table.rdt-cardview > tbody > tr > :first-child { display: block; text-align: left !important; font-weight: 600; font-size: .98rem;
    padding-bottom: 6px !important; margin-bottom: 4px; border-bottom: 1px solid var(--bs-border-color) !important; }
table.rdt-cardview > tbody > tr > :first-child::before { content: none !important; }
table.rdt-cardview > tbody > tr > :first-child:has(> input[type=checkbox]:only-child) { display: flex; border-bottom: 0 !important; padding-bottom: 0 !important; margin: 0; position: absolute !important; top: 10px; right: 12px; width: auto !important; }
/* empty cells and "no records" rows */
table.rdt-cardview > tbody > tr > :empty, table.rdt-cardview > tfoot > tr > :empty { display: none; }
table.rdt-cardview > tbody > tr.rdt-row-full > *, table.rdt-cardview > tfoot > tr.rdt-row-full > * { display: block; text-align: center !important; border: 0 !important; color: var(--bs-secondary-color); font-weight: 400; }
table.rdt-cardview > tbody > tr.rdt-row-full { box-shadow: none; border-style: dashed; }
/* totals at the bottom: a strong summary card */
table.rdt-cardview > tfoot > tr { background: var(--bs-tertiary-bg, #f3f6f9); font-weight: 700; }
table.rdt-cardview > tfoot > tr > :first-child { display: flex; justify-content: flex-start; text-align: left !important; border-bottom: 0 !important; margin: 0; padding-bottom: 4px !important; }
/* inputs, selects and buttons inside a card use the full width */
table.rdt-cardview td .form-control, table.rdt-cardview td .form-select, table.rdt-cardview td .input-group { width: 100%; max-width: 62%; }
table.rdt-cardview td:has(> .form-control, > .form-select, > .input-group) { align-items: center; }
table.rdt-cardview > tbody > tr > :first-child .form-control, table.rdt-cardview > tbody > tr > :first-child .form-select,
table.rdt-cardview > tbody > tr > :first-child .input-group { max-width: 100%; }
table.rdt-cardview td .btn-group, table.rdt-cardview td .d-flex { flex-wrap: wrap; justify-content: flex-end; }
/* wider screens (iPad): cards side by side */
@media (min-width: 576px) {
    table.rdt-cardview > tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
    table.rdt-cardview > tbody > tr { margin: 0; }
    table.rdt-cardview > tbody > tr.rdt-row-full { grid-column: 1 / -1; }
    table.rdt-cardview > tfoot > tr { margin-top: 12px; }
}
table.rdt-cardview tr.table-active, table.rdt-cardview tr.table-warning, table.rdt-cardview tr.table-danger, table.rdt-cardview tr.table-success { border-left: 4px solid var(--bs-primary); }

@media (max-width: 575.98px) {
    /* tables that must stay tables (data-no-cards): tighter, first column stays in view */
    table[data-no-cards] { font-size: .85rem; }
    table[data-no-cards] > * > tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--bs-body-bg); }
    .page-content .table th { min-width: 0 !important; }
}

/* ---- phones: bottom tab bar (rdt-app.js) ---- */
#rdt-tabbar { display: none; }
@media (max-width: 767.98px) {
    #rdt-tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035; background: rgba(255, 255, 255, .97);
        backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--bs-border-color);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 18px rgba(16, 48, 58, .08); }
    [data-bs-theme=dark] #rdt-tabbar { background: rgba(20, 30, 38, .97); }
    #rdt-tabbar > a, #rdt-tabbar > button { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 1px; border: 0; background: none;
        color: var(--bs-secondary-color, #6c757d); font-size: .68rem; font-weight: 600; text-decoration: none; padding: 2px 0; position: relative; }
    #rdt-tabbar i { font-size: 1.45rem; line-height: 1.1; }
    #rdt-tabbar .on, #rdt-tabbar > :active { color: #0B2545; }
    [data-bs-theme=dark] #rdt-tabbar .on { color: #e8a317; }
    #rdt-tabbar b { position: absolute; top: 0; left: 50%; margin-left: 6px; min-width: 17px; height: 17px; border-radius: 9px; background: #e8a317; color: #0B2545;
        font-size: .65rem; line-height: 17px; text-align: center; padding: 0 4px; }
    body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    body.has-tabbar .footer { margin-bottom: 0; }
}

/* ---- loader: a thin bar at the top at once, a small "Loading…" card if it takes longer ---- */
#rdt-loader { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 3000; pointer-events: none; opacity: 0; transition: opacity .2s; }
#rdt-loader.on { opacity: 1; }
#rdt-loader .bar { height: 100%; width: 0; background: linear-gradient(90deg, #e8a317, #f5c04a); box-shadow: 0 0 8px rgba(232, 163, 23, .6); }
#rdt-loader.on .bar { animation: rdtLoad 8s cubic-bezier(.1, .7, .2, 1) forwards; }
@keyframes rdtLoad { 0% { width: 0; } 20% { width: 45%; } 60% { width: 75%; } 100% { width: 92%; } }
#rdt-loader-card { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.96); z-index: 3001; pointer-events: none;
    background: rgba(11, 37, 69, .92); color: #fff; border-radius: 14px; padding: 16px 22px; display: flex; align-items: center; gap: 12px;
    font-weight: 600; font-size: .95rem; box-shadow: 0 16px 40px rgba(0, 0, 0, .25); opacity: 0; transition: opacity .2s, transform .2s; }
#rdt-loader-card.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#rdt-loader-card .spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #e8a317; animation: rdtSpin .8s linear infinite; }
@keyframes rdtSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #rdt-loader.on .bar { animation: none; width: 70%; } #rdt-loader-card .spin { animation-duration: 2s; } }

/* ---- the window of a "+" (add form over the page) ---- */
.rdt-qa-modal .modal-body { height: min(80vh, 900px); }
.rdt-qa-modal.rdt-qa-own-shade { background: rgba(15, 23, 42, .5); }
@media (max-width: 767.98px) { .rdt-qa-modal .modal-body { height: auto; flex: 1 1 auto; } .rdt-qa-modal iframe { min-height: 80vh; } }
/* inside that window: only the form (no menu, top bar, footer, notices) */
body.rdt-embed .vertical-menu, body.rdt-embed #page-topbar, body.rdt-embed .footer, body.rdt-embed #rdt-tabbar,
body.rdt-embed .page-title-box, body.rdt-embed .rdt-notices, body.rdt-embed .alert-info { display: none !important; }
body.rdt-embed .main-content { margin-left: 0 !important; }
body.rdt-embed .page-content { padding: 12px !important; }
body.rdt-embed { padding-bottom: 0 !important; }

/* "+ Add" chip at the end of a list of choices, and its little box */
.rdt-chip-add { border: 0; padding: 0; background: none; cursor: pointer; }
.rdt-chip-add span { border-style: dashed !important; color: var(--bs-primary); }
.rdt-chip-new { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rdt-chip-new .form-control { width: 190px; }
.rdt-chip-new small { flex-basis: 100%; }

/* card view: a group title row of a table (e.g. HOTELS in the permissions) is a heading, not a card */
table.rdt-cardview > tbody > tr.table-group-divider { background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 10px 2px 2px !important; margin: 6px 0 4px; grid-column: 1 / -1; }
table.rdt-cardview > tbody > tr.table-group-divider > * { text-align: left !important; font-weight: 700; color: var(--bs-primary) !important; letter-spacing: .04em; border: 0 !important; padding: 0 !important; }

/* phones: the side menu ends above the bottom tab bar, so its last items can be reached */
@media (max-width: 767.98px) {
    body.has-tabbar .vertical-menu { bottom: calc(64px + env(safe-area-inset-bottom)) !important; height: auto !important; }
    body.has-tabbar .vertical-menu .simplebar-content-wrapper, body.has-tabbar .vertical-menu [data-simplebar] { max-height: 100%; }
}

/* own features of one room (room categories, several at once) */
.rdt-row-feats { margin: 8px 0 4px; padding: 10px 12px; border: 1px dashed rgba(var(--bs-primary-rgb), .45); border-radius: 10px; background: rgba(var(--bs-primary-rgb), .04); }
.rdt-row-feats .rdt-checks { display: flex; flex-wrap: wrap; gap: 6px; }
.rdt-row-feat-btn.active, .rdt-row-feat-btn.active:hover, .rdt-row-feat-btn.active:focus { background: var(--bs-primary) !important; border-color: var(--bs-primary) !important; color: #fff !important; opacity: 1; }

/* several at once, one row per item (room categories: name · size · beds · Features · ×) */
.rdt-mrows { display: flex; flex-direction: column; gap: 8px; }
.rdt-mrow-line { display: grid; gap: 6px; align-items: center; grid-template-columns: minmax(0, 1fr) auto auto; }
.rdt-mrow-line.rdt-mrow-c1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 120px 40px; }
.rdt-mrow-line.rdt-mrow-c2 { grid-template-columns: minmax(0, 2.2fr) minmax(0, .8fr) minmax(0, 1.6fr) 120px 40px; }
.rdt-mrow-head { font-size: .78rem; font-weight: 600; color: var(--bs-secondary-color); margin-bottom: -4px; }
.rdt-mrow-head span:last-child { grid-column: span 2; }
.rdt-mrow-line .btn { white-space: nowrap; }
.rdt-mrow-x { width: 40px; padding-left: 0; padding-right: 0; font-size: 1.1rem; line-height: 1; }
.rdt-row-feat-btn b { font-weight: 600; }
.rdt-row-feat-btn span { font-size: .85rem; }
.rdt-row-feats .rdt-chip-add { border-style: dashed; }
@media (max-width: 767.98px) {
    .rdt-mrow { padding: 8px; border: 1px solid var(--bs-border-color); border-radius: 10px; }
    .rdt-mrow-head { display: none; }
    .rdt-mrow-line.rdt-mrow-c2 { grid-template-columns: minmax(0, .8fr) minmax(0, 1.4fr) auto auto; }
    .rdt-mrow-line.rdt-mrow-c1 { grid-template-columns: minmax(0, 1fr) auto auto; }
    .rdt-mrow-line > input:first-child { grid-column: 1 / -1; }
    .rdt-row-feat-btn span { display: none; }
}
/* rows with guests too (room categories): name · size · beds · adults · children · infants · Features · × */
.rdt-mrow-line.rdt-mrow-c5 { grid-template-columns: minmax(0, 2fr) minmax(0, .7fr) minmax(0, 1.4fr) minmax(0, .65fr) minmax(0, .65fr) minmax(0, .65fr) 120px 40px; }
@media (max-width: 1199.98px) {
    .rdt-mrows:has(.rdt-mrow-c5) .rdt-mrow { padding: 8px; border: 1px solid var(--bs-border-color); border-radius: 10px; }
    .rdt-mrow-head.rdt-mrow-c5 { display: none; }
    .rdt-mrow-line.rdt-mrow-c5 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .rdt-mrow-c5 > input:nth-child(1) { grid-column: 1 / -1; }
    .rdt-mrow-c5 > :nth-child(2) { grid-column: span 2; }
    .rdt-mrow-c5 > :nth-child(3) { grid-column: span 4; }
    .rdt-mrow-c5 > :nth-child(4), .rdt-mrow-c5 > :nth-child(5), .rdt-mrow-c5 > :nth-child(6) { grid-column: span 2; }
    .rdt-mrow-c5 > .rdt-row-feat-btn { grid-column: span 5; }
    .rdt-mrow-c5 > .rdt-mrow-x { grid-column: span 1; width: 100%; }
    .rdt-mrow-c5 .rdt-row-feat-btn span { display: inline; }
}
.rdt-mcell { position: relative; display: block; min-width: 0; }
/* stacked rows (phone / iPad): a small name on each box, so a filled "1" still says what it is */
@media (max-width: 1199.98px) {
    .rdt-mrow-c5 .rdt-mcell::before { content: attr(data-label); position: absolute; top: -7px; left: 8px; z-index: 1; padding: 0 4px; font-size: .66rem; line-height: 1.1; color: var(--bs-secondary-color); background: var(--bs-body-bg); border-radius: 4px; }
    .rdt-mrow-c5 { row-gap: 10px; }
}
@media (max-width: 767.98px) {
    .rdt-mrow-c1 .rdt-mcell::before, .rdt-mrow-c2 .rdt-mcell::before { content: attr(data-label); position: absolute; top: -7px; left: 8px; z-index: 1; padding: 0 4px; font-size: .66rem; line-height: 1.1; color: var(--bs-secondary-color); background: var(--bs-body-bg); border-radius: 4px; }
}

/* several ticked at once ('pick_many'): room chips + one row per ticked room (its dates and prices) */
.rdt-pick-chips { align-items: center; }
.rdt-pick-qa { width: auto; display: inline-flex; }
.rdt-pick-qa .btn { border-radius: 999px !important; padding: .3rem .65rem; }
.rdt-pick-line { display: grid; gap: 6px; align-items: center; grid-template-columns: minmax(0, 1.6fr) repeat(var(--n, 1), minmax(0, 1fr)); }
.rdt-pick-rows { display: flex; flex-direction: column; gap: 6px; }
.rdt-pick-head { font-size: .78rem; font-weight: 600; color: var(--bs-secondary-color); margin-bottom: 4px; }
.rdt-pick-name { font-weight: 600; font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rdt-pick-row .form-control { padding-left: .5rem; padding-right: .4rem; }
@media (max-width: 991.98px) {
    .rdt-pick-head { display: none; }
    .rdt-pick-row { padding: 10px 8px 8px; border: 1px solid var(--bs-border-color); border-radius: 10px; row-gap: 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .rdt-pick-row .rdt-pick-name { grid-column: 1 / -1; white-space: normal; }
    .rdt-pick-row .rdt-mcell { grid-column: span 2; }
    .rdt-pick-row .rdt-mcell:nth-child(2), .rdt-pick-row .rdt-mcell:nth-child(3) { grid-column: span 3; }
    .rdt-pick-row .rdt-mcell::before { content: attr(data-label); position: absolute; top: -7px; left: 8px; z-index: 1; padding: 0 4px; font-size: .66rem; line-height: 1.1; color: var(--bs-secondary-color); background: var(--bs-body-bg); border-radius: 4px; }
}
