/* SAWM app-specific overrides on top of vendored Bootstrap. Keep this file small — PRD §8.1 performance budget. */

body {
    min-height: 100vh;
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Show/hide password button injected by assets/password-toggle.js. The inline SVG needs
   explicit centring — Bootstrap sizes .btn for a text baseline, not an icon. */
.password-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
}

/* Rendered staff guides (/help/{slug}) — Markdown from docs/guides via GuideService.
   Sized for reading a checklist on a phone, and for the printed copy that ends up
   laminated by the counter (PRD §6.13). */
.guide h1 { font-size: 1.5rem; margin-bottom: 1rem; }
.guide h2 { font-size: 1.15rem; margin-top: 1.75rem; margin-bottom: .6rem; }
.guide h3 { font-size: 1rem; margin-top: 1.25rem; }
.guide p, .guide li { line-height: 1.6; }
.guide ol, .guide ul { padding-left: 1.35rem; }
.guide li { margin-bottom: .35rem; }
.guide table { width: 100%; margin: 1rem 0; border-collapse: collapse; }
.guide th, .guide td { border: 1px solid #dee2e6; padding: .45rem .6rem; text-align: left; vertical-align: top; }
.guide th { background: #f8f9fa; }
.guide blockquote {
    border-left: 3px solid #1F3864;
    background: #f8f9fa;
    margin: 1rem 0;
    padding: .6rem .9rem;
}
.guide blockquote p:last-child { margin-bottom: 0; }
.guide code { background: #f1f3f5; padding: .1rem .3rem; border-radius: .2rem; }

@media print {
    /* Print just the guide — no navbar, no buttons. */
    .navbar, .alert-dismissible .btn-close { display: none !important; }
    .guide { max-width: 100%; }
    a[href]::after { content: ""; }
}

/* ---------------------------------------------------------------- line editor
   Parts & labour rows (Views/partials/line_editor.php), shared by estimates and
   job sheets.

   The table is right on a desktop and unusable on a phone: eight columns squeezed
   into 360px leaves a description box showing "Tengok j..." and a horizontal
   scrollbar under everything. Below the md breakpoint each row becomes a card with
   real labels instead.

   Deliberately CSS-only. The markup keeps its <table>, its <tr class="line-row">
   and every class line-editor.js queries, so the add/remove/total/catalog logic is
   untouched — and a row cloned from the <template> reflows exactly like a
   server-rendered one, with no second code path to keep in step. */

.line-editor .cell-label,
.line-editor .remove-label {
    /* Labels exist for the mobile layout; the table header does the job on desktop.
       Not display:none — screen readers should still reach them. */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 767.98px) {
    .line-editor .table-responsive { overflow-x: visible; }
    .line-editor table,
    .line-editor tbody { display: block; width: 100%; }
    .line-editor thead { display: none; }

    .line-editor tr.line-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .6rem .75rem;
        align-items: end;
        border: 1px solid var(--bs-border-color, #dee2e6);
        border-radius: .5rem;
        padding: .85rem;
        margin-bottom: .85rem;
        background: var(--bs-body-bg, #fff);
    }

    .line-editor tr.line-row > td {
        display: block;
        width: auto !important;
        padding: 0;
        border: 0;
        text-align: left !important;
    }

    /* Description and the catalog type-ahead need the full width — it is the field
       staff actually type into, and the one the screenshot showed truncated. */
    .line-editor .cell-description,
    .line-editor .cell-remove { grid-column: 1 / -1; }

    .line-editor .cell-label {
        position: static;
        width: auto;
        height: auto;
        margin: 0 0 .2rem;
        clip: auto;
        overflow: visible;
        display: block;
        font-size: .75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--bs-secondary-color, #6c757d);
    }

    /* Taxable reads as a checkbox with its own words, not an unlabelled tick. */
    .line-editor .cell-tax { align-self: center; }
    .line-editor .cell-tax .cell-label {
        display: inline;
        margin: 0;
        text-transform: none;
        letter-spacing: 0;
        font-size: .875rem;
        font-weight: 400;
        color: inherit;
    }

    .line-editor .cell-amount {
        align-self: center;
        text-align: right !important;
        font-size: 1rem;
    }
    .line-editor .cell-amount .cell-label {
        display: inline;
        margin: 0 .35rem 0 0;
        font-size: .75rem;
    }
    .line-editor .cell-amount .line-total-display { font-weight: 600; }

    /* A 36px × button is a poor target on a phone; give it words and full width. */
    .line-editor .cell-remove .remove-line { width: 100%; }
    .line-editor .remove-label {
        position: static;
        width: auto;
        height: auto;
        margin: 0 0 0 .4rem;
        clip: auto;
        overflow: visible;
    }

    /* iOS zooms the whole page when a focused input is under 16px, which on a
       cramped form means every tap fights the viewport. form-control-sm is 14px. */
    .line-editor .form-control,
    .line-editor .form-select { font-size: 1rem; }

    .line-editor .add-line { width: 100%; }
    .line-editor .totals-preview { max-width: none !important; }
}
