/* =====================================================================
   Saansu Hub — brand layer on top of the Highdmin (Coderthemes BS5) template.
   Load AFTER app.min.css + icons.min.css.
   ===================================================================== */

:root,
[data-bs-theme=light] {
    --sh-primary: #1D4ED8;
    --sh-primary-rgb: 29, 78, 216;

    --highdmin-primary: #1D4ED8;
    --highdmin-primary-rgb: 29, 78, 216;
    --highdmin-primary-text-emphasis: #16349E;
    --highdmin-primary-bg-subtle: #E2E9FB;
    --highdmin-primary-border-subtle: #AFC2F0;
}

[data-bs-theme=dark] {
    --sh-primary: #4C7CF0;
    --highdmin-primary: #4C7CF0;
}

/* myBillBook cards/panels use a visible 1px border instead of Highdmin's
   default shadow-only (border-width 0) look. Flip the template's own
   customisation variable globally — every .card picks this up, not just one
   screen. */
.card { --highdmin-card-border-width: 1px; }

/* =====================================================================
   myBillBook accent colour (UI Design Decision, CLAUDE.md, 2026-10-26).
   The Highdmin template hardcodes its brand colour as teal (#02c0ce) on
   every component instead of referencing a variable, so each component
   needs its own override here rather than one root-level variable change.
   ===================================================================== */
