/* ─── Design Tokens ─────────────────────────────────── */
:root {
    --cream:       #FAF7F2;
    --cream-dark:  #F0EAE0;
    --brown-100:   #EDE0CE;
    --brown-300:   #C4A882;
    --brown-500:   #9E7B50;
    --brown-700:   #6B4F2E;
    --brown-900:   #3D2B1A;
    --green-soft:  #5A7A5C;
    --green-pale:  #EDF4EE;
    --red-soft:    #C0392B;
    --red-pale:    #FDECEA;
    --amber:       #E8943A;
    --amber-pale:  #FEF3E7;
    --text:        #2C1F0F;
    --text-muted:  #8A7060;
    --border:      #E2D5C3;
    --white:       #FFFFFF;
    --shadow-sm:   0 1px 3px rgba(60,30,10,.08);
    --shadow-md:   0 4px 16px rgba(60,30,10,.10);
    --radius:      10px;
    --radius-lg:   16px;
}

/* ─── Reset & Base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: 'Inter', sans-serif;
    background: var(--cream);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--brown-700); text-decoration: none; }
a:hover { color: var(--brown-500); }

/* ─── Navbar ─────────────────────────────────────────── */
.navbar {
    background: var(--brown-900);
    color: var(--cream);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.brand-icon { font-size: 1.6rem; line-height: 1; }
.brand-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--brown-300);
    line-height: 1.2;
}
.brand-sub {
    font-size: .65rem;
    color: var(--brown-300);
    opacity: .6;
    text-transform: uppercase;
    letter-spacing: .1em;
}
.nav-links {
    display: flex;
    gap: .25rem;
}
.nav-links a {
    color: rgba(255,255,255,.7);
    padding: .45rem .9rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: .4rem;
    transition: background .15s, color .15s;
}
.nav-links a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-links a.active { background: var(--brown-700); color: var(--cream); }
.badge {
    background: var(--amber);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}

/* ─── Layout ─────────────────────────────────────────── */
.container {
    /* max-width: 1200px;
    margin: 0 auto; */
    padding: 2rem 1.5rem;
    flex: 1;
}
.page-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--brown-900);
    margin-bottom: 1.5rem;
}
.footer {
    text-align: center;
    padding: 1rem;
    font-size: .8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ─── Alert ──────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    font-weight: 500;
}
.alert-success { background: var(--green-pale); color: var(--green-soft); border: 1px solid #c3ddc4; }
.alert-error   { background: var(--red-pale);   color: var(--red-soft);   border: 1px solid #f0c4c0; }

/* ─── Card ───────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.5rem;
}
.card-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--brown-900);
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border);
}

/* ─── Kasir Layout ───────────────────────────────────── */
.kasir-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    align-items: start;
}
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 2fr));
    gap: .75rem;
}
.product-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .1s;
    text-align: center;
    user-select: none;
}
.product-card:hover {
    border-color: var(--brown-300);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.product-card:active { transform: translateY(0); }
.product-card.out-of-stock {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}
.product-emoji { font-size: 2.2rem; margin-bottom: .5rem; }
.product-name { font-weight: 600; font-size: .9rem; color: var(--brown-900); }
.product-price { font-size: .8rem; color: var(--brown-500); margin-top: .25rem; }
.product-stock { font-size: .7rem; color: var(--text-muted); margin-top: .15rem; }

/* ─── Cart ───────────────────────────────────────────── */
.cart-sticky { position: sticky; top: 80px; }
.cart-items { list-style: none; margin-bottom: 1rem; }
.cart-items li {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--cream-dark);
    font-size: .875rem;
}
.cart-items li:last-child { border-bottom: none; }
.cart-item-name { flex: 1; font-weight: 500; color: var(--brown-900); }
.cart-item-price { color: var(--text-muted); font-size: .8rem; }
.qty-btn {
    width: 26px; height: 26px;
    border: 1px solid var(--border);
    background: var(--cream);
    border-radius: 6px;
    cursor: pointer;
    font-size: .9rem;
    display: flex; align-items: center; justify-content: center;
    transition: background .1s;
    color: var(--brown-700);
}
.qty-btn:hover { background: var(--brown-100); }
.qty-num { font-size: .85rem; font-weight: 600; min-width: 20px; text-align: center; }
.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .75rem 0;
    border-top: 2px solid var(--brown-900);
    margin-top: .5rem;
}
.cart-total-label { font-weight: 600; }
.cart-total-amount {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--brown-900);
}
.cart-empty { text-align: center; color: var(--text-muted); padding: 2rem 0; font-size: .875rem; }

