/* ==========================================================================
   Church Welfare Management System - theme
   Palette lifted from the supplied sample screenshot:
     Navy       #0B1D35  (headers, sidebar)
     Gold       #D4AF37  (accent stripe, highlights)
     Success    #1F9D55  (complete / paid / active pills)
     Warning    #C97A18  (pending / due pills)
     Danger     #C0392B  (overdue / rejected pills)
     Page bg    #F4F5F7
     Card bg    #FFFFFF
   ========================================================================== */

:root {
    --navy: #0B1D35;
    --navy-light: #16294a;
    --gold: #D4AF37;
    --gold-dark: #c19d2d;      /* hover shade of the accent */
    --on-gold: #0B1D35;        /* text on accent buttons */
    --on-navy: #FFFFFF;        /* text on primary-coloured areas */
    --success: #1F9D55;
    --success-bg: #E3F6EA;
    --warning: #C97A18;
    --warning-bg: #FCEFDD;
    --danger: #C0392B;
    --danger-bg: #FBEAE8;
    --muted: #6B7280;
    --page-bg: #F4F5F7;
    --card-bg: #FFFFFF;
    --border: #E5E7EB;
    --radius: 12px;
}

* { box-sizing: border-box; }

/* Global font-size reduction: 1rem now resolves to 14px instead of the
   browser default 16px, which scales every rem-based size in this file
   AND in Bootstrap's own CSS (which is rem-based throughout) down by the
   same ~12.5% - a single change instead of hunting down every rule. */
html { font-size: 14px; }

body {
    background-color: var(--page-bg);
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    color: #1F2937;
    font-size: .95rem;
}

a { color: var(--navy); }
a:hover { color: var(--gold); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--navy);
    color: #fff;
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.25rem 1.25rem 1.25rem;
    border-bottom: 3px solid var(--gold);
    margin-bottom: 1rem;
}

.sidebar .brand-title { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.sidebar .brand-sub { font-size: .72rem; color: #b9c2d4; }

.sidebar .nav-section-label {
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .06em;
    color: #8b96ad;
    padding: .9rem 1.25rem .35rem 1.25rem;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #dfe4ee;
    padding: .55rem 1.25rem;
    font-size: .92rem;
    border-left: 3px solid transparent;
    text-decoration: none;
}

.sidebar .nav-link:hover { background: var(--navy-light); color: #fff; }

.sidebar .nav-link-disabled {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #55617a;
    padding: .55rem 1.25rem;
    font-size: .92rem;
    border-left: 3px solid transparent;
    text-decoration: none;
    cursor: not-allowed;
    pointer-events: none;
}
.sidebar .nav-link-disabled::after {
    content: "\1F512";
    margin-left: auto;
    font-size: .75rem;
    opacity: .6;
}

.sidebar .nav-link.active {
    background: var(--navy-light);
    border-left-color: var(--gold);
    color: #fff;
    font-weight: 600;
}

.main-content { flex: 1; min-width: 0; }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: .85rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-body { padding: 1.5rem; }

/* ---------- Header banner (mirrors the sample's navy card with gold edge) ---------- */
.hero-banner {
    background: var(--navy);
    color: #fff;
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.hero-banner::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: var(--gold);
}

.hero-banner h1, .hero-banner h2 { color: #fff; margin: 0 0 .5rem 0; }
.hero-banner .text-muted-light { color: #b9c2d4; }

/* ---------- Cards ---------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--navy);
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    /* Lets .stat-value size itself off THIS card's own width (via the cqi
       unit below) rather than the viewport - so it shrinks correctly in a
       narrow column even on a wide screen, and grows back on a full-width
       card on mobile. */
    container-type: inline-size;
}

.stat-card .stat-label {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .05em;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
}

/* The currency code, e.g. "GH₵", moved up next to the label instead of
   glued onto the big number - see .stat-value below. */
.stat-card .stat-label .stat-unit {
    text-transform: none;
    letter-spacing: normal;
    font-weight: 600;
    white-space: nowrap;
}

.stat-card .stat-value {
    /* Fallback for browsers without container query units (the clamp()
       below is simply ignored as invalid there, leaving this in effect). */
    font-size: 1.35rem;
    /* Shrinks between 1rem and 1.6rem based on the card's own width, so a
       long figure (e.g. GH₵ 1,234,567.89) no longer overruns the card. */
    font-size: clamp(1rem, 9cqi, 1.6rem);
    font-weight: 700;
    color: var(--navy);
    line-height: 1.15;
    /* If a figure is still too wide even at the smallest size, wrap it
       onto a second line rather than clipping or ellipsis-truncating a
       digit out of a monetary amount - a hidden digit is far worse than an
       extra line. */
    overflow-wrap: anywhere;
}

/* Small supporting line under a stat value, e.g. "42.5% of contributions". */
.stat-card .stat-sub {
    font-size: .75rem;
    color: var(--muted);
    margin-top: .15rem;
}

/* ---------- Pills / badges ---------- */
.pill {
    display: inline-block;
    padding: .28rem .75rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.pill-success { background: var(--success-bg); color: var(--success); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }
.pill-danger  { background: var(--danger-bg);  color: var(--danger); }
.pill-neutral { background: #EEF0F3; color: var(--muted); }
.pill-navy    { background: #E7EBF3; color: var(--navy); }

/* ---------- Buttons ---------- */
.btn-brand {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}
.btn-brand:hover { background: var(--navy-light); border-color: var(--navy-light); color: #fff; }

.btn-gold {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--on-gold);
    font-weight: 600;
}
.btn-gold:hover { background: var(--gold-dark); border-color: var(--gold-dark); color: var(--on-gold); }

/* ---------- Tables ---------- */
.table thead th {
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .04em;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
    font-weight: 700;
}

.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background-color: #FAFBFC; }

/* ---------- Timeline / progress steps (mirrors the sample's placement-journey list) ---------- */
.step-list { border-left: 2px solid var(--border); margin-left: .6rem; }

.step-item { position: relative; padding: .35rem 0 .35rem 1.4rem; }

.step-item .step-dot {
    position: absolute;
    left: -11px;
    top: .4rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--success);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
}

/* ---------- Login page ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--navy) 0%, var(--navy) 45%, var(--page-bg) 45%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px color-mix(in srgb, var(--navy) 25%, transparent);
    padding: 2rem;
}

.login-card .gold-underline {
    width: 48px;
    height: 4px;
    background: var(--gold);
    border-radius: 2px;
    margin-bottom: 1rem;
}

/* ---------- Utility ---------- */
.section-title {
    font-weight: 700;
    color: var(--navy);
    margin-bottom: .75rem;
}

/* ---------- Form labels (match the .table thead th treatment) ---------- */
.form-label {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .05em;
    color: var(--navy);
    font-weight: 700;
    margin-bottom: .35rem;
}

/* ---------- Mobile navigation ----------
   Above 768px, the sidebar is always visible (original desktop layout,
   untouched). At or below it, the sidebar becomes an off-canvas panel that
   slides in from the left over a dimmed backdrop, opened by the hamburger
   button in the topbar - see wwwroot/js/mobile-nav.js. */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 34px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 7px;
    flex-shrink: 0;
}
.hamburger-btn span {
    display: block;
    height: 2px;
    background: var(--navy);
    border-radius: 1px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--navy) 50%, transparent);
    z-index: 1040;
}
.sidebar-backdrop.show { display: block; }

.min-width-0 { min-width: 0; }

@media (max-width: 768px) {
    .hamburger-btn { display: flex; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 270px;
        max-width: 82vw;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .sidebar.open { transform: translateX(0); }

    .main-content { width: 100%; min-width: 0; }

    .topbar {
        flex-wrap: wrap;
        row-gap: .6rem;
        padding: .75rem 1rem;
    }
    .topbar-actions { width: 100%; justify-content: flex-start; }

    .page-body { padding: 1rem; }

    .hero-banner { padding: 1.15rem 1.25rem; }
    .hero-banner::after { width: 6px; }

    /* Stat-card grids and filter-bar rows already use Bootstrap's
       responsive column classes, so they stack full-width automatically;
       this just tightens the gutters so stacked cards don't look like
       they're floating with too much side padding on a narrow screen. */
    .page-body .row { --bs-gutter-x: .75rem; }
}

@media (max-width: 400px) {
    /* Very narrow phones (older/smaller devices): drop the role pill from
       the topbar rather than let it wrap awkwardly - username and the
       actions that matter (change password, log out) stay. */
    .topbar-actions .pill-navy { display: none; }
}

/* ---------- Searchable select (type-to-search combobox) ----------
   Progressively enhances a plain <select> - see wwwroot/js/searchable-select.js */
.searchable-select { position: relative; }

.searchable-select-results {
    position: absolute;
    z-index: 20;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(16, 24, 40, .12);
}

.searchable-select-item { padding: .5rem .75rem; cursor: pointer; font-size: .85rem; }
.searchable-select-item:hover,
.searchable-select-item.active { background: var(--page-bg); }
.searchable-select-empty { padding: .5rem .75rem; color: var(--muted); font-size: .85rem; }

/* ---------- Printing (reports, statements, stock-taking sheet) ---------- */
.print-only { display: none; }
@media print {
    .sidebar, .sidebar-backdrop, .topbar, .hamburger-btn, .no-print, .alert { display: none !important; }
    .app-shell, .main-content, .page-body { display: block !important; margin: 0 !important; padding: 0 !important; }
    body { background: #fff !important; }
    .print-only { display: block !important; }
    .card { box-shadow: none !important; border: 0 !important; }
    .hero-banner { background: none !important; color: #000 !important; padding: 0 0 .5rem !important; box-shadow: none !important; }
    .hero-banner .text-muted-light { color: #333 !important; }
    .table { font-size: 10pt; }
    .table thead { display: table-header-group; }
    .table tr { break-inside: avoid; }
    a { color: #000 !important; text-decoration: none !important; }
    .pill { border: 1px solid #999; }
}

/* ---------- Grouped sidebar menu with icons ---------- */
.sidebar .nav-icon { width: 1.15rem; text-align: center; font-size: 1rem; flex-shrink: 0; opacity: .9; }
.sidebar .nav-group { margin-bottom: .15rem; }
.sidebar .nav-group-toggle {
    width: 100%; display: flex; align-items: center; gap: .6rem;
    background: none; border: 0; color: #8b96ad;
    text-transform: uppercase; font-size: .7rem; letter-spacing: .06em; font-weight: 600;
    padding: .7rem 1.25rem .4rem 1.25rem; text-align: left; cursor: pointer;
}
.sidebar .nav-group-toggle:hover, .sidebar .nav-group.has-active > .nav-group-toggle { color: #fff; }
.sidebar .nav-group-toggle .nav-icon { font-size: .9rem; color: var(--gold); opacity: 1; }
.sidebar .nav-group-toggle .chevron { margin-left: auto; font-size: .7rem; transition: transform .15s ease; }
.sidebar .nav-group.collapsed .nav-group-toggle .chevron { transform: rotate(-90deg); }
.sidebar .nav-group.collapsed .nav-group-items { display: none; }
.sidebar .nav-group-items .nav-link, .sidebar .nav-group-items .nav-link-disabled { padding-left: 1.6rem; }

/* ---------- Dashboard ---------- */
.kpi-card { display: flex; gap: .9rem; align-items: center; height: 100%; }
.kpi-card .kpi-icon {
    width: 2.6rem; height: 2.6rem; border-radius: .7rem; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
    background: color-mix(in srgb, var(--navy) 10%, transparent); color: var(--navy);
}
.kpi-card .kpi-icon.warn { background: #FFF4E0; color: #B26A00; }
.kpi-card .kpi-icon.danger { background: #FDECEC; color: #B42318; }
.kpi-card .kpi-icon.accent { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--gold-dark); }
.kpi-card .kpi-body { min-width: 0; flex: 1; }
a.kpi-link { color: inherit; text-decoration: none; display: block; height: 100%; }
a.kpi-link .stat-card { transition: box-shadow .15s ease, transform .15s ease; height: 100%; }
a.kpi-link:hover .stat-card { box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-1px); }

.chart-card .card-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.chart-card .card-header .bi { color: var(--gold-dark); margin-right: .35rem; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .9rem; }

.shortcut-group-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .4rem; display: flex; align-items: center; gap: .4rem; }
.shortcut-group-title .bi { color: var(--gold-dark); }
.shortcut {
    display: flex; align-items: center; gap: .55rem; padding: .5rem .65rem; border-radius: .5rem;
    color: var(--navy); text-decoration: none; font-size: .88rem; border: 1px solid var(--border); background: #fff; margin-bottom: .35rem;
}
.shortcut .bi { font-size: 1.05rem; }
.shortcut:hover { background: color-mix(in srgb, var(--navy) 6%, #fff); border-color: color-mix(in srgb, var(--navy) 25%, transparent); color: var(--navy); }

/* Compact dashboard charts: 2 rows of 4 on wide screens */
.chart-grid .card-header { padding: .45rem .75rem; font-size: .82rem; }
.chart-grid .card-header .small { font-size: .7rem; }
.chart-grid .card-body { padding: .5rem .6rem; }
.chart-grid .chart-box { height: 175px; }
@media (max-width: 767.98px) { .chart-grid .chart-box { height: 210px; } }

/* ---------- Corporate logo & developer credit ---------- */
.sidebar .brand { flex-direction: column; align-items: flex-start; }
.sidebar .brand-logo { display: block; background: #fff; border-radius: .6rem; padding: .45rem .6rem; margin-bottom: .2rem; }
.sidebar .brand-logo img { display: block; max-height: 64px; max-width: 150px; object-fit: contain; }
.logo-preview { width: 150px; height: 150px; border: 1px dashed var(--border); border-radius: .6rem; display: flex; align-items: center; justify-content: center; background: #fff; padding: .5rem; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.login-logo { text-align: center; margin-bottom: 1rem; }
.login-logo img { max-height: 110px; max-width: 220px; object-fit: contain; }
.login-credit { margin-top: 1.25rem; padding-top: .9rem; border-top: 1px solid var(--border); text-align: center; font-size: .78rem; color: var(--muted); }
.login-credit a { color: inherit; }
.app-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .4rem 1rem; padding: .9rem 1.5rem 1.2rem; font-size: .75rem; color: var(--muted); border-top: 1px solid var(--border); margin-top: 1rem; }
.app-footer a { color: inherit; }
