/* =========================================================================
   A & B Fashion POS — application styles (on top of Bootstrap 5.3)
   Brand: #81030F (burgundy) with a muted gold accent taken from the logo.
   ========================================================================= */

@font-face {
    font-family: "Noto Sans Sinhala";
    src: url("../fonts/NotoSansSinhala.ttf") format("truetype");
    font-display: swap;
    unicode-range: U+0D80-0DFF, U+200C-200D;
}

:root {
    --brand: #81030f;
    --brand-700: #6a020c;
    --brand-800: #520109;
    --brand-900: #3a0006;
    --brand-50: #fbf1f2;
    --brand-100: #f4dadd;
    --brand-200: #e8b5bb;
    --gold: #b8913f;
    --gold-50: #faf4e6;
    --ink: #221a1c;
    --ink-2: #4a4044;
    --muted: #776d71;
    --line: #e9e3e4;
    --line-2: #f1ecec;
    --surface: #ffffff;
    --canvas: #f7f4f3;
    --success: #1f7a4d;
    --warning: #a86500;
    --danger: #b42318;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(34, 26, 28, .05), 0 4px 16px rgba(34, 26, 28, .04);
    --sidebar-w: 248px;

    --bs-primary: var(--brand);
    --bs-primary-rgb: 129, 3, 15;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 129, 3, 15;
    --bs-link-hover-color: var(--brand-800);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--canvas);
    --bs-border-color: var(--line);
    --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", sans-serif;
    --bs-focus-ring-color: rgba(129, 3, 15, .25);
}

html { -webkit-text-size-adjust: 100%; }
body { font-size: .925rem; background: var(--canvas); color: var(--ink); }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn:hover, .nav-link:hover, .list-group-item:hover { text-decoration: none; }
.font-serif { font-family: Georgia, "Times New Roman", serif; }
.tabular, .money, .table td.num, .table th.num { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.text-muted, .muted { color: var(--muted) !important; }
.small-caps { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
:focus-visible { outline: 3px solid rgba(129, 3, 15, .35); outline-offset: 2px; }

/* ---- Bootstrap overrides ------------------------------------------------ */
.btn { border-radius: var(--radius-sm); font-weight: 600; }
.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-700); --bs-btn-hover-border-color: var(--brand-700);
    --bs-btn-active-bg: var(--brand-800); --bs-btn-active-border-color: var(--brand-800);
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand-200);
    --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brand-700); --bs-btn-active-border-color: var(--brand-700);
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--line); --bs-btn-hover-bg: var(--brand-50); --bs-btn-hover-border-color: var(--brand-100); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { background: #a37f33; color: #fff; }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: #ddd5d6; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--brand-200); box-shadow: 0 0 0 .2rem rgba(129, 3, 15, .15);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.form-text { font-size: .78rem; }
.badge { font-weight: 600; letter-spacing: .01em; }
.text-bg-brand { background: var(--brand-50) !important; color: var(--brand) !important; }
.text-bg-gold { background: var(--gold-50) !important; color: #7a5c19 !important; }
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--brand); }
.alert { border-radius: var(--radius); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand); }

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

