/* ==========================================================================
   Electronics POS — application theme
   A calm, dense, professional admin surface built on Bootstrap 5.
   ========================================================================== */

:root {
    --brand: #2563eb;
    --brand-rgb: 37, 99, 235;
    --brand-dark: #1d4ed8;
    --brand-soft: rgba(37, 99, 235, .1);

    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-50: #f8fafc;

    --ok: #059669;
    --ok-soft: rgba(5, 150, 105, .1);
    --warn: #d97706;
    --warn-soft: rgba(217, 119, 6, .12);
    --bad: #dc2626;
    --bad-soft: rgba(220, 38, 38, .1);
    --info: #0891b2;

    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 62px;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .07);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);

    --bs-body-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--bs-body-font-family);
    background: var(--ink-50);
    color: var(--ink-700);
    font-size: .875rem;
    line-height: 1.55;
}

h1, h2, h3, h4, h5, h6 { color: var(--ink-900); font-weight: 600; letter-spacing: -.01em; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

/* ------------------------------------------------------------------ Layout */

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: #0b1220;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width .18s ease, transform .18s ease;
}

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

.sidebar-brand .logo-mark {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand), #7c3aed);
    display: grid; place-items: center;
    color: #fff; font-size: 1rem; font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(var(--brand-rgb), .4);
    overflow: hidden;
}
.sidebar-brand .logo-mark img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-brand .brand-text { min-width: 0; }
.sidebar-brand .brand-name {
    color: #fff; font-weight: 650; font-size: .95rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand .brand-sub { font-size: .68rem; color: #64748b; letter-spacing: .04em; text-transform: uppercase; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .75rem .65rem 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: #1e293b transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 3px; }

.nav-section {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #475569;
    font-weight: 600;
    padding: 1rem .75rem .35rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .53rem .75rem;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    font-size: .845rem;
    font-weight: 500;
    margin-bottom: 1px;
    white-space: nowrap;
    transition: background .12s, color .12s;
}
.sidebar-nav .nav-link i { font-size: 1.02rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .05); color: #e2e8f0; }
.sidebar-nav .nav-link.active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 3px 10px rgba(var(--brand-rgb), .35);
}
.sidebar-nav .nav-link .badge { margin-left: auto; font-size: .66rem; }

/* Collapsible groups */
.nav-group > .nav-link .chev { margin-left: auto; font-size: .72rem; transition: transform .18s; }
.nav-group > .nav-link[aria-expanded="true"] .chev { transform: rotate(90deg); }
.nav-group .submenu { padding-left: 2.35rem; }
.nav-group .submenu .nav-link { padding: .4rem .7rem; font-size: .81rem; }
.nav-group .submenu .nav-link.active { background: rgba(var(--brand-rgb), .18); color: #fff; box-shadow: none; }

/* Collapsed rail */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .nav-link span,
body.sidebar-collapsed .sidebar .nav-section,
body.sidebar-collapsed .sidebar .chev,
body.sidebar-collapsed .sidebar .submenu { display: none; }
body.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding: .6rem; }
body.sidebar-collapsed .main-area { margin-left: var(--sidebar-w-collapsed); }

.main-area {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .18s ease;
}

/* ------------------------------------------------------------------ Topbar */

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--ink-200);
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar .page-title { font-size: 1rem; font-weight: 650; color: var(--ink-900); margin: 0; line-height: 1.2; }
.topbar .page-sub { font-size: .74rem; color: var(--ink-400); }

.icon-btn {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-500);
    transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--ink-100); color: var(--ink-900); }

.shop-switch {
    display: flex; align-items: center; gap: .55rem;
    padding: .34rem .7rem .34rem .5rem;
    border: 1px solid var(--ink-200);
    border-radius: 999px;
    background: #fff;
    font-size: .8rem;
    color: var(--ink-700);
    font-weight: 500;
}
.shop-switch:hover { border-color: var(--brand); color: var(--brand); }
.shop-switch .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }

