/*
 * Phone and tablet layouts (.claude/mobile/mobile-brief.md). One app: the same Twig
 * templates, laid out by width alone.
 *
 *   1024 px and up   desktop exactly as before: nothing in this file applies
 *   768 to 1023 px   tablet: the side nav is already the theme's drawer (up to 1140 px);
 *                    grids hide `lowPriority` columns (grid-phone.js)
 *   under 768 px     phone: bottom bar, one column, 14 px gutters, 44 px tap targets,
 *                    48 px inputs with 16 px text, grids as rows that open in place
 *
 * Breakpoints are written as in the rest of our CSS: max-width 767.98px for phones.
 * Imported last from app.js so it wins over the theme at equal specificity.
 */

/* The side nav's first paint. The theme lays the page out beside a 250 px side nav until
   config.js sets data-sidenav-size, and config.js runs from the app module, which is
   deferred: after the first layout. Up to 1140 px it sets "full" (the drawer), so on a
   phone or tablet every full load slid the page in from 250 px over the theme's 0.25 s
   `transition: all`, the content squeezed into the rest meanwhile. Until the attribute
   lands, lay those widths out as "full" already, so it arrives with nothing to move.
   The attribute is not set here: config.js reads it back as the user's chosen size. */
@media (max-width: 1140px) {
    html:not([data-sidenav-size]):not([data-layout=topnav]) .page-content,
    html:not([data-sidenav-size]):not([data-layout=topnav]) .app-topbar { margin-left: 0; }
    html:not([data-sidenav-size]):not([data-layout=topnav]) .sidenav-menu { margin-left: calc(var(--abstack-sidenav-width) * -1); opacity: 0; top: 0; }
}

/* Phone-only and desktop-only blocks. m-hide never changes anything at 768 px and up.
   `html` in front: Bootstrap's CSS is injected at runtime, so a bare class would lose to
   .d-flex and friends (also !important) whenever Bootstrap lands later. */
@media (min-width: 768px) {
    html .m-only { display: none !important; }
}
@media (max-width: 767.98px) {
    html .m-hide { display: none !important; }
}

/* ── Shell: header, gutters, touch sizes ─────────────────────────────────── */
@media (max-width: 767.98px) {
    :root, [data-bs-theme] { --abstack-topbar-height: 56px; }

    /* 14 px side gutters: the theme puts 12 px on .page-content and 12 more on .page-container. */
    .page-content { padding-left: 0; padding-right: 0; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
    .page-content > .page-container,
    .page-content .page-container { --abstack-gutter-x: 28px; }
    /* The theme's footer reaches out over the 12 px this file removes from .page-content. */
    .page-content > .footer { margin-left: 0; margin-right: 0; }

    /* The topbar in its phone mode: menu, the page's title, its actions, then search and the user menu. */
    .app-topbar .topbar-menu { gap: 4px; padding-left: 4px; padding-right: 8px; }
    .app-topbar .logo { display: none !important; }
    .app-topbar .button-toggle-menu,
    .app-topbar .topbar-link { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .topbar-phone-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
    .topbar-phone-title .topbar-phone-name { flex: 1 1 auto; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--abstack-topbar-item-hover-color, inherit); }
    .topbar-phone-title .btn { flex: none; min-height: 36px; padding: 0 12px; font-weight: 600; }
    .app-topbar .topbar-back { color: inherit; }

    /* Touch: 44 px tap targets, 48 px fields (their 16 px text is app.css X-23). */
    .page-content .btn:not(.btn-sm):not(.btn-link) { min-height: 44px; }
    .page-content .form-control:not(.form-control-sm),
    .page-content .form-select:not(.form-select-sm) { min-height: 48px; }
}

/* ── Bottom bar ──────────────────────────────────────────────────────────── */
.m-bottombar { display: none; }
@media (max-width: 767.98px) {
    .m-bottombar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1020;
        display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column;
        background: #fff; border-top: 1px solid #e5e7eb;
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    }
    .m-bottombar-item {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        min-height: 50px; padding: 0; border: 0; background: none;
        font-size: 11px; font-weight: 500; color: #4b5563; text-decoration: none;
    }
    .m-bottombar-item i { font-size: 22px; line-height: 1; }
    .m-bottombar-item[aria-current="page"] { color: #1d4ed8; font-weight: 700; }
    /* Full-screen work surfaces keep the whole screen. */
    body.tc-canvas-active .m-bottombar { display: none; }
}

/* ── Action bar: a page's main actions in place of the bottom bar (project page, lot page) ── */
@media (max-width: 767.98px) {
    body:has(.m-actionbar) .m-bottombar { display: none; }
    .m-actionbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1020;
        display: flex; gap: 8px; padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
        background: #fff; border-top: 1px solid #e5e7eb;
    }
    .m-actionbar > .btn { flex: 1 1 0; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; font-size: 15px; border-radius: 12px; }
    .m-actionbar > .btn.m-actionbar-more { flex: 0 0 48px; }
    /* A dark bar for selected rows takes the action bar's place (Select mode). */
    .m-selectbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1025;
        display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
        padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); background: #0b1f33; color: #fff;
    }
}