.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--brand-800) 0%, var(--brand-900) 100%);
    color: #f6e9ea; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column;
}
.sidebar-brand { display: flex; flex-direction: column; align-items: center; padding: 18px 16px 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand img { width: 150px; height: auto; background: #fff; border-radius: 8px; padding: 6px 8px; }
.sidebar-brand small { margin-top: 8px; color: rgba(255,255,255,.55); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; }
.sidebar nav { padding: 12px 10px 18px; flex: 1; }
.nav-section { font-size: .65rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.45); padding: 14px 12px 6px; font-weight: 700; }
.side-link {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 1px 0;
    border-radius: 8px; color: rgba(255,255,255,.82); font-weight: 500; font-size: .9rem;
}
.side-link i { font-size: 1.05rem; width: 20px; text-align: center; color: rgba(255,255,255,.65); }
.side-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.side-link.active { background: #fff; color: var(--brand); font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.side-link.active i { color: var(--gold); }
.sidebar-foot { padding: 12px 16px 16px; font-size: .72rem; color: rgba(255,255,255,.45); border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 10px 24px; min-height: 60px;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.topbar .crumb { font-size: .75rem; color: var(--muted); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--brand-50); color: var(--brand);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; border: 1px solid var(--brand-100);
}
.content { padding: 22px 24px 40px; flex: 1; }
.content-narrow { max-width: 980px; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 1045; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.25); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1040; display: none; }
    .sidebar.open + .sidebar-backdrop { display: block; }
    .content { padding: 16px 16px 32px; }
    .topbar { padding: 8px 16px; }
}
@media (min-width: 992px) { .menu-toggle { display: none; } .sidebar-backdrop { display: none; } }

/* ---- Cards, panels, stats ---------------------------------------------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 700; padding: 12px 16px; border-radius: var(--radius) var(--radius) 0 0 !important; }
.card-title-sm { font-size: .95rem; font-weight: 700; margin: 0; }
.stat-card { padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); height: 100%; }
.stat-card .label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat-card .value { font-size: 1.55rem; font-weight: 750; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-card .foot { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.stat-card .icon { width: 38px; height: 38px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: var(--brand-50); color: var(--brand); font-size: 1.1rem; }
.stat-card.warn .icon { background: #fff4e0; color: var(--warning); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-actions h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.page-actions .lead-text { color: var(--muted); font-size: .85rem; margin: 2px 0 0; }

/* ---- Tables -------------------------------------------------------------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .65rem .75rem; border-color: var(--line-2); }
.table thead th {
    background: #faf8f8; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
    font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--brand-50); }
.table-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-card .table-responsive { margin: 0; }
.table tfoot td { font-weight: 700; background: #faf8f8; }
.empty-state { text-align: center; padding: 42px 16px; color: var(--muted); }
.empty-state i { font-size: 2rem; color: var(--brand-200); display: block; margin-bottom: 8px; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--line-2); }
.thumb-lg { width: 100%; max-width: 320px; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.15); vertical-align: -2px; }

/* Responsive tables become stacked cards on phones */
@media (max-width: 767.98px) {
    .table-stack, .table-stack tbody, .table-stack tfoot { display: block; width: 100%; }
    .table-stack thead { display: none; }
    .table-stack tr { display: block; width: 100%; border-bottom: 1px solid var(--line); padding: 8px 4px; }
    .table-stack td { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; width: 100%;
        border: 0 !important; padding: 4px 10px !important; text-align: right; overflow-wrap: anywhere; min-width: 0 !important; }
    .table-stack td::before { content: attr(data-label); flex: 0 0 auto; font-weight: 600; color: var(--muted); text-align: left; font-size: .8rem; }
    .table-stack td > * { min-width: 0; }
    .table-stack td[data-label=""]::before { content: none; }
    .table-stack td[data-label=""] { justify-content: flex-end; }
    .table-stack td[data-label="Product"], .table-stack td[data-label="Item"], .table-stack td[data-label="Receipt"],
    .table-stack td[data-label="Product / variant"], .table-stack td[data-label="Name"] { text-align: left; }
    .table-responsive:has(.table-stack) { overflow-x: visible; }
}

/* ---- Filters ------------------------------------------------------------- */
.filter-bar { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; box-shadow: var(--shadow); }

