/*
 * Mobile shell (MobileLayout.razor) — fixed header, scrolling body, fixed tab
 * bar, in Onix Glass: frosted header and tab bar over the page gradient
 * (onix-glass.css paints the page). Loaded on every page but scoped under
 * .onix-m-shell, which only the mobile layout renders, so a desktop page is
 * untouched.
 */

.onix-m-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: transparent;
}

/* Safe areas: both halves are required. Capacitor 8 on Android sets the custom
 * properties and only populates env() on WebView >= 140 with viewport-fit=cover;
 * iOS never sets the custom properties, so var() falls through to env(). One
 * rule, correct on both — see onixapp/docs/BRIDGE.md. */
.onix-m-topbar {
    position: sticky;
    top: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 8px) 12px 8px;
    background: rgba(255, 255, 255, 0.62);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    backdrop-filter: blur(18px) saturate(1.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 1px 0 rgba(10, 31, 60, 0.06);
}

.onix-m-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--onix-ink-900, #1D1D1F);
}

.onix-m-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 113, 227, 0.25);
}

.onix-m-topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.onix-m-content {
    flex: 1 1 auto;
    /* Clears the fixed tab bar so the last card is never trapped under it. */
    padding-bottom: calc(64px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
}

.onix-m-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    display: flex;
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    backdrop-filter: blur(20px) saturate(1.5);
    border-top: 1px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 -8px 24px rgba(10, 31, 60, 0.08);
    padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

.onix-m-tab {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    /* 56px: the Material minimum touch target, kept explicit so shrinking the
     * label cannot quietly make the target too small to hit. */
    min-height: 56px;
    padding: 6px 4px;
    font-size: 11px;
    line-height: 1.2;
    text-decoration: none;
    color: var(--onix-ink-500, #6E6E73);
    -webkit-tap-highlight-color: transparent;
}

.onix-m-tab--current {
    color: var(--onix-blue-600, #0071E3);
    font-weight: 600;
    box-shadow: inset 0 2px 0 0 var(--onix-blue-500, #0071E3);
}

/* ---------------------------------------------------------------------------
 * Vendor-bill capture (ScanBill.razor + onix-intake.js).
 *
 * Plain elements rather than MudBlazor components: the shim owns this screen
 * and addresses these nodes by id, so they must not depend on a Blazor
 * re-render to be readable or writable.
 * ------------------------------------------------------------------------- */

.onix-scan-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 28px 16px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px dashed rgba(0, 113, 227, 0.45);
    border-radius: 16px;
    color: #1D1D1F;
    font: inherit;
    font-size: 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.onix-scan-drop:disabled { opacity: .6; cursor: default; }
.onix-scan-drop-icon { color: #0071E3; }

.onix-scan-note {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 12px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 16px;
    font: inherit;
    font-size: 16px; /* < 16px makes iOS Safari zoom the page on focus. */
    color: #1D1D1F;
}

.onix-scan-status:empty { display: none; }

.onix-scan-status {
    padding: 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.onix-scan-status--working { background: #E9F2FF; color: #0066CC; }
.onix-scan-status--ok      { background: #E4F4EE; color: #0E8158; }
.onix-scan-status--error   { background: #FDE7E8; color: #A9393F; }

/* The bill that was just filed. Confirmation you can actually check: a
 * sentence cannot tell you that you photographed the wrong invoice. */
.onix-scan-preview:empty { display: none; }

.onix-scan-preview {
    display: flex;
    gap: 8px;
    overflow-x: auto;           /* a long bill scrolls sideways, the page does not */
    margin-top: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 16px;
}

.onix-scan-preview-img {
    display: block;
    flex: 0 0 auto;
    width: auto;
    /* Tall receipts must not push the tab bar off-screen; the strip is
     * scrollable if the user wants a closer look. */
    max-height: 22vh;
    border-radius: 8px;
}

/* Non-image uploads (the file picker also takes PDFs) get their name, not a
 * broken <img>. */
.onix-scan-preview-name {
    margin: 0;
    padding: 14px 8px;
    text-align: center;
    font-size: 14px;
    word-break: break-all;
    color: #1D1D1F;
}

/* --- Multi-page capture ---------------------------------------------------
 * A bill is several sheets. The strip is the working set: what will be sent,
 * in the order it will be sent, with page one first because that is the one
 * the accountant's viewer opens. */

.onix-scan-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
    padding: 12px;
    font: inherit;
    font-weight: 600;
    color: #0071E3;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 16px;
    cursor: pointer;
}

.onix-scan-secondary:disabled { opacity: .5; }

.onix-scan-count:empty { display: none; }

.onix-scan-count {
    margin-top: 14px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: #6E6E73;
}

.onix-scan-pages:empty { display: none; }

.onix-scan-pages {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-top: 8px;
    padding-bottom: 4px;
}

.onix-page {
    position: relative;
    flex: 0 0 auto;
    width: 76px;
    height: 96px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 10px;
    overflow: hidden;
}

.onix-page-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.onix-page-file {
    display: block;
    padding: 8px 6px;
    font-size: 11px;
    line-height: 1.3;
    word-break: break-all;
    color: #1D1D1F;
}

/* The number is information, not decoration: page one becomes the bill's main
 * attachment, so the order is a decision the user is making. */
.onix-page-number {
    position: absolute;
    left: 4px;
    bottom: 4px;
    min-width: 18px;
    padding: 1px 5px;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: rgba(255, 255, 255, 0.72);
    background: rgba(10, 31, 60, .72);
    border-radius: 9px;
}

.onix-page-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: 16px;
    line-height: 20px;
    color: rgba(255, 255, 255, 0.72);
    background: rgba(10, 31, 60, .72);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.onix-scan-submit {
    width: 100%;
    margin-top: 14px;
    padding: 14px;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    /* Button/Primary of the design: navy, white label, soft navy shadow. */
    color: #FFFFFF;
    background: #0071E3;
    box-shadow: 0 6px 16px rgba(0, 113, 227, 0.28);
    border: 0;
    border-radius: 14px;
    cursor: pointer;
}

.onix-scan-submit:disabled {
    box-shadow: none;
    color: #AEAEB2;
    background: rgba(10, 31, 60, 0.10);
    cursor: default;
}

/* --- The bill list --------------------------------------------------------
 * What the accounting service holds, read live. The row answers the two things
 * an owner actually asks — who it is from and whether anyone has dealt with it
 * — and leaves the rest to the detail screen. */

.onix-bills { padding-bottom: 96px; }   /* clear of the floating button */

.onix-bill-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.onix-bill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    text-decoration: none;
    color: inherit;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(10, 31, 60, 0.10);
    border-radius: 16px;
}

.onix-bill:active { background: rgba(0, 113, 227, 0.06); }

.onix-bill-main { min-width: 0; }        /* lets the name ellipsize, not overflow */

.onix-bill-who {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: #1D1D1F;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.onix-bill-meta {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: #6E6E73;
}

.onix-bill-dot { margin: 0 5px; }

.onix-bill-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex: 0 0 auto;
}

.onix-bill-amount {
    font-weight: 700;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    color: #1D1D1F;
}

/* State chips: the design's chip lives in onix-glass.css (.onix-chip and its
   --review / --posted / --paid / --captured / --overdue states). */
.onix-chip--waiting { color: var(--warn); background: var(--warn-soft); }
.onix-chip--reading { color: var(--brand-strong); background: var(--brand-soft); }
.onix-chip--cancel  { color: var(--danger-strong); background: var(--danger-soft); }

.onix-bills-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 40px 24px;
    text-align: center;
    color: #6E6E73;
}

.onix-bills-empty p { margin: 0; max-width: 34ch; line-height: 1.5; }

.onix-bill-skeleton { border-radius: 16px; margin-bottom: 8px; }

/* ---- Users of my company (Users.razor) --------------------------------
   Same row grammar as the bills: a card per person, one tap to open. A
   locked row (the firm's staff, seen by an owner) keeps the card but not
   the affordance — no hover, no pointer — so it does not promise an editor
   the gateway would refuse. */
.onix-user-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.onix-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    text-decoration: none;
    color: inherit;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(10, 31, 60, 0.10);
    border-radius: 16px;
}

a.onix-user:active { background: rgba(0, 113, 227, 0.06); }
.onix-user--locked { color: #6E6E73; }
.onix-user--inactive .onix-user-name,
.onix-user--inactive .onix-user-avatar { opacity: .55; }

.onix-user-avatar {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #E9F2FF;
    color: #0071E3;
    font-weight: 700;
    font-size: 16px;
}

.onix-user--locked .onix-user-avatar { background: rgba(111, 116, 133, 0.12); color: #6E6E73; }

.onix-user-main { flex: 1 1 auto; min-width: 0; }

.onix-user-name {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: #1D1D1F;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.onix-user-you {
    margin-left: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #0071E3;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.onix-user-meta {
    display: block;
    font-size: 12.5px;
    color: #6E6E73;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.onix-user-side { flex: 0 0 auto; }

.onix-chip--role { color: var(--brand-strong); background: var(--brand-soft); }
.onix-chip--firm { color: var(--brand-strong); background: var(--brand-soft); }

.onix-user-role-help { margin-top: -8px; line-height: 1.4; }

/* The one thing this screen leads to, reachable however far it is scrolled. */
.onix-fab {
    position: fixed;
    right: 16px;
    /* Above the tab bar, and above the phone's own gesture area. */
    bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 12px);
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    font-weight: 700;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.72);
    background: #0071E3;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(10, 31, 60, .28);
}

.onix-fab:active { background: #0066CC; }

/* --- One bill ------------------------------------------------------------- */

.onix-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: #0071E3;
}

.onix-bill-detail-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.onix-bill-number {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: #6E6E73;
}

.onix-bill-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    margin: 0 0 16px;
}

.onix-bill-facts dt { font-size: 13px; color: #6E6E73; }
.onix-bill-facts dd {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #1D1D1F;
}

.onix-bill-note {
    margin: 0 0 16px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.5;
    color: #6E6E73;
    background: rgba(0, 113, 227, 0.06);
    border-radius: 10px;
}

.onix-bill-lines {
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.onix-bill-lines li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid rgba(10, 31, 60, 0.10);
}

.onix-scan-open {
    display: block;
    margin-top: 12px;
    padding: 12px;
    text-align: center;
    font-weight: 700;
    text-decoration: none;
    color: #0071E3;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid #0071E3;
    border-radius: 16px;
}

/* The bill, page by page. Images rather than an embedded PDF because Android's
 * WebView has no viewer for one — see BillDetail.razor. */
.onix-bill-pages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.onix-bill-page {
    display: block;
    width: 100%;
    height: auto;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 10px;
}

.onix-bill-file {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: #0071E3;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 10px;
}

/* ---- Desktop shell: this app's screens as top-bar tabs (AppTabs.razor) ----
   The phone's tab bar, laid out along the app bar. Same colours as the shell
   bar's pills (onix-shellbar.css): slate text, brand blue when current. */
.onix-d-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 18px;
    overflow-x: auto;
    scrollbar-width: none;
}
.onix-d-tabs::-webkit-scrollbar { display: none; }
.onix-d-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 14px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    color: var(--onix-bar-ink, #424245);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.onix-d-tab:hover { background: var(--onix-bar-hover-bg, rgba(0, 113, 227, 0.08)); color: var(--onix-bar-hover-ink, #0071E3); }
.onix-d-tab--current { color: var(--onix-blue-600, #0071E3); background: rgba(0, 113, 227, 0.12); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7); }
@media (max-width: 767.98px) {
    .onix-d-tab span { display: none; }
    .onix-d-tab { padding: 0 10px; }
}

/* The page viewer of the Onix app (js/onix-files.js): a printable page opened
 * over the current one, since the app has no tabs. Over the mobile shell's
 * header and tab bar; the toasts stay above it. */
.onix-viewer {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    background: var(--panel, #fff);
}
.onix-viewer-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 8px) 12px 8px;
    border-bottom: 1px solid var(--line-strong, rgba(0, 0, 0, 0.12));
}
.onix-viewer-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.onix-viewer-close { flex: 0 0 auto; }
.onix-viewer-frame {
    flex: 1 1 auto;
    width: 100%;
    border: 0;
    background: #fff;
    margin-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}
body:has(.onix-viewer) .toast-host { z-index: 1400; }
