/* =====================================================================
   Product Credit & Payment Monitoring System — app stylesheet
   Mobile-first. Sidebar is fixed on >=992px, off-canvas below that.
   ===================================================================== */

:root {
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 60px;
    --sidebar-bg: #1f2a44;
    --sidebar-bg-2: #182138;
    --sidebar-active: #3b82f6;
    --ink: #1b2333;
    --muted: #6b7688;
    --surface: #ffffff;
    --canvas: #f2f4f8;
    --border: #e4e8ef;
}

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

html, body { height: 100%; }

body {
    background: var(--canvas);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: .925rem;
    overflow-x: hidden;
}

/* ---------------------------------------------------------------------
   Shell
   --------------------------------------------------------------------- */
.app-wrapper { min-height: 100vh; display: flex; }

.main-column {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: 0;
    transition: margin-left .22s ease;
}

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: #cbd5ea;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform .25s ease, width .22s ease;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    min-height: var(--topbar-h);
}

.brand-icon {
    width: 34px; height: 34px;
    flex: 0 0 34px;
    border-radius: 9px;
    background: var(--sidebar-active);
    color: #fff;
    display: grid; place-items: center;
    font-size: 1.05rem;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { color: #fff; font-size: .95rem; white-space: nowrap; }
.brand-text small { color: #8fa0c4; font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: .75rem .6rem 1rem; scrollbar-width: thin; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 6px; }

.nav-section-title {
    margin: .9rem .7rem .35rem;
    font-size: .65rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #7b8cb3;
    white-space: nowrap;
}

.sidebar-nav .nav-link,
.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .58rem .75rem;
    margin-bottom: 2px;
    border-radius: 8px;
    color: #c3cee6;
    font-size: .875rem;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar-nav .nav-link i,
.sidebar-footer .nav-link i { font-size: 1.05rem; flex: 0 0 20px; text-align: center; }

.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, .35);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding: .55rem .6rem .7rem;
    background: rgba(0, 0, 0, .12);
}

.sidebar-footer .nav-link { margin-bottom: 0; }
.collapse-toggle { width: 100%; background: none; border: 0; cursor: pointer; text-align: left; }

/* ---------------------------------------------------------------------
   Sidebar submenu (Products > All Products / Categories)
   --------------------------------------------------------------------- */
.sub-toggle {
    flex: 0 0 34px;
    width: 34px; height: 34px;
    margin-right: .35rem;
    display: grid; place-items: center;
    border: 0; border-radius: 8px;
    background: none;
    color: #9fb0d4;
    transition: background-color .15s ease, color .15s ease;
}
.sub-toggle:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.sub-toggle i { display: block; transition: transform .2s ease; }
.sub-toggle:not(.collapsed) i { transform: rotate(180deg); }

.sub-nav {
    list-style: none;
    margin: 0;
    padding: 0 0 .3rem;
}
.sub-nav .nav-link {
    padding-left: 1.7rem;
    font-size: .83rem;
    color: #a9b8da;
}
.sub-nav .nav-link i { font-size: .85rem; flex: 0 0 16px; }
.sub-nav .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sub-nav .nav-link.active { background: rgba(59, 130, 246, .35); color: #fff; box-shadow: none; }

.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(2px);
    z-index: 1045;
    opacity: 0; visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
}

/* Mobile / tablet: off-canvas */
@media (max-width: 991.98px) {
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
}

/* Desktop */
@media (min-width: 992px) {
    .sidebar { transform: translateX(0); }
    .main-column { margin-left: var(--sidebar-w); }
    body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
    body.sidebar-collapsed .main-column { margin-left: var(--sidebar-w-collapsed); }
    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .nav-section-title { opacity: 0; visibility: hidden; }
    body.sidebar-collapsed .sub-nav,
    body.sidebar-collapsed .sub-toggle { display: none; }
    body.sidebar-collapsed .nav-item.has-sub > .d-flex > .nav-link { justify-content: center; padding-inline: .5rem; gap: 0; }
    body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: .5rem; }
    body.sidebar-collapsed .sidebar-nav .nav-link,
    body.sidebar-collapsed .sidebar-footer .nav-link { justify-content: center; padding-inline: .5rem; gap: 0; }
    body.sidebar-collapsed #sidebarClose { display: none !important; }
}