/* The account menu is a button for accessibility, but must not read as a link. */
.topbar .btn-link,
.topbar .btn-link:hover,
.topbar .btn-link:focus {
    text-decoration: none;
    color: inherit;
    box-shadow: none;
}

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-size: .78rem; font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: .68rem; }
.avatar.lg { width: 68px; height: 68px; font-size: 1.4rem; }

.page-body { padding: 1.35rem; flex: 1; }

/* ------------------------------------------------------------------- Cards */

.card {
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    background: #fff;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--ink-200);
    padding: .85rem 1.15rem;
    font-weight: 600;
    color: var(--ink-900);
    display: flex;
    align-items: center;
    gap: .6rem;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-header .card-title { margin: 0; font-size: .92rem; font-weight: 650; }
.card-header .card-sub { font-size: .74rem; color: var(--ink-400); font-weight: 400; }
.card-body { padding: 1.15rem; }
.card-footer { background: var(--ink-50); border-top: 1px solid var(--ink-200); padding: .75rem 1.15rem; }

/* --------------------------------------------------------------- Stat tile */

.stat {
    background: #fff;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    padding: 1.05rem 1.15rem;
    box-shadow: var(--shadow-xs);
    height: 100%;
    position: relative;
    overflow: hidden;
}
.stat::after {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--tile, var(--brand));
    opacity: .85;
}
.stat-label {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-400); font-weight: 600; margin-bottom: .4rem;
}
.stat-value { font-size: 1.45rem; font-weight: 700; color: var(--ink-900); line-height: 1.15; letter-spacing: -.02em; }
.stat-meta { font-size: .75rem; color: var(--ink-500); margin-top: .3rem; }
.stat-icon {
    position: absolute; top: 1rem; right: 1rem;
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center;
    font-size: 1.05rem;
    background: var(--tile-soft, var(--brand-soft));
    color: var(--tile, var(--brand));
}

/* Compact secondary tiles: keep the label on one line so a row of six stays
   evenly aligned however narrow each column gets. */