/* ---- Status pills -------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.pill-success { background: #e7f5ee; color: var(--success); }
.pill-warning { background: #fff4e0; color: var(--warning); }
.pill-danger { background: #fdecea; color: var(--danger); }
.pill-muted { background: #f1eeee; color: var(--muted); }
.pill-brand { background: var(--brand-50); color: var(--brand); }

/* ---- Auth pages ---------------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.auth-art {
    background: radial-gradient(circle at 30% 20%, #9a1220 0%, var(--brand) 35%, var(--brand-900) 100%);
    color: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: 48px;
}
.auth-art img { width: 280px; max-width: 70%; background: #fff; border-radius: 14px; padding: 12px 16px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.auth-art h2 { font-family: Georgia, serif; font-weight: 400; font-size: 2rem; margin-top: 36px; }
.auth-art p { color: rgba(255,255,255,.75); max-width: 420px; }
.auth-art .addr { font-size: .8rem; color: rgba(255,255,255,.6); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 1.5rem; font-weight: 750; }
@media (max-width: 860px) {
    .auth-page { grid-template-columns: 1fr; }
    .auth-art { padding: 28px 24px; align-items: center; text-align: center; }
    .auth-art h2, .auth-art p, .auth-art .addr { display: none; }
    .auth-art img { width: 200px; }
}

/* ---- Toasts -------------------------------------------------------------- */
.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.app-toast { background: var(--ink); color: #fff; border-radius: 9px; padding: 11px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: .88rem; display: flex; gap: 10px; align-items: flex-start; animation: toast-in .18s ease-out; }
.app-toast.success { background: #18603d; }
.app-toast.error { background: #9b1c13; }
.app-toast.warning { background: #8a5300; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Misc ---------------------------------------------------------------- */
.kbd { display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; font-size: .72rem; background: #fff; color: var(--muted); font-family: ui-monospace, monospace; }
.code-chip { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; background: var(--line-2); padding: 1px 6px; border-radius: 5px; }
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: .9rem; }
.dl-grid dt { color: var(--muted); font-weight: 500; }
.dl-grid dd { margin: 0; font-weight: 600; }
.chart-box { position: relative; height: 240px; }
.spinner-inline { width: 1rem; height: 1rem; border-width: .15em; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(247,244,243,.95); padding: 12px 0; border-top: 1px solid var(--line); z-index: 5; }
.variant-grid input[type=number] { max-width: 120px; }

@media print {
    .sidebar, .topbar, .no-print, .toast-stack { display: none !important; }
    .content { padding: 0; }
    body { background: #fff; }
}

/* Keep the first (name) column readable in wide tables on larger screens */
@media (min-width: 768px) {
    .table-stack td:first-child, .table-stack th:first-child { min-width: 220px; }
}
.table td.num, .table th.num { white-space: nowrap; }
@media (max-width: 575.98px) {
    .stat-card { padding: 12px 14px; }
    .stat-card .value { font-size: 1.15rem; }
    .page-actions h2 { font-size: 1rem; }
}

/* Developer credit */
.app-footer { margin-top: 2rem; padding: 1rem 0 .25rem; border-top: 1px solid rgba(0,0,0,.06); text-align: center; }
.app-footer-minimal { border-top: 0; margin-top: 0; padding: .75rem 0 1rem; }
.app-credit { margin: 0; font-size: .78rem; color: #8a8a8a; }
.app-credit a { color: var(--brand, #81030F); font-weight: 600; text-decoration: none; }
.app-credit a:hover, .app-credit a:focus { text-decoration: underline; }
@media print { .app-footer { display: none; } }
.auth-form { position: relative; }
.auth-credit { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; }
.auth-page ~ .app-footer-minimal { display: none; }
@media (max-width: 860px) { .auth-credit { position: static; margin-top: 2rem; } .auth-form { flex-direction: column; } }

/* Product gallery (more images) */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.gallery-item { border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; display: flex; flex-direction: column; gap: 4px; }
.gallery-item img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 6px; background: var(--canvas); }
.gallery-tools { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.gallery-tools .btn { padding: 0 6px; line-height: 1.6; }
.gallery-pos { font-size: .8rem; font-weight: 700; color: var(--muted); }
.gallery-remove { color: var(--danger); text-align: center; }
.gallery-item.is-removed { opacity: .45; }
.gallery-item.is-removed img { filter: grayscale(1); }
.gallery-item.is-new { border-color: #b7dfc8; }