.btn-primary {
    --highdmin-btn-bg: #5b4bd6;
    --highdmin-btn-border-color: #5b4bd6;
    --highdmin-btn-hover-bg: #4c3ec4;
    --highdmin-btn-hover-border-color: #4c3ec4;
    --highdmin-btn-active-bg: #4c3ec4;
    --highdmin-btn-active-border-color: #4c3ec4;
    --highdmin-btn-focus-shadow-rgb: 91, 75, 214;
    --highdmin-btn-disabled-bg: #5b4bd6;
    --highdmin-btn-disabled-border-color: #5b4bd6;
}
.btn-outline-primary {
    --highdmin-btn-color: #5b4bd6;
    --highdmin-btn-border-color: #5b4bd6;
    --highdmin-btn-hover-bg: #5b4bd6;
    --highdmin-btn-hover-border-color: #5b4bd6;
    --highdmin-btn-focus-shadow-rgb: 91, 75, 214;
    --highdmin-btn-active-bg: #5b4bd6;
    --highdmin-btn-active-border-color: #5b4bd6;
    --highdmin-btn-disabled-color: #5b4bd6;
    --highdmin-btn-disabled-border-color: #5b4bd6;
}
.form-check-input:checked { background-color: #5b4bd6; border-color: #5b4bd6; }
.pagination { --highdmin-pagination-active-bg: #5b4bd6; --highdmin-pagination-active-border-color: #5b4bd6; }

/* ---------- Global confirm dialog (SH.confirm / SweetAlert2) polish ---------- */
.swal2-popup { border-radius: 1rem !important; padding-bottom: 1.5rem !important; }
.swal2-title { font-size: 1.15rem !important; }
.swal2-html-container { font-size: .9rem !important; }

/* ---------- Text-based logo (no image assets yet) ---------- */
.sh-logo {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: .02em;
    color: var(--highdmin-primary, #1D4ED8);
    text-decoration: none;
}

.sh-logo .sh-logo-mark {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--highdmin-primary, #1D4ED8);
    color: #fff;
    font-weight: 800;
    font-size: .95rem;
}

.sh-logo-sm { display: none; }

/* ---------- Guest (login) layout ---------- */
.sh-auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
}

@media (min-width: 992px) {
    .sh-auth { grid-template-columns: 1fr 1fr; }
}

.sh-auth-brand {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem;
    background: linear-gradient(160deg, var(--highdmin-primary, #1D4ED8), #0F2A7A);
    color: #fff;
}

@media (min-width: 992px) {
    .sh-auth-brand { display: flex; }
}

.sh-auth-form {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
    position: relative;
}

.sh-auth-card { width: 100%; max-width: 420px; }

.theme-toggle-floating {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.theme-toggle i.ri-sun-line { display: none; }
[data-bs-theme=dark] .theme-toggle i.ri-moon-line { display: none; }
[data-bs-theme=dark] .theme-toggle i.ri-sun-line { display: inline; }

/* ---------- Misc ---------- */
.sh-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.sh-page-sub { color: var(--bs-secondary-color); margin-bottom: .5rem; }

.badge-soon {
    font-size: .625rem;
    padding: .15rem .4rem;
    border-radius: .35rem;
    background: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
}

.is-soon { opacity: .6; cursor: not-allowed; }

.sh-avatar-initials {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--highdmin-primary-bg-subtle, #E2E9FB);
    color: var(--highdmin-primary, #1D4ED8);
    font-weight: 700;
    font-size: .8rem;
}

/* =====================================================================
   myBillBook-style sidebar (UI Design Decision, CLAUDE.md, 2026-10-26)
   Dark navy sidebar skin, regardless of main content light/dark mode.
   ===================================================================== */
:root[data-menu-color=dark] {
    --highdmin-menu-bg: #141a2e;
    --highdmin-menu-item-color: #9aa5c4;
    --highdmin-menu-item-hover-color: #ffffff;
    --highdmin-menu-item-hover-bg: rgba(255, 255, 255, .04);
    --highdmin-menu-item-active-color: #ffffff;
    --highdmin-menu-item-active-bg: #5b4bd6;
    --highdmin-sidebar-user-bg: #1b2340;
}

.sidenav-menu .sh-logo-mark {
    background: linear-gradient(135deg, #e8c766, #b8860b);
    color: #1a1a1a;
}

.sh-logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.sh-logo-name { font-size: .95rem; letter-spacing: .03em; color: #fff; }
.sh-sidebar-mobile { font-size: .75rem; font-weight: 500; color: #8792ad; }

.sh-sidebar-create {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 1rem .9rem;
    padding: .55rem .9rem;
    background: #5b4bd6;
    color: #fff;
    border-radius: .5rem;
    font-weight: 600;
    font-size: .85rem;
    text-decoration: none;
}
.sh-sidebar-create:hover { background: #4c3ec4; color: #fff; }

/* Sub-menu active item (e.g. "All Parties" under "Parties") — Highdmin only pills the
   top-level active link (`.side-nav>.side-nav-item.active>.side-nav-link`); give nested
   sub-menu links the same rounded fill so an expanded menu's current page stands out. */
.side-nav .sub-menu .side-nav-link.active {
    color: var(--highdmin-menu-item-active-color);
    background: var(--highdmin-menu-item-active-bg);
    border-radius: var(--highdmin-border-radius);
}

/* ---------- Dashboard widgets ---------- */
.sh-promo-banner {
    background: linear-gradient(90deg, #fdf1e6, #fdf6ee);
    border: 1px solid #f6e3c9;
    border-radius: .75rem;
    padding: 1.25rem 1.5rem;
}
[data-bs-theme=dark] .sh-promo-banner {
    background: linear-gradient(90deg, #332a1f, #2b271f);
    border-color: #4a3c25;
}

.sh-stat-card {
    border-radius: .65rem;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.sh-stat-card .sh-stat-label { font-size: .85rem; font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.sh-stat-card .sh-stat-value { font-size: 1.35rem; font-weight: 700; }
.sh-stat-card--collect { background: rgba(34, 197, 94, .1); color: #15803d; }
.sh-stat-card--pay { background: rgba(239, 68, 68, .1); color: #b91c1c; }
.sh-stat-card--balance { background: rgba(59, 130, 246, .1); color: #1d4ed8; }
.sh-stat-card--muted { background: rgba(148, 163, 184, .15); color: #475569; }
[data-bs-theme=dark] .sh-stat-card--collect { background: rgba(34, 197, 94, .12); color: #4ade80; }
[data-bs-theme=dark] .sh-stat-card--pay { background: rgba(239, 68, 68, .12); color: #f87171; }
[data-bs-theme=dark] .sh-stat-card--balance { background: rgba(59, 130, 246, .12); color: #60a5fa; }

.sh-scan-upload {
    border: 1.5px dashed #f0b088;
    border-radius: .6rem;
    padding: 1.5rem 1rem;
    text-align: center;
    color: #c2703f;
    background: rgba(240, 176, 136, .08);
    font-size: .85rem;
}

.sh-topbar-icons { display: flex; align-items: center; gap: .35rem; }
.sh-topbar-icons a {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: .4rem;
    color: var(--bs-secondary-color);
    font-size: 1.1rem;
}
.sh-topbar-icons a:hover { background: var(--bs-secondary-bg); }

/* ---------- Parties list (Module 3) ---------- */
.sh-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.sh-filter-seg {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .6rem;
    flex: 1 1 260px;
    padding: 1.1rem 1.35rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .85rem;
    background: var(--bs-body-bg);
    cursor: pointer;
    text-decoration: none;
    transition: background-color .12s ease, box-shadow .12s ease;
}
.sh-filter-seg:hover { background: var(--bs-secondary-bg); text-decoration: none; }
.sh-filter-seg--all.active { background: rgba(91, 75, 214, .07); box-shadow: inset 0 0 0 1.5px #5b4bd6; }
.sh-filter-seg--collect.active { background: rgba(34, 197, 94, .07); box-shadow: inset 0 0 0 1.5px #16a34a; }
.sh-filter-seg--pay.active { background: rgba(239, 68, 68, .07); box-shadow: inset 0 0 0 1.5px #dc2626; }
.sh-filter-row { display: flex; align-items: center; gap: .55rem; }
.sh-filter-icon {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.sh-filter-icon--all { background: rgba(91, 75, 214, .12); color: #5b4bd6; }
.sh-filter-icon--collect { background: rgba(34, 197, 94, .12); color: #16a34a; }
.sh-filter-icon--pay { background: rgba(239, 68, 68, .12); color: #dc2626; }
.sh-filter-seg .sh-filter-label { font-size: .85rem; font-weight: 600; color: var(--bs-secondary-color); }
.sh-filter-seg--all.active .sh-filter-label { color: #5b4bd6; }
.sh-filter-seg .sh-filter-value { font-size: 1.6rem; font-weight: 700; color: var(--bs-body-color); line-height: 1.1; }

.sh-sort-icon { font-size: .85rem; color: var(--bs-secondary-color); margin-left: .25rem; cursor: pointer; }

.sh-row-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: var(--bs-secondary-color);
}
.sh-row-icon-btn:hover { background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.sh-row-icon-btn--whatsapp { background: rgba(34, 197, 94, .12); color: #16a34a; }
.sh-row-icon-btn--whatsapp:hover { background: rgba(34, 197, 94, .2); color: #16a34a; }

.sh-help-btn {
    position: fixed;
    right: 1.5rem;
    bottom: 5.5rem;
    z-index: 1040;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bs-dark, #1e1f27);
    color: #fff;
    display: inline-grid;
    place-items: center;
    font-size: 1.1rem;
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .18);
}
.sh-help-btn:hover { color: #fff; opacity: .9; }

.sh-pending-actions-btn {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1040;
    background: #16a34a;
    color: #fff;
    border-radius: 2rem;
    padding: .55rem 1rem;
    font-weight: 600;
    font-size: .85rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .18);
    text-decoration: none;
}
.sh-pending-actions-btn:hover { background: #128a3e; color: #fff; }
.sh-pending-actions-btn .badge { background: #fff; color: #16a34a; }

/* ---------- Tabbed create-party modal ---------- */
/* The <form> wraps modal-header/body/footer, which breaks Bootstrap's
   .modal-dialog-scrollable flex chain (it expects those three to be direct
   children of .modal-content). display:contents removes the form from the
   box model so the flex/overflow layout — and the body scrollbar — works. */
.modal-content > form { display: contents; }

/* Reusable tabbed-modal body: the nav column (.sh-modal-tabs) is a fixed,
   bordered card-like panel that never scrolls — like the myBillBook
   reference, where only the right-hand tab content scrolls and the nav list
   + Cancel stay fully visible. Bootstrap's .modal-dialog-scrollable puts
   overflow-y:auto on the whole .modal-body; override that here and move the
   scrolling down to just .sh-modal-tabs-content. Same specificity as
   Bootstrap's rule (two classes) so load order (brand.css last) decides it,
   but the extra .sh-modal-tabbed-body class keeps this scoped to this
   pattern instead of touching every scrollable modal in the app. */
.modal-dialog-scrollable .modal-body.sh-modal-tabbed-body {
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
}
.sh-modal-tabs-layout {
    display: flex;
    gap: 1rem;
    flex: 1 1 auto;
    min-height: 0;
}
.sh-modal-tabs {
    flex: 0 0 170px;
    align-self: flex-start;
    overflow-y: auto;
    max-height: 100%;
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    padding: .6rem;
}
.sh-modal-tabs-content {
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
    padding-right: .25rem;
}
.sh-modal-tabs .nav-link {
    text-align: left;
    color: var(--bs-body-color);
    font-size: .85rem;
    border-radius: .4rem;
    padding: .5rem .65rem;
}
.sh-modal-tabs .nav-link.active { background: rgba(91, 75, 214, .12); color: #5b4bd6; font-weight: 600; }
.sh-modal-tabs .sh-modal-tabs-group {
    text-transform: uppercase;
    font-size: .65rem;
    letter-spacing: .04em;
    color: var(--bs-secondary-color);
    margin: 1rem 0 .35rem .65rem;
}
.sh-dashed-btn {
    display: block;
    width: 100%;
    border: 1.5px dashed #5b4bd6;
    border-radius: .5rem;
    padding: .6rem;
    text-align: center;
    color: #5b4bd6;
    background: rgba(91, 75, 214, .04);
    font-weight: 600;
    font-size: .85rem;
}
.sh-dashed-btn:hover { background: rgba(91, 75, 214, .08); color: #4c3ec4; }

/* Highdmin theme bug: its own --highdmin-secondary-bg equals the select2 dropdown's background in both
   themes, so the "currently selected" option highlight it ships was invisible (white-on-white in light
   mode) — surfaced by the Parties Address-tab State dropdown, 2026-10-27. Give it a real, visible tint. */
.select2-container--default .select2-results__option--selected,
.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: color-mix(in srgb, var(--highdmin-primary) 12%, transparent);
    color: var(--bs-body-color);
    font-weight: 600;
}

/* This theme's compiled CSS bundle never included Bootstrap's `.w-auto` utility (it's genuinely
   absent from app.min.css), so any `<select class="... w-auto">` placed inside an `.input-group`
   (e.g. Parties' Opening Balance "To Collect"/"To Pay" direction select) was still caught by
   Bootstrap's own `.input-group > .form-select { width: 1%; min-width: 0 }` rule and squashed down
   to an almost-invisible sliver — the option text only became visible once you clicked/focused it
   and the browser's native popout briefly widened it. Restore the utility, 2026-10-27. */
.w-auto { width: auto !important; }

/* ---------- Bulk Add Parties grid — Google-Sheets-style look (Module 3, 2026-10-27) ----------
   Not a real embedded spreadsheet (no Sheets API/OAuth fits an offline billing app) — a plain
   editable table styled to read like one: column letters, a sticky row-number gutter, per-cell
   borders, and borderless inputs that only reveal their cell outline on focus. */
.sh-grid-wrap {
    overflow: auto;
    max-width: 100%;
    border: 1px solid var(--bs-border-color);
    border-radius: .4rem;
}
#bulkGrid {
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}
#bulkGrid th, #bulkGrid td {
    border-right: 1px solid var(--bs-border-color);
    border-bottom: 1px solid var(--bs-border-color);
    padding: 0;
}
#bulkGrid thead tr.sh-grid-letters th {
    background: var(--bs-tertiary-bg, var(--bs-secondary-bg));
    color: var(--bs-secondary-color);
    font-weight: 600;
    text-align: center;
    font-size: .7rem;
    padding: .2rem .4rem;
    position: sticky;
    top: 0;
    z-index: 2;
}
#bulkGrid thead tr.sh-grid-fields th {
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    font-weight: 600;
    font-size: .75rem;
    padding: .45rem .6rem;
    white-space: nowrap;
    position: sticky;
    top: 22px;
    z-index: 2;
}
#bulkGrid .sh-grid-rownum,
#bulkGrid thead th.sh-grid-corner {
    position: sticky;
    left: 0;
    background: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    min-width: 36px;
    z-index: 1;
}
#bulkGrid thead th.sh-grid-corner { z-index: 3; }
#bulkGrid td input,
#bulkGrid td select {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    background-color: transparent;
    font-size: .8125rem;
    padding: .4rem .5rem;
}
#bulkGrid td input:focus,
#bulkGrid td select:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--highdmin-primary);
    background-color: var(--bs-body-bg);
}
#bulkGrid td input.is-invalid { background-color: color-mix(in srgb, var(--bs-danger) 8%, transparent); }
#bulkGrid td.sh-grid-delete-cell {
    text-align: center;
    position: sticky;
    right: 0;
    background: var(--bs-body-bg);
}

.sh-tab-preview-note {
    font-size: .75rem;
    color: var(--bs-secondary-color);
    background: var(--bs-secondary-bg);
    border-radius: .35rem;
    padding: .4rem .6rem;
    margin-bottom: .85rem;
}

/* ── Phase 1b items — inline validation errors + searchable selects ─────── */
.sh-inline-error {
    color: var(--bs-danger);
    font-size: .8rem;
    margin-top: .25rem;
}
.sh-ss .form-select {
    cursor: pointer;
}
.sh-ss-options .dropdown-item {
    font-size: .875rem;
}
/* myBillBook-style left tab nav used by tabbed item forms / settings modals */
.sh-modal-tabs {
    min-width: 200px;
}
.sh-modal-tabs .nav-link {
    text-align: start;
    border-radius: .45rem;
}
.sh-batch-card {
    background: var(--bs-tertiary-bg);
    border-radius: .5rem;
}

/* ---------- Page loader bar (see SH.loader in shell.js) ---------- */
#page-loader-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    z-index: 10000;
    pointer-events: none;
    transition: height .25s ease;
}

#page-loader-progress {
    height: 100%;
    width: 0%;
    background: #5b4bd6;
    opacity: 0;
    transition: width .2s ease-out, opacity .3s ease;
}

/* app.min.css reserves a 5px gap above .sidenav-menu/.app-topbar for this bar by default;
   we collapse that gap until the loader is actually running (see SH.loader in shell.js). */
.sidenav-menu,
.app-topbar {
    top: 0;
    transition: top .25s ease;
}

body.loader-active #page-loader-bar {
    height: 5px;
}

body.loader-active .sidenav-menu,
body.loader-active .app-topbar {
    top: 5px;
}

/* Airy table variant (Parties list) — more breathing room than the default dense tables. */
.sh-table-clean thead th {
    font-weight: 600;
    color: var(--bs-secondary-color);
    border-bottom-width: 1px;
    padding-top: .85rem;
    padding-bottom: .85rem;
}
.sh-table-clean tbody td {
    padding-top: 1rem;
    padding-bottom: 1rem;
}