.mini-tile-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .045em;
    font-weight: 650;
    color: var(--ink-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.mini-tile-value {
    font-weight: 700;
    color: var(--ink-900);
    font-size: 1.02rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mini-tile:hover .mini-tile-value { color: var(--brand); }

.trend { font-size: .74rem; font-weight: 600; display: inline-flex; align-items: center; gap: .2rem; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--bad); }
.trend.flat { color: var(--ink-400); }

/* ------------------------------------------------------------------ Tables */

.table { --bs-table-bg: transparent; margin-bottom: 0; color: var(--ink-700); }
.table > :not(caption) > * > * { padding: .68rem .9rem; }
.table thead th {
    background: var(--ink-50);
    border-bottom: 1px solid var(--ink-200);
    font-size: .71rem;
    text-transform: uppercase;
    letter-spacing: .055em;
    color: var(--ink-500);
    font-weight: 650;
    white-space: nowrap;
}
.table tbody td { border-bottom: 1px solid var(--ink-100); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover { background: var(--ink-50); }
.table tfoot td { background: var(--ink-50); font-weight: 650; color: var(--ink-900); border-top: 2px solid var(--ink-200); }

.table-compact > :not(caption) > * > * { padding: .48rem .7rem; font-size: .82rem; }

.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: .82em; }

/* ------------------------------------------------------------------ Badges */

.badge { font-weight: 600; font-size: .7rem; padding: .32em .6em; border-radius: 6px; letter-spacing: .01em; }
.badge.soft-success { background: var(--ok-soft); color: var(--ok); }
.badge.soft-warning { background: var(--warn-soft); color: var(--warn); }
.badge.soft-danger { background: var(--bad-soft); color: var(--bad); }
.badge.soft-primary { background: var(--brand-soft); color: var(--brand); }
.badge.soft-info { background: rgba(8, 145, 178, .1); color: var(--info); }
.badge.soft-secondary { background: var(--ink-100); color: var(--ink-500); }

/* ------------------------------------------------------------------- Forms */

.form-label { font-size: .78rem; font-weight: 600; color: var(--ink-700); margin-bottom: .3rem; }
.form-control, .form-select {
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-sm);
    font-size: .855rem;
    padding: .46rem .7rem;
    color: var(--ink-900);
    background-color: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-control::placeholder { color: var(--ink-400); }
.form-control-sm, .form-select-sm { padding: .3rem .55rem; font-size: .8rem; }
.form-text { font-size: .74rem; color: var(--ink-400); }
.input-group-text { background: var(--ink-50); border-color: var(--ink-200); font-size: .82rem; color: var(--ink-500); }

.form-switch .form-check-input { width: 2.35em; height: 1.2em; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* ----------------------------------------------------------------- Buttons */

.btn {
    font-size: .845rem;
    font-weight: 550;
    border-radius: var(--radius-sm);
    padding: .46rem .9rem;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    transition: all .12s;
}
.btn-sm { padding: .3rem .65rem; font-size: .79rem; }
.btn-lg { padding: .65rem 1.3rem; font-size: .95rem; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-light { background: #fff; border-color: var(--ink-200); color: var(--ink-700); }
.btn-light:hover { background: var(--ink-50); border-color: var(--ink-400); color: var(--ink-900); }
.btn-soft { background: var(--brand-soft); color: var(--brand); border: 1px solid transparent; }
.btn-soft:hover { background: var(--brand); color: #fff; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }

/* ------------------------------------------------------------ Page toolbar */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1.15rem;
}
.toolbar .spacer { flex: 1; }

.filter-card { background: #fff; border: 1px solid var(--ink-200); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1.15rem; }
.filter-card .row { --bs-gutter-y: .6rem; }

.segmented {
    display: inline-flex;
    background: var(--ink-100);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }

.segmented a {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    padding: .42rem .85rem;
    border-radius: 6px;
    font-size: .81rem;
    font-weight: 550;
    color: var(--ink-500);
    white-space: nowrap;
    transition: background .12s, color .12s;
}
.segmented a:hover { color: var(--ink-900); }
.segmented a.active {
    background: #fff;
    color: var(--ink-900);
    font-weight: 600;
    box-shadow: var(--shadow-xs);
}
.segmented a.active i { color: var(--brand); }

/* ------------------------------------------------------------- Empty state */

.empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--ink-400);
}

/* Direct child only — otherwise this would blow up icons inside the
   call-to-action button that empty states often carry. */
.empty > i { font-size: 2.6rem; opacity: .35; display: block; margin-bottom: .75rem; }

.empty h6 { color: var(--ink-700); font-weight: 600; margin-bottom: .25rem; }
.empty p { font-size: .84rem; margin-bottom: 1rem; }

/* Actions sit on one centred row and keep normal button sizing. */
.empty .btn,
.empty form { display: inline-flex; }
.empty form { margin: 0 .2rem; }
.empty .btn i {
    font-size: inherit;
    display: inline-block;
    opacity: 1;
    margin: 0;
}

/* -------------------------------------------------------------- Pagination */

.pagination { margin: 0; gap: 3px; }
.page-link {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--ink-200);
    color: var(--ink-700);
    font-size: .82rem;
    padding: .34rem .65rem;
}
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.page-item.disabled .page-link { color: var(--ink-400); }

/* ------------------------------------------------------------------ Alerts */

.alert { border: 0; border-radius: var(--radius); font-size: .855rem; padding: .8rem 1rem; border-left: 3px solid; }
.alert-success { background: var(--ok-soft); color: #065f46; border-color: var(--ok); }
.alert-danger { background: var(--bad-soft); color: #991b1b; border-color: var(--bad); }
.alert-warning { background: var(--warn-soft); color: #92400e; border-color: var(--warn); }
.alert-info { background: rgba(8, 145, 178, .1); color: #155e75; border-color: var(--info); }

/* ------------------------------------------------------------------ Modals */

.modal-content { border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--ink-200); padding: 1rem 1.25rem; }
.modal-title { font-size: 1rem; font-weight: 650; }
.modal-body { padding: 1.25rem; }
.modal-footer { border-top: 1px solid var(--ink-200); padding: .85rem 1.25rem; }

.dropdown-menu {
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: .85rem;
    padding: .35rem;
}
.dropdown-item { border-radius: 6px; padding: .45rem .7rem; display: flex; align-items: center; gap: .55rem; }
.dropdown-item:active { background: var(--brand); }
.dropdown-header { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400); font-weight: 650; }

/* -------------------------------------------------------------- Line items */

.line-table { border: 1px solid var(--ink-200); border-radius: var(--radius); overflow: hidden; }
.line-table .table thead th { background: var(--ink-50); }
.line-table input.form-control, .line-table select.form-select {
    border: 1px solid transparent;
    background: transparent;
    padding: .25rem .4rem;
    font-size: .84rem;
}
.line-table input.form-control:hover, .line-table select.form-select:hover { border-color: var(--ink-200); background: #fff; }
.line-table input.form-control:focus { background: #fff; }

.totals-row { display: flex; justify-content: space-between; padding: .38rem 0; font-size: .855rem; }
.totals-row.grand {
    border-top: 2px solid var(--ink-200);
    margin-top: .5rem;
    padding-top: .7rem;
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--ink-900);
}

/* --------------------------------------------------------------- Typeahead */

.typeahead-wrap { position: relative; }
.typeahead-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1055;
    display: none;
}
.typeahead-results.show { display: block; }
.typeahead-item {
    padding: .55rem .8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .7rem;
    border-bottom: 1px solid var(--ink-100);
}
.typeahead-item:last-child { border-bottom: 0; }
.typeahead-item:hover, .typeahead-item.active { background: var(--brand-soft); }
.typeahead-item .ta-name { font-weight: 550; color: var(--ink-900); font-size: .85rem; }
.typeahead-item .ta-meta { font-size: .74rem; color: var(--ink-400); }

/* ------------------------------------------------------------------ Charts */

.chart-box { position: relative; width: 100%; }
.chart-box canvas { max-width: 100%; }

/* --------------------------------------------------------------- Utilities */

.text-muted-2 { color: var(--ink-400) !important; }
.fs-xs { font-size: .74rem; }
.fs-sm { font-size: .82rem; }
.fw-550 { font-weight: 550; }
.fw-650 { font-weight: 650; }
.divider-y { border-left: 1px solid var(--ink-200); height: 24px; }
.cursor-pointer { cursor: pointer; }
.hover-lift { transition: transform .15s, box-shadow .15s; }
.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.sticky-actions { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--ink-200); padding: .85rem 1.15rem; z-index: 10; border-radius: 0 0 var(--radius) var(--radius); }
.scroll-y { overflow-y: auto; }

.progress-thin { height: 5px; border-radius: 3px; background: var(--ink-100); }
.progress-thin .progress-bar { border-radius: 3px; }

/* ------------------------------------------------------------------ Mobile */

.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 1035;
    display: none;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main-area { margin-left: 0 !important; }
    .page-body { padding: 1rem .85rem; }
    .topbar { padding: 0 .85rem; }
}

/* ------------------------------------------------------------------- Print */

@media print {
    .sidebar, .topbar, .no-print, .sidebar-backdrop { display: none !important; }
    .main-area { margin-left: 0 !important; }
    .page-body { padding: 0; }
    body { background: #fff; font-size: 12px; }
    .card { border: 0; box-shadow: none; }
    a[href]:after { content: none !important; }
}
