/* =========================================================
   Warung Kasir — Stylesheet
   Palet: hangat, terinspirasi warung makan pinggir jalan
   ========================================================= */

:root {
    --clay: #C2542D;         /* aksen utama - terracotta/gorengan */
    --clay-dark: #A6431F;
    --clay-light: #F0DCC9;
    --charcoal: #2B241E;     /* teks utama, gelap kehangatan arang */
    --charcoal-soft: #5B4F44;
    --cream: #FFF8EF;        /* background utama */
    --paper: #FFFFFF;
    --line: #E7DCCB;
    --green-ok: #3F7A4C;
    --red-danger: #B23A2E;
    --amber-warn: #C98A1B;

    --radius: 10px;
    --shadow: 0 2px 10px rgba(43, 36, 30, 0.08);
    --font-display: 'Fraunces', 'Georgia', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--cream);
    color: var(--charcoal);
    font-family: var(--font-body);
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

button {
    font-family: inherit;
    cursor: pointer;
}

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

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--charcoal);
    color: #F2E9DD;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
}

.sidebar-brand {
    padding: 0 20px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 12px;
}

.sidebar-brand .logo-mark {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--clay-light);
    line-height: 1.1;
}

.sidebar-brand .logo-sub {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #B9AA97;
    margin-top: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: #D9CCB9;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.15s ease;
}

.nav-item:hover { background: rgba(255,255,255,0.05); }

.nav-item.active {
    background: rgba(194, 84, 45, 0.18);
    color: #fff;
    border-left-color: var(--clay);
}

.nav-icon { font-size: 17px; width: 20px; text-align: center; }

.sidebar-footer {
    margin-top: auto;
    padding: 12px 20px 0 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .user-name {
    font-size: 13px;
    color: #EFE4D4;
    font-weight: 600;
}
.sidebar-footer .logout-link {
    font-size: 12.5px;
    color: #C98A6A;
    display: inline-block;
    margin-top: 6px;
}

.main {
    margin-left: 220px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar h1 {
    font-family: var(--font-display);
    font-size: 20px;
    margin: 0;
    font-weight: 600;
}

.topbar .topbar-sub {
    font-size: 12.5px;
    color: var(--charcoal-soft);
    margin-top: 2px;
}

.content { padding: 22px 24px 60px 24px; flex: 1; }

/* Mobile: bottom nav instead of sidebar */
.bottom-nav {
    display: none;
}

@media (max-width: 860px) {
    .sidebar { display: none; }
    .main { margin-left: 0; }
    .content { padding: 16px 14px 90px 14px; }
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: var(--charcoal);
        z-index: 50;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
        justify-content: space-around;
    }
    .bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        color: #B9AA97;
        font-size: 10.5px;
        padding: 6px 4px;
        flex: 1;
    }
    .bottom-nav a.active { color: var(--clay-light); }
    .bottom-nav .nav-icon { font-size: 19px; }
}

/* ---------- Cards / Panels ---------- */
.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-pad { padding: 20px; }

.grid-2 {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 18px;
}
@media (max-width: 860px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--clay); color: #fff; }
.btn-primary:hover { background: var(--clay-dark); }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--line);
    color: var(--charcoal);
}
.btn-outline:hover { border-color: var(--clay); color: var(--clay-dark); }

.btn-danger { background: var(--red-danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--charcoal-soft); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--charcoal-soft);
}

input[type=text], input[type=number], input[type=password], input[type=date], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    background: var(--paper);
    color: var(--charcoal);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--clay);
    box-shadow: 0 0 0 3px rgba(194,84,45,0.12);
}

.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 10px 12px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--line);
}
th {
    color: var(--charcoal-soft);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
    font-weight: 700;
}
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
}
.badge-ok { background: #E4F1E6; color: var(--green-ok); }
.badge-warn { background: #FBEDD3; color: var(--amber-warn); }
.badge-danger { background: #F7E1DD; color: var(--red-danger); }

/* ---------- Kasir page specific ---------- */
.kasir-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 18px;
    align-items: start;
}
@media (max-width: 1050px) {
    .kasir-layout { grid-template-columns: 1fr; }
}

.search-bar { margin-bottom: 14px; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.product-card {
    background: var(--paper);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: border-color 0.12s ease, transform 0.08s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.product-card:hover { border-color: var(--clay); }
.product-card:active { transform: scale(0.97); }
.product-card.out-of-stock {
    opacity: 0.45;
    cursor: not-allowed;
}
.product-card .p-kategori {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--charcoal-soft);
}
.product-card .p-nama {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.25;
}
.product-card .p-harga {
    color: var(--clay-dark);
    font-weight: 700;
    font-size: 13.5px;
}
.product-card .p-stok {
    font-size: 11.5px;
    color: var(--charcoal-soft);
}

.cart-panel {
    position: sticky;
    top: 78px;
}

.cart-items { max-height: 340px; overflow-y: auto; margin: 12px 0; }

.cart-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}
.cart-row:last-child { border-bottom: none; }
.cart-row .ci-name { flex: 1; font-size: 13.5px; font-weight: 600; }
.cart-row .ci-price { font-size: 11.5px; color: var(--charcoal-soft); }

.qty-control {
    display: flex;
    align-items: center;
    gap: 6px;
}
.qty-control button {
    width: 24px; height: 24px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--paper);
    font-weight: 700;
    line-height: 1;
}
.qty-control span { min-width: 18px; text-align: center; font-weight: 700; font-size: 13px; }

.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 2px solid var(--charcoal);
    font-weight: 700;
    font-size: 17px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--charcoal-soft);
}
.empty-state .empty-emoji { font-size: 32px; margin-bottom: 8px; }

/* ---------- Stat cards (rekap) ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
@media (max-width: 700px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 12px; color: var(--charcoal-soft); font-weight: 600; }
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    color: var(--clay-dark);
    margin-top: 4px;
}

.tab-group {
    display: inline-flex;
    background: var(--clay-light);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 16px;
}
.tab-group button {
    border: none;
    background: transparent;
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--clay-dark);
}
.tab-group button.active { background: var(--clay); color: #fff; }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--charcoal) 0%, #3a2f26 60%, var(--clay-dark) 130%);
    padding: 20px;
}
.login-card {
    background: var(--cream);
    border-radius: 16px;
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-card .logo-mark {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 600;
    color: var(--clay-dark);
    text-align: center;
}
.login-card .logo-sub {
    text-align: center;
    font-size: 12.5px;
    color: var(--charcoal-soft);
    margin-bottom: 24px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.login-error {
    background: #F7E1DD;
    color: var(--red-danger);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
}

/* ---------- Toast ---------- */
#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--charcoal);
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 999;
    max-width: 90vw;
    text-align: center;
}
#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#toast.error { background: var(--red-danger); }
#toast.success { background: var(--green-ok); }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(43,36,30,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal-backdrop.show { display: flex; }
.modal-box {
    background: var(--paper);
    border-radius: 14px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}
.modal-box h2 {
    font-family: var(--font-display);
    font-size: 19px;
    margin: 0 0 16px 0;
}
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}
.modal-actions .btn { flex: 1; }

.text-muted { color: var(--charcoal-soft); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-wrap-gap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
