/* =========================================================
   PipAlgo POS — Design tokens
   Palette: indigo-blue primary, deep navy sidebar, sky accent
   Type: Inter throughout, weight carries hierarchy
   ========================================================= */
:root {
    --brand: #1656e8;          /* primary actions, links, focus */
    --brand-dark: #0e3fb0;     /* hover/pressed state of primary */
    --brand-light: #eaf1ff;    /* tint backgrounds, chips */
    --navy: #0b1b3a;           /* sidebar base */
    --navy-soft: #142a54;      /* sidebar hover */
    --sky: #3fa6ff;            /* active accent on dark navy */
    --ink: #0f1b33;            /* primary text */
    --slate: #64748b;          /* secondary text */
    --line: #e4eaf5;           /* hairline borders */
    --bg: #f4f7fc;             /* page background */
    --sidebar-w: 252px;
    --topbar-h: 64px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 2px rgba(15, 27, 51, .04), 0 8px 24px -12px rgba(22, 86, 232, .10);
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
}

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--navy) 0%, #0a1730 100%);
    color: #fff;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    padding: 22px 22px 18px;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 11px;
}

.sidebar .brand i {
    width: 34px; height: 34px; border-radius: 9px;
    background: rgba(63, 166, 255, .18);
    color: var(--sky);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.68);
    padding: 10px 12px;
    margin-bottom: 2px;
    text-decoration: none;
    font-size: .89rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease;
}

.sidebar-nav a:hover { background: var(--navy-soft); color: #fff; }
.sidebar-nav a.active {
    background: var(--navy-soft);
    color: #fff;
    border-left-color: var(--sky);
    font-weight: 600;
}
.sidebar-nav a.active .nav-icon { color: var(--sky); }

.sidebar-nav .nav-icon { width: 18px; text-align: center; font-size: .95rem; }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    transition: margin-left .25s ease;
}

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar h5 { font-weight: 700; letter-spacing: -0.01em; }

.page-body { padding: 24px; }

.app-footer {
    padding: 16px 24px;
    text-align: center;
    font-size: .78rem;
    color: var(--slate);
    border-top: 1px solid var(--line);
    background: #fff;
}

.menu-toggle {
    display: none;
    border: none;
    background: none;
    font-size: 1.3rem;
    color: var(--navy);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11, 27, 58, .45);
    z-index: 1035;
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: inline-block; }
    .sidebar-backdrop.show { display: block; }
}

/* ---------- Cards / widgets ---------- */
.stat-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--line);
    border-top: 3px solid var(--brand);
    height: 100%;
}

.stat-card .stat-label { font-size: .78rem; color: var(--slate); font-weight: 500; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; color: var(--ink); margin-top: 4px; letter-spacing: -0.02em; }
.stat-card .stat-icon {
    width: 42px; height: 42px; border-radius: 11px;
    background: var(--brand-light); color: var(--brand);
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}

.card { border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 700; border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important; }

.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-brand:disabled { background: #a9c0f5; border-color: #a9c0f5; }
.btn-outline-brand { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.btn, .form-control, .form-select { border-radius: var(--radius-sm); }

.table thead th { font-size: .76rem; font-weight: 600; color: var(--slate); border-bottom-width: 1px; border-color: var(--line); }
.table td { border-color: var(--line); }

.badge-low { background: #fff3cd; color: #92600a; }
.badge-out { background: #fde2e2; color: #b3261e; }

/* ---------- POS screen ---------- */
.pos-wrapper { display: flex; gap: 18px; align-items: flex-start; }

.pos-products { flex: 1 1 60%; min-width: 0; }

.pos-cart {
    flex: 1 1 38%;
    max-width: 420px;
    position: sticky;
    top: calc(var(--topbar-h) + 18px);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    max-height: calc(100vh - 230px);
    overflow-y: auto;
    padding: 4px 4px 20px;
}

.product-tile {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 14px 12px;
    text-align: center;
    cursor: pointer;
    transition: box-shadow .15s ease, transform .1s ease, border-color .15s ease;
}

.product-tile:hover { box-shadow: 0 10px 24px -10px rgba(22, 86, 232, .28); transform: translateY(-2px); border-color: #cbdcfb; }
.product-tile:active { transform: translateY(0); }
.product-tile .p-name { font-weight: 600; font-size: .85rem; margin-top: 8px; line-height: 1.25; min-height: 2.4em; color: var(--ink); }
.product-tile .p-price { color: var(--brand); font-weight: 700; font-size: .87rem; margin-top: 4px; }
.product-tile .p-stock { font-size: .7rem; color: #9aa5b5; }
.product-tile .p-thumb {
    width: 100%; aspect-ratio: 1/1; border-radius: var(--radius-sm);
    background: var(--brand-light);
    display: flex; align-items: center; justify-content: center; color: var(--brand); font-size: 1.4rem;
}

.cart-panel { background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: var(--shadow-card); display: flex; flex-direction: column; max-height: calc(100vh - 100px); overflow: hidden; }
.cart-panel > .p-3.border-bottom:first-child { background: var(--navy); color: #fff; border-bottom: none !important; }
.cart-panel > .p-3.border-bottom:first-child .btn-outline-danger { color: #ffd1d1; border-color: rgba(255,255,255,.3); }
.cart-panel > .p-3.border-bottom:first-child .btn-outline-danger:hover { background: rgba(255,255,255,.1); }

.cart-items { flex: 1; overflow-y: auto; max-height: 340px; }
.cart-line { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid #f0f3f9; }
.cart-line .ci-name { font-weight: 600; font-size: .85rem; color: var(--ink); }
.cart-line .ci-price { font-size: .75rem; color: var(--slate); }

.qty-control { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); }
.qty-control button { border: none; background: transparent; width: 26px; height: 26px; font-weight: 700; color: var(--brand); }
.qty-control button:hover { background: var(--brand-light); }
.qty-control input { width: 34px; border: none; background: transparent; text-align: center; font-size: .82rem; font-weight: 600; }

.cart-summary { padding: 16px 18px; border-top: 1px solid var(--line); background: #fbfcfe; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.cart-summary .row-line { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 6px; color: var(--slate); }
.cart-summary .row-total { font-size: 1.25rem; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }

.payment-tabs .btn { flex: 1; border-radius: 999px; font-weight: 600; }

@media (max-width: 991.98px) {
    .pos-wrapper { flex-direction: column; }
    .pos-cart { max-width: 100%; position: static; }
    .product-grid { max-height: none; }
}

/* ---------- Auth ---------- */
.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(1200px 600px at 15% -10%, rgba(63,166,255,.25), transparent 60%),
        radial-gradient(1000px 500px at 110% 110%, rgba(22,86,232,.35), transparent 60%),
        linear-gradient(160deg, var(--navy), #0a1730);
}

.auth-shell-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card { background: #fff; border-radius: var(--radius-lg); padding: 38px 34px; width: 100%; max-width: 380px; box-shadow: 0 24px 60px -20px rgba(11, 27, 58, .45); }
.auth-card .form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--brand-light); }

/* ---------- Print (receipt) ---------- */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .receipt-box { box-shadow: none !important; border: none !important; width: 100% !important; }
}