/* ---------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------- */
.topbar {
    position: sticky; top: 0;
    z-index: 1030;
    min-height: var(--topbar-h);
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem clamp(.75rem, 2vw, 1.5rem);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-title { line-height: 1.1; margin-left: .35rem; }
.topbar-title h1 { font-weight: 650; letter-spacing: -.01em; }
.topbar-title small { font-size: .7rem; }

.topbar-actions { display: flex; align-items: center; gap: .5rem; }

.nav-icon-btn {
    width: 38px; height: 38px;
    display: inline-grid; place-items: center;
    border-radius: 9px;
    color: var(--ink);
    font-size: 1.3rem;
    text-decoration: none;
}
.nav-icon-btn:hover { background: #eceff5; color: var(--ink); }

.user-chip { border-radius: 999px; background: #fff; }

/* ---------------------------------------------------------------------
   Content / footer
   --------------------------------------------------------------------- */
.content {
    flex: 1 1 auto;
    padding: clamp(.85rem, 2vw, 1.5rem);
    max-width: 1600px;
    width: 100%;
}

.app-footer {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: .35rem;
    padding: .85rem clamp(.85rem, 2vw, 1.5rem);
    border-top: 1px solid var(--border);
    font-size: .78rem;
    color: var(--muted);
    background: #fff;
}

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

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 650;
    padding: .85rem 1.1rem;
}

.stat-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 1rem 1.1rem;
    height: 100%;
    display: flex; gap: .9rem; align-items: flex-start;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(16, 24, 40, .08); }

.stat-icon {
    width: 44px; height: 44px; flex: 0 0 44px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 1.25rem;
}
.stat-icon.bg-soft-primary   { background: #e8f1ff; color: #2563eb; }
.stat-icon.bg-soft-success    { background: #e6f7ef; color: #16a34a; }
.stat-icon.bg-soft-warning    { background: #fdf2e2; color: #d97706; }
.stat-icon.bg-soft-danger     { background: #fdeaea; color: #dc2626; }
.stat-icon.bg-soft-info       { background: #e6f4f8; color: #0891b2; }
.stat-icon.bg-soft-secondary  { background: #eef0f4; color: #475569; }

.stat-body { min-width: 0; }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat-value { font-size: clamp(1.1rem, 2.2vw, 1.45rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.25; word-break: break-word; }
.stat-meta  { font-size: .74rem; color: var(--muted); }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table-responsive { -webkit-overflow-scrolling: touch; }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    padding: .7rem .85rem;
}
.table tbody td { padding: .72rem .85rem; vertical-align: middle; border-color: var(--border); }
.table-hover tbody tr:hover { background: #f8fafc; }
.table-sm thead th, .table-sm tbody td { padding: .5rem .7rem; }

.cell-main { font-weight: 600; }
.cell-sub  { font-size: .75rem; color: var(--muted); }
.amount    { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
}
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .5; }

/* ---------------------------------------------------------------------
   Misc components
   --------------------------------------------------------------------- */
.page-toolbar {
    display: flex; flex-wrap: wrap; gap: .6rem;
    align-items: center; justify-content: space-between;
    margin-bottom: 1rem;
}
.page-toolbar .form-control, .page-toolbar .form-select { max-width: 260px; }

.progress-thin { height: 7px; border-radius: 999px; background: #eceff4; }
.progress-thin .progress-bar { border-radius: 999px; }

.badge { font-weight: 600; letter-spacing: .02em; }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: .6rem 0; border-bottom: 1px dashed var(--border); }
.list-plain li:last-child { border-bottom: 0; }

.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-grid; place-items: center;
    background: #e8f1ff; color: #2563eb;
    font-weight: 700; font-size: .8rem;
    flex: 0 0 34px;
}

.modal-content { border: 0; border-radius: 16px; box-shadow: 0 24px 60px rgba(15, 23, 42, .22); }
.modal-header { border-bottom-color: var(--border); }
.modal-footer { border-top-color: var(--border); }
.confirm-icon { font-size: 1.05rem; vertical-align: -2px; }
#confirmMessage { line-height: 1.55; color: var(--muted); }

.form-control, .form-select { border-radius: 9px; border-color: #d7dce5; }
.form-control:focus, .form-select:focus { border-color: #93b4fb; box-shadow: 0 0 0 .18rem rgba(59,130,246,.16); }
.form-label { font-size: .8rem; font-weight: 600; color: #46506a; margin-bottom: .3rem; }
.input-group-text { border-color: #d7dce5; background: #f8fafc; }

.btn { border-radius: 9px; font-weight: 600; font-size: .875rem; }
.btn-light { border: 1px solid var(--border); }

.alert { border-radius: 12px; border: 0; font-size: .875rem; }

.quick-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .7rem .8rem;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    transition: .15s ease;
}
.quick-link:hover { border-color: #b9cdfa; background: #f6f9ff; color: #1d4ed8; transform: translateY(-1px); }
.quick-link i { font-size: 1.1rem; color: var(--sidebar-active); }

.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 1rem; }
.timeline-item::before {
    content: ""; position: absolute; left: -1.4rem; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: #fff; border: 2px solid var(--sidebar-active);
}

/* ---------------------------------------------------------------------
   Credit creation: product catalogue + cart
   --------------------------------------------------------------------- */
.product-card {
    display: flex; flex-direction: column; gap: .3rem;
    height: 100%; padding: .6rem;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    transition: box-shadow .15s ease, transform .15s ease;
}
.product-card:hover { box-shadow: 0 8px 20px rgba(15, 23, 42, .08); transform: translateY(-1px); }
.product-name { font-weight: 600; font-size: .84rem; line-height: 1.25; }
.product-meta { font-size: .7rem; color: var(--muted); }
.product-price { font-weight: 700; font-size: .85rem; color: var(--sidebar-active); margin-top: auto; }

.cart-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem 0; border-bottom: 1px dashed var(--border);
}
.cart-item:last-child { border-bottom: 0; }
.cart-item-main { flex: 1 1 auto; min-width: 0; }
.cart-item-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-meta { font-size: .7rem; color: var(--muted); }

.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.qty-btn {
    width: 26px; height: 28px; border: 0; line-height: 1;
    background: #f6f8fc; color: var(--ink); font-weight: 700;
}
.qty-btn:hover { background: #eaeff8; }
.qty-input {
    width: 42px; height: 28px; border: 0; text-align: center;
    font-size: .8rem; color: var(--ink); background: #fff;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cart-line-total { min-width: 74px; text-align: right; font-size: .8rem; font-weight: 600; }
.cart-remove {
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; width: 26px; height: 26px;
    border: 0; border-radius: 50%;
    background-color: #fdeaea; color: #c0392b;
    font-size: 1.05rem; line-height: 1; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    transition: background-color .15s ease, color .15s ease;
}
.cart-remove:hover { background-color: #f9d6d3; color: #922b21; }
.cart-remove:active { background-color: #f4c4c0; }
.cart-remove:focus-visible { outline: 2px solid #c0392b; outline-offset: 1px; }

/* Height-bounded cart panel: body scrolls, header + footer stay visible */
.cart-panel { top: 76px; }
@media (min-width: 992px) {
    .cart-panel {
        position: sticky;
        display: flex;
        max-height: calc(100vh - 96px);
    }
    .cart-panel > .card {
        display: flex; flex-direction: column;
        width: 100%; min-height: 0; overflow: hidden;
    }
    .cart-panel .card-header,
    .cart-panel .cart-footer { flex: 0 0 auto; }
    .cart-panel .cart-body {
        flex: 1 1 auto; min-height: 0;
        overflow-y: auto; overscroll-behavior: contain;
    }
}
.cart-footer { background: #fff; }



/* ---------------------------------------------------------------------
   Login page
   --------------------------------------------------------------------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background:
        radial-gradient(1000px 500px at 15% 10%, rgba(59,130,246,.20), transparent 60%),
        radial-gradient(900px 500px at 85% 90%, rgba(14,165,233,.18), transparent 60%),
        #10182c;
}
.auth-card { width: 100%; max-width: 420px; border: 0; border-radius: 18px; box-shadow: 0 30px 70px rgba(0,0,0,.35); }

/* Login verification modal: rounded progress ring + step list */
.verify-ring-wrap { position: relative; width: 128px; height: 128px; }
.verify-ring { width: 128px; height: 128px; transform: rotate(-90deg); }
.verify-ring .ring-bg { fill: none; stroke: #e6eaf2; stroke-width: 9; }
.verify-ring .ring-bar {
    fill: none;
    stroke: var(--sidebar-active);
    stroke-width: 9;
    stroke-linecap: round;
    transition: stroke-dashoffset .25s ease;
}
.verify-percent {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ink);
}
.verify-steps { list-style: none; padding: 0; margin: 0; }
.verify-steps li {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .3rem 0;
    color: var(--muted);
}
.verify-steps li .step-dot {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border-radius: 50%;
    border: 2px solid #cdd5e4;
    box-sizing: border-box;
}
.verify-steps li.done { color: #16a34a; }
.verify-steps li.done .step-dot { border-color: #16a34a; background: #16a34a; }
.verify-steps li.done .step-dot::after {
    content: "";
    display: block;
    width: 4px;
    height: 8px;
    margin: 0 auto;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translateY(-1px) rotate(45deg);
}
.verify-steps li.active { color: var(--sidebar-active); font-weight: 600; }
.verify-steps li.active .step-dot {
    border-color: var(--sidebar-active);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .16);
}

/* ---------------------------------------------------------------------
   Print
   --------------------------------------------------------------------- */
@media print {
    .sidebar, .sidebar-backdrop, .topbar, .app-footer, .page-toolbar, .no-print, .btn { display: none !important; }
    .main-column { margin-left: 0 !important; }
    .content { padding: 0; }
    body { background: #fff; }
    .card { border: 1px solid #ddd; box-shadow: none; }
    .table thead th { background: #f3f3f3 !important; -webkit-print-color-adjust: exact; }
}