/* ─── Form ───────────────────────────────────────────── */
.form-group { margin-bottom: .85rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--brown-700); margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .05em; }
.form-control {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: 'Inter', sans-serif;
    background: var(--white);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--brown-300); box-shadow: 0 0 0 3px rgba(158,123,80,.12); }
.form-control-sm { padding: .4rem .7rem; font-size: .8rem; }
textarea.form-control { resize: vertical; min-height: 60px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-check { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.form-check input { width: auto; }
.form-check label { font-size: .875rem; font-weight: 500; }

/* ─── Buttons ────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1.25rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    transition: all .15s;
    white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brown-900); color: #fff; }
.btn-primary:hover { background: var(--brown-700); }
.btn-amber { background: var(--amber); color: #fff; }
.btn-amber:hover { background: #d4831e; }
.btn-green { background: var(--green-soft); color: #fff; }
.btn-green:hover { background: #4a6a4c; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--brown-300); background: var(--cream); }
.btn-danger { background: var(--red-pale); color: var(--red-soft); border: 1px solid #f0c4c0; }
.btn-danger:hover { background: #fbd9d7; }
.btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.btn-block { width: 100%; }

/* ─── Table ──────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
    text-align: left;
    padding: .6rem 1rem;
    background: var(--cream-dark);
    color: var(--brown-700);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border);
}
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--cream-dark); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--cream); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ─── Badges / Status ────────────────────────────────── */
.pill {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.pill-pending   { background: var(--amber-pale); color: #b36200; }
.pill-process   { background: #EEF2FF; color: #3730A3; }
.pill-done      { background: var(--green-pale); color: var(--green-soft); }
.pill-cancelled { background: var(--red-pale); color: var(--red-soft); }
.pill-paid      { background: var(--green-pale); color: var(--green-soft); }
.pill-unpaid    { background: var(--red-pale); color: var(--red-soft); }

/* ─── Stats bar ──────────────────────────────────────── */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon { font-size: 2rem; opacity: .8; }
.stat-value { font-family: 'Playfair Display', serif; font-size: 1.5rem; font-weight: 600; line-height: 1; color: var(--brown-900); }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; text-transform: uppercase; letter-spacing: .05em; }

/* ─── Preorder highlight ─────────────────────────────── */
.preorder-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
    transition: box-shadow .15s;
}
.preorder-card:hover { box-shadow: var(--shadow-md); }
.preorder-card.urgent { border-left: 4px solid var(--amber); }
.preorder-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .75rem; }
.preorder-meta { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
.preorder-items { font-size: .83rem; color: var(--brown-700); margin-bottom: .75rem; }
.preorder-items span { background: var(--cream-dark); padding: .15rem .5rem; border-radius: 5px; margin-right: .3rem; display: inline-block; margin-bottom: .2rem; }
.preorder-footer { display: flex; justify-content: space-between; align-items: center; padding-top: .75rem; border-top: 1px solid var(--border); }
.preorder-actions { display: flex; gap: .5rem; }

/* ─── Modal ──────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(30,15,5,.5);
    backdrop-filter: blur(2px);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    padding: 1.25rem 1.5rem .75rem;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-title { font-family: 'Playfair Display', serif; font-size: 1.15rem; font-weight: 600; }
.modal-close { cursor: pointer; font-size: 1.4rem; color: var(--text-muted); line-height: 1; background: none; border: none; }
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer { padding: .75rem 1.5rem 1.25rem; display: flex; gap: .75rem; justify-content: flex-end; border-top: 1px solid var(--border); }

/* ─── Misc ───────────────────────────────────────────── */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .8rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.fw-bold { font-weight: 700; }
.hidden { display: none !important; }

@media (max-width: 768px) {
    .navbar {
        padding: .5rem 1rem;
        height: auto;
        align-items: center;
        gap: .5rem;
        flex-wrap: wrap;
    }
    .nav-brand { gap: .5rem; }
    .brand-icon { font-size: 1.4rem; }
    .brand-name { font-size: 1rem; }
    .brand-sub { display: none; }
    .nav-links {
        order: 2;
        width: 100%;
        display: flex;
        justify-content: center;
        gap: .5rem;
        padding: .5rem 0;
        flex-wrap: wrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .nav-links a {
        padding: .45rem .7rem;
        font-size: .85rem;
    }

    .kasir-grid { grid-template-columns: 1fr; }
    .stats-bar { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .nav-links a span:not(.badge) { display: none; }

    .preorder-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .preorder-footer > div:first-child {
        width: 100%;
        text-align: left;
    }
    .preorder-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: .4rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .preorder-actions form,
    .preorder-actions a {
        flex: 0 1 auto;
        min-width: fit-content;
    }
    .btn-sm { padding: .35rem .6rem; font-size: .75rem; }
}