/* A sheet's list of links (+ New, ⋯): one 48 px row each */
.m-sheet-list { display: flex; flex-direction: column; }
.m-sheet-item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 4px; border-bottom: 1px solid #f3f4f6; color: #111827; font-size: 15px; font-weight: 500; text-decoration: none; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%; }
.m-sheet-item:last-child { border-bottom: 0; }
.m-sheet-item .pp-icon, .m-sheet-item svg { width: 20px; height: 20px; color: #4b5563; }

/* ── A short row of chips that scrolls sideways (the one sideways scroller allowed) ── */
@media (max-width: 767.98px) {
    .m-chip-row { display: flex !important; gap: 8px; overflow-x: auto; margin: 0 -14px 4px; padding: 4px 14px 8px; scrollbar-width: none; }
    .m-chip-row::-webkit-scrollbar { display: none; }
    .m-chip-row > * { flex: none; }
}

/* ── AG Grid rows as cards (grid-phone.js) ───────────────────────────────── */
.gp-phone .ag-header,
.gp-phone .ag-paging-panel,
.gp-phone .ag-body-horizontal-scroll,
.gp-phone .ag-floating-bottom,
.gp-phone .ag-floating-top { display: none !important; }
.gp-phone .ag-center-cols-viewport { overflow-x: hidden !important; }
.gp-phone.ag-theme-quartz { --ag-wrapper-border-radius: 0; --ag-row-hover-color: transparent; }
.gp-phone .ag-root-wrapper { border-left: 0; border-right: 0; }
.gp-phone .ag-full-width-row { overflow: hidden; }

.gp-card { background: #fff; border-bottom: 1px solid #e5e7eb; white-space: normal; line-height: normal; height: auto !important; }
.gp-card.is-open { background: #f8fafc; }
.gp-card.gp-flag { box-shadow: inset 3px 0 0 #dc2626; }
.gp-card-head {
    width: 100%; display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 10px 11px 14px; border: 0; background: none; text-align: left; color: #111827;
    font: inherit; line-height: normal; white-space: normal;
}
.gp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.gp-title { font-size: 15px; font-weight: 600; line-height: 20px; overflow-wrap: anywhere; }
.gp-meta { font-size: 13px; line-height: 18px; color: #4b5563; overflow-wrap: anywhere; }
.gp-custom { display: block; margin-top: 2px; }
.gp-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.gp-value { font-size: 14px; font-weight: 700; line-height: 1.2; }
.gp-chevron { flex: none; font-size: 18px; color: #6b7280; line-height: 20px; }
.gp-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.gp-note { margin: 0; padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 18px; }
.gp-note.is-danger { background: #fee2e2; color: #991b1b; }
.gp-note.is-warning { background: #fef3c7; color: #92400e; }
.gp-note.is-success { background: #dcfce7; color: #166534; }
.gp-note.is-muted { background: #f3f4f6; color: #374151; }
.gp-detail { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: 12px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; }
.gp-detail > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gp-detail dt { font-size: 12px; font-weight: 400; color: #4b5563; }
.gp-detail dd { margin: 0; font-size: 14px; font-weight: 500; color: #111827; overflow-wrap: anywhere; }
.gp-actions { display: flex; gap: 8px; }
.gp-actions > .btn { flex: 1 1 0; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.gp-more { margin-top: 12px; min-height: 44px; font-weight: 600; }

/* ── The Filter sheet (a bottom offcanvas) ───────────────────────────────── */
.offcanvas.offcanvas-bottom.gp-sheet { height: auto; max-height: 82vh; border-radius: 18px 18px 0 0; }
.gp-sheet .offcanvas-header { padding: 6px 6px 6px 16px; border-bottom: 1px solid #e5e7eb; }
.gp-sheet .offcanvas-title { font-size: 17px; font-weight: 700; }
.gp-sheet .offcanvas-header .btn-close { width: 44px; height: 44px; padding: 0; margin: 0 0 0 auto; }
.gp-sheet .offcanvas-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 18px; }
.gp-sheet-section h3 { font-size: 13px; font-weight: 700; color: #374151; margin: 0 0 8px; }
.gp-sort-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gp-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.gp-pill { min-height: 44px; padding: 0 12px; border: 1px solid #d1d5db; background: #fff; color: #374151; border-radius: 10px; font-size: 14px; font-weight: 600; }
.gp-pills .gp-pill { border-radius: 999px; font-size: 13px; font-weight: 500; }
.gp-pill[aria-pressed="true"] { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }
.gp-sheet-foot { display: flex; gap: 8px; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid #e5e7eb; }
.gp-sheet-foot .btn { min-height: 48px; font-size: 15px; font-weight: 700; border-radius: 12px; }
.gp-sheet-foot .btn-light { flex: 1 1 0; }
.gp-sheet-foot .btn-primary { flex: 2 1 0; }

/* The Filter button beside a phone search box */
.gp-filter-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; }
.gp-filter-btn.is-active { border-color: #2563eb !important; background: #eff6ff; color: #1d4ed8; }

/* A segmented control (views, short fixed lists) */
.m-seg { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; background: #e5e7eb; border-radius: 10px; padding: 3px; }
.m-seg > button { min-height: 38px; border: 0; border-radius: 8px; background: transparent; color: #4b5563; font-size: 13px; font-weight: 600; }
.m-seg > button[aria-pressed="true"] { background: #fff; color: #111827; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* ── Plain tables as rows that open in place (table-phone.js) ─────────────── */
@media (max-width: 767.98px) {
    table.gp-table, table.gp-table > tbody, table.gp-table > tfoot { display: block; width: 100% !important; min-width: 0 !important; }
    table.gp-table > thead { display: none; }
    table.gp-table > tbody > tr, table.gp-table > tfoot > tr {
        position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: 12px; row-gap: 4px;
        padding: 10px 28px 10px 0; border-bottom: 1px solid #e5e7eb; background: none;
    }
    table.gp-table > tbody > tr > td, table.gp-table > tfoot > tr > td,
    table.gp-table > tbody > tr > th, table.gp-table > tfoot > tr > th {
        display: none; padding: 0 !important; border: 0 !important; background: none; text-align: left; white-space: normal; min-width: 0; width: auto !important; max-width: none !important; overflow-wrap: anywhere;
    }
    table.gp-table .gp-td-title { display: block; grid-column: 1; font-weight: 600; font-size: 14px; line-height: 1.35; }
    table.gp-table .gp-td-value { display: block; grid-column: 2; grid-row: 1; text-align: right; font-weight: 700; white-space: nowrap; }
    table.gp-table .gp-td-check { display: flex; align-items: center; grid-column: 1 / -1; }
    table.gp-table tr.gp-tr-more { cursor: pointer; }
    table.gp-table tr.gp-tr-more::after { content: ""; position: absolute; right: 8px; top: 16px; width: 8px; height: 8px; border-right: 2px solid #6b7280; border-bottom: 2px solid #6b7280; transform: rotate(45deg); }
    table.gp-table tr.gp-tr-more.gp-open { background: #f8fafc; }
    table.gp-table tr.gp-tr-more.gp-open::after { transform: rotate(-135deg); top: 20px; }
    table.gp-table tr.gp-open > td:not(.gp-td-title):not(.gp-td-value):not(.gp-td-check):not(:empty) {
        display: flex; justify-content: space-between; gap: 12px; grid-column: 1 / -1; font-size: 13px;
    }
    table.gp-table tr.gp-open > td[data-label]:not(.gp-td-title):not(.gp-td-value):not(.gp-td-action)::before { content: attr(data-label); color: #4b5563; flex: none; max-width: 50%; }
    table.gp-table tr.gp-open > td:not(.gp-td-title):not(.gp-td-value) > * { text-align: right; }
    table.gp-table tr.gp-open > td.gp-td-action { justify-content: flex-start; flex-wrap: wrap; padding-top: 6px !important; }
    table.gp-table tr.gp-open > td.gp-td-action > * { text-align: left; }
    table.gp-table tr.gp-tr-heading { display: block; padding: 10px 0 6px; border-bottom: 1px solid #e5e7eb; }
    table.gp-table tr.gp-tr-heading > td, table.gp-table tr.gp-tr-heading > th { display: block; font-weight: 700; font-size: 13px; }
    /* A table's scroller has nothing left to scroll. */
    .table-responsive:has(> table.gp-table) { overflow-x: visible; }
}

/* ── "Works best on a computer" (components/_desktop_notice.html.twig) ───── */
.m-notice { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 32px 8px; text-align: center; }
.m-notice.is-inline { padding: 20px 16px; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; }
.m-notice-icon { width: 72px; height: 72px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; display: flex; align-items: center; justify-content: center; font-size: 34px; }
.m-notice.is-inline .m-notice-icon { width: 52px; height: 52px; font-size: 26px; }
.m-notice-title { margin: 0; font-size: 21px; font-weight: 700; }
.m-notice.is-inline .m-notice-title { font-size: 17px; }
.m-notice-why { margin: 0; font-size: 15px; line-height: 22px; color: #374151; }
.m-notice > .btn { width: 100%; min-height: 48px; border-radius: 12px; font-size: 15px; font-weight: 700; }
.m-notice-status { margin: 0; font-size: 13px; color: #166534; min-height: 0; }
.m-notice-status:empty { display: none; }
.m-notice-note { margin: 0; font-size: 12px; line-height: 18px; color: #4b5563; }
@media (max-width: 767.98px) {
    ul.gp-list-fold > li:nth-child(n+6) { display: none !important; }
    .gp-list-more { min-height: 44px; font-weight: 600; }
}

/* Figures in a row under their labels (a small table on a phone, 3.4: lot materials) */
.gp-figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.gp-figures > * { min-width: 0; overflow-wrap: anywhere; }
.gp-figures .pp-lot-sub { display: block; font-size: 11px; }
.gp-figures-head { padding: 6px 14px 6px 14px; font-size: 12px; font-weight: 600; color: #4b5563; border-bottom: 1px solid #e5e7eb; }
.gp-card .gp-figures { margin-top: 4px; }
