/*!
 * Our God is Able Credit and Savings - application styles
 * Mobile first, Bootstrap 5.3 compatible.
 */

:root {
    --brand: #14532d;
    --brand-light: #16a34a;
    --brand-soft: #f0fdf4;
    --ink: #1f2937;
    --sidebar-width: 268px;
    --header-height: 60px;
    --radius: .85rem;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body.app-body {
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    min-height: 100vh;
}

body.blank-body {
    font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    background: #f8fafc;
}

/* ---------------------------------------------------------------- header */

.app-header {
    min-height: var(--header-height);
    z-index: 1030;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: .65rem;
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    color: #fff;
    font-size: 1.1rem;
}

.brand-mark-lg {
    width: 52px;
    height: 52px;
    font-size: 1.5rem;
}

.notification-badge {
    font-size: .65rem;
    padding: .15em .35em;
}

.avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: .75rem;
    font-weight: 700;
}

.avatar-lg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 1.8rem;
    font-weight: 700;
}

/* --------------------------------------------------------------- sidebar */

.app-wrapper {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - var(--header-height));
}

.app-sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: #fff;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.app-sidebar::-webkit-scrollbar {
    width: 8px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.app-sidebar .offcanvas-body {
    overflow-y: auto;
    height: 100%;
}

.app-main {
    flex: 1 1 auto;
    padding: 1.25rem;
    min-width: 0;
}

.sidebar-nav {
    padding: .75rem 0 1.5rem;
}

.sidebar-group {
    margin-bottom: 1rem;
}

.sidebar-group-scroll {
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.sidebar-group-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-group-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.sidebar-group-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.sidebar-label {
    padding: .5rem 1.25rem .25rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #9ca3af;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem 1.25rem;
    color: #374151;
    text-decoration: none;
    font-size: .925rem;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease;
}

.sidebar-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
}

.sidebar-link:hover {
    background: #f8fafc;
    color: var(--brand);
}

.sidebar-link.active {
    background: var(--brand-soft);
    color: var(--brand);
    border-left-color: var(--brand);
    font-weight: 600;
}

.sidebar-footer {
    margin: 1rem 1.25rem 0;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.app-footer {
    background: #fff;
}

/* ----------------------------------------------------------------- cards */

.card {
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
}

.card-header {
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
}

.stat-card {
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 .5rem 1rem rgba(16, 24, 40, .08);
}

.stat-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.25;
    word-break: break-word;
}

.stat-sub {
    font-size: .78rem;
    color: #6b7280;
}

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: .75rem;
    font-size: 1.2rem;
    flex: 0 0 auto;
}

.stat-icon-primary { background: #e0e7ff; color: #4338ca; }
.stat-icon-success { background: #dcfce7; color: #15803d; }
.stat-icon-warning { background: #fef3c7; color: #b45309; }
.stat-icon-danger  { background: #fee2e2; color: #b91c1c; }
.stat-icon-info    { background: #cffafe; color: #0e7490; }
.stat-icon-dark    { background: #e5e7eb; color: #111827; }

.page-header h1 {
    font-weight: 700;
}

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

/* ---------------------------------------------------------------- tables */

.table > :not(caption) > * > * {
    padding: .6rem .75rem;
    vertical-align: middle;
}

.table thead th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
    background: #f8fafc;
    white-space: nowrap;
}

.table-hover tbody tr:hover {
    background-color: #f6fbf8;
}

/* --------------------------------------------------------------- forms */

.form-label {
    font-weight: 600;
    font-size: .875rem;
    margin-bottom: .3rem;
}

.form-control,
.form-select {
    border-radius: .55rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-light);
    box-shadow: 0 0 0 .2rem rgba(22, 163, 74, .15);
}

.btn {
    border-radius: .55rem;
}

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: #166534;
    --bs-btn-hover-border-color: #166534;
    --bs-btn-active-bg: #14532d;
    --bs-btn-active-border-color: #14532d;
}

.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
}

.password-meter {
    height: 6px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.password-meter-bar {
    height: 100%;
    width: 0;
    background: #ef4444;
    transition: width .2s ease, background .2s ease;
}

/* ---------------------------------------------------------------- login */

.login-page {
    background: linear-gradient(135deg, #ecfdf5 0%, #f8fafc 55%, #eff6ff 100%);
}

.login-brand {
    background: linear-gradient(160deg, var(--brand) 0%, #0f766e 100%);
}

.min-vh-100 {
    min-height: 100vh;
}

/* ------------------------------------------------------- member bottom nav */

.member-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1020;
    display: flex;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding-bottom: env(safe-area-inset-bottom);
}

.member-bottom-nav a {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    padding: .5rem .25rem;
    font-size: .68rem;
    color: #6b7280;
    text-decoration: none;
}

.member-bottom-nav a i {
    font-size: 1.15rem;
}

.member-bottom-nav a.active {
    color: var(--brand);
    font-weight: 600;
}

body.member-body {
    padding-bottom: 4.5rem;
}

@media (min-width: 992px) {
    body.member-body {
        padding-bottom: 0;
    }
}

/* ---------------------------------------------------------------- utility */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand);
    color: #fff;
    padding: .5rem 1rem;
    z-index: 2000;
}

.skip-link:focus {
    left: 0;
}

@media print {
    .app-header,
    .app-sidebar,
    .app-footer,
    .member-bottom-nav,
    .no-print {
        display: none !important;
    }

    .app-main {
        padding: 0;
    }

    body {
        background: #fff;
    }
}

/* ------------------------------------------------- scrollable form bodies */
/*
 * Long forms (member registration, user credentials) are capped to the
 * viewport and scroll inside themselves, so the page header and the action
 * buttons stay reachable instead of scrolling away.
 */

.form-scroll {
    max-height: min(76vh, 780px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
    padding-right: .35rem;
}

.form-scroll::-webkit-scrollbar {
    width: 10px;
}

.form-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 999px;
}

.form-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
    border: 2px solid #f1f5f9;
}

.form-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Keep the primary action visible while the form body scrolls. */
.form-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.form-scroll-hint {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .75rem;
    color: #6b7280;
    margin-bottom: .5rem;
}

/* ------------------------------------------------------------ ajax states */

.ajax-busy {
    position: relative;
    pointer-events: none;
    opacity: .65;
}

[data-ajax-form] .ajax-status {
    display: none;
}

[data-ajax-form].has-errors .ajax-status {
    display: block;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ----------------------------------------------------------- responsive */

/*
 * Below the tablet breakpoint a nested scroll area traps the page scroll and
 * fights the mobile URL bar, so the form returns to normal document flow.
 * Everything above stays capped.
 */
@media (max-width: 767.98px) {
    .form-scroll {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .form-actions {
        position: static;
    }

    .form-actions .btn {
        flex: 1 1 auto;
    }

    .form-scroll-hint {
        display: none;
    }
}

@media (min-width: 768px) and (max-height: 620px) {
    .form-scroll {
        max-height: 68vh;
    }
}

@media (max-width: 575.98px) {
    .stat-value {
        font-size: 1.1rem;
    }

    .app-main {
        padding: .75rem;
    }

    .btn {
        min-height: 44px;
    }

    .form-control,
    .form-select {
        font-size: 16px;
    }

    .table {
        font-size: .85rem;
    }

    .table > :not(caption) > * > * {
        padding: .45rem .5rem;
    }

    .card-body {
        padding: .9rem;
    }

    .form-actions {
        padding: .75rem .9rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .offcanvas {
        width: 85vw;
    }

    .member-nav .nav-link {
        padding: .5rem .75rem;
    }
}

/* ------------------------------------------------- member portal nav bar */

.member-nav .nav-link {
    color: #374151;
    font-size: .9rem;
    font-weight: 500;
    padding: .45rem .85rem;
    border-radius: .55rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}

.member-nav .nav-link:hover {
    background: #f8fafc;
    color: var(--brand);
}

.member-nav .nav-link.active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}

.member-nav .nav-pills {
    scrollbar-width: thin;
}

/* On small screens the nav collapses into the bottom bar instead. */
@media (max-width: 991.98px) {
    .member-nav {
        display: none !important;
    }
}

/* ---------------------------------------------------- touch targets */
.btn,
.nav-link,
.sidebar-link {
    touch-action: manipulation;
}

/* ---------------------------------------------------- horizontal scrollbars */
.table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
    padding-bottom: .25rem;
}

.table-wrap::-webkit-scrollbar {
    height: 10px;
}

.table-wrap::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
    border: 2px solid #f1f5f9;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================================ beauty theme */

body.app-body {
    background: linear-gradient(180deg, #f6fbf8 0%, #eef4f1 100%);
}

.app-header {
    box-shadow: 0 2px 12px rgba(20, 83, 45, .06);
    backdrop-filter: saturate(180%) blur(6px);
    background: linear-gradient(120deg, #0f3d24 0%, #14532d 50%, #1a7431 100%) !important;
    color: #fff;
}

.app-header .navbar-brand,
.app-header .nav-link,
.app-header .btn-light {
    color: #fff !important;
}

.app-header .btn-light {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .2);
    color: #fff;
}

.app-header .btn-light:hover {
    background: rgba(255, 255, 255, .22);
}

.app-header .brand-mark {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1f2937;
}

.app-header .navbar-toggler {
    border-color: rgba(255, 255, 255, .3);
}

.brand-mark {
    box-shadow: 0 4px 10px rgba(20, 83, 45, .25);
}

.card {
    box-shadow: 0 6px 18px rgba(15, 23, 42, .05);
    border: 1px solid rgba(229, 231, 235, .7);
    transition: box-shadow .2s ease, transform .2s ease;
}

.card:hover {
    box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
}

.card-header {
    background: linear-gradient(90deg, #f8fafc 0%, #f0fdf4 100%);
}

.stat-card {
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(22, 163, 74, .04), transparent 60%);
    pointer-events: none;
}

.stat-icon {
    box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
}

.btn {
    box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, .1);
}

.btn-primary {
    background: linear-gradient(135deg, #14532d, #16a34a);
    border: none;
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.form-control, .form-select {
    border: 1px solid #d1d5db;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 .2rem rgba(22, 163, 74, .18);
}

.table {
    border-radius: .75rem;
    overflow: hidden;
}

.table thead th {
    background: linear-gradient(180deg, #f8fafc, #f1f5f9);
    border-bottom: 2px solid #e5e7eb;
}

.table tbody tr {
    transition: background .12s ease;
}

.table-hover tbody tr:hover {
    background: #f0fdf4;
}

.page-header h1 {
    background: linear-gradient(90deg, #14532d, #16a34a);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.app-sidebar {
    box-shadow: 2px 0 12px rgba(15, 23, 42, .04);
}

.sidebar-link.active {
    box-shadow: inset 3px 0 0 #16a34a;
}

.app-footer {
    background: linear-gradient(90deg, #fff, #f8fafc);
}

/* Monthly summary split circle */
.month-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .1);
    border: 4px solid #e5e7eb;
}

.month-circle-half {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: .5rem .25rem;
    text-align: center;
}

.month-circle-left {
    background: linear-gradient(160deg, #dcfce7, #bbf7d0);
    color: #14532d;
}

.month-circle-right {
    background: linear-gradient(160deg, #fef3c7, #fde68a);
    color: #92400e;
}

/* Soft entrance animation for cards */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .stat-card {
    animation: fadeUp .35s ease both;
}

/* Badge polish */
.badge {
    font-weight: 600;
    letter-spacing: .02em;
    border-radius: .5rem;
}

/* Empty state hint */
.text-muted {
    color: #6b7280 !important;
}

/* Print keeps clean */
@media print {
    body.app-body { background: #fff; }
    .card { box-shadow: none; }
}

/* Generic horizontal scroll containers get a visible bottom scrollbar. */
.scroll-x {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
}

.scroll-x::-webkit-scrollbar {
    height: 10px;
}

.scroll-x::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 999px;
}

.scroll-x::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
    border: 2px solid #f1f5f9;
}