/* ==================================================================
   style.css — gaya mandiri (tanpa CDN) agar tetap ringan di shared
   hosting dan tidak bergantung pada koneksi internet pengunjung.
   ================================================================== */

:root {
    --primary: #b45309;      /* cokelat oranye (warung/rempah) */
    --primary-dark: #92400e;
    --bg: #faf7f2;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --success: #15803d;
    --success-bg: #dcfce7;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --warning: #92400e;
    --warning-bg: #fef3c7;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ---------- Layout: Sidebar kiri + area konten ---------- */
.layout {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--primary);
    color: #fff;
    padding: 18px 14px;
    box-shadow: 2px 0 6px rgba(0, 0, 0, .12);
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.3;
    text-decoration: none;
    display: block;
}
.menu { display: flex; flex-direction: column; gap: 4px; }
.menu a {
    color: #ffe8cc;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: .92rem;
}
.menu a:hover { background: var(--primary-dark); color: #fff; }
.menu a.active { background: #fff; color: var(--primary-dark); font-weight: 600; }
.menu a.logout { color: #ffd9d9; margin-top: auto; }

/* ---------- Area konten utama ---------- */
.main-area {
    flex: 1;
    min-width: 0;            /* cegah tabel lebar merusak layout */
    display: flex;
    flex-direction: column;
}
.container {
    width: 100%;
    max-width: 1080px;
    margin: 24px auto;
    padding: 0 16px;
    flex: 1;
}
.footer {
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
    padding: 24px 16px;
}

/* Tabel lebar dapat digulir horizontal di area sempit */
.card { overflow-x: auto; }

/* Elemen khusus mobile — disembunyikan di desktop */
.mobile-bar { display: none; }
.overlay { display: none; }

/* ---------- Responsif: layar HP (drawer menu dari kiri) ---------- */
@media (max-width: 768px) {
    /* Sidebar menjadi laci (drawer) yang muncul dari kiri */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 250px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform .25s ease;
        overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); }

    /* Lapisan gelap di belakang drawer saat terbuka */
    .overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        z-index: 900;
    }

    /* Bar atas berisi tombol hamburger + nama aplikasi */
    .mobile-bar {
        display: flex;
        align-items: center;
        gap: 12px;
        background: var(--primary);
        color: #fff;
        padding: 10px 14px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
    }
    .hamburger {
        width: auto;
        background: transparent;
        border: none;
        color: #fff;
        font-size: 1.5rem;
        line-height: 1;
        padding: 2px 6px;
        cursor: pointer;
    }
    .mobile-brand {
        color: #fff;
        font-weight: 700;
        font-size: 1rem;
        text-decoration: none;
    }

    .container { margin: 16px auto; padding: 0 12px; }
    .page-head h1 { font-size: 1.2rem; }
    .page-head .btn { width: 100%; text-align: center; }
}

/* ---------- Judul halaman ---------- */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}
.page-head h1 { font-size: 1.4rem; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

/* ---------- Kartu ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}
.card h2 { font-size: 1.05rem; margin: 0 0 14px; }

/* ---------- Kartu statistik ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 16px;
}
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }

/* ---------- Tabel ---------- */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f9fafb; color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: #fafafa; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

/* ---------- Tombol ---------- */
.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { background: var(--primary-dark); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #991b1b; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #166534; }

/* ---------- Form ---------- */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 5px; }
input, select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .95rem;
    font-family: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(180, 83, 9, .12);
}
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }

/* ---------- Alert / flash ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: .92rem; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }

/* ---------- Badge ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-info { background: #dbeafe; color: #1d4ed8; }

/* ---------- Halaman login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 30px; width: 100%; max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.login-box h1 { text-align: center; font-size: 1.3rem; margin: 0 0 6px; }
.login-box .sub { text-align: center; color: var(--muted); font-size: .88rem; margin-bottom: 20px; }

/* ---------- Item baris transaksi (dinamis) ---------- */
.item-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-row select { flex: 3; }
.item-row input { flex: 1; }
.item-row .hapus-item { flex: 0 0 auto; }

@media (max-width: 600px) {
    .menu a { padding: 7px 9px; font-size: .85rem; }
    .stat .value { font-size: 1.25rem; }
}

/* ---------- Combobox: dropdown dengan kolom pencarian ---------- */
.combo { position: relative; width: 100%; }
.item-row .combo { flex: 3; width: auto; min-width: 0; }
.combo > select {                /* select asli: disembunyikan tapi tetap fokusabel utk validasi */
    position: absolute; inset: 0;
    opacity: 0; pointer-events: none; margin: 0;
}
.combo-control {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: .95rem;
    min-height: 40px;
}
.combo.open .combo-control { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(180,83,9,.12); }
.combo-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-control.placeholder .combo-text { color: var(--muted); }
.combo-caret { color: var(--muted); font-size: .7rem; flex: 0 0 auto; }
.combo-panel {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    z-index: 50;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    overflow: hidden;
}
.combo-search {
    width: 100%; border: none; border-bottom: 1px solid var(--border);
    border-radius: 0; padding: 9px 11px; font-size: .9rem; outline: none;
}
.combo-search:focus { box-shadow: none; border-color: var(--border); border-bottom-color: var(--primary); }
.combo-list { list-style: none; margin: 0; padding: 4px; max-height: 220px; overflow-y: auto; }
.combo-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: .9rem; line-height: 1.3; }
.combo-list li:hover { background: var(--bg); }
.combo-list li.sel { background: var(--warning-bg); font-weight: 600; }
.combo-empty { padding: 10px; color: var(--muted); font-size: .85rem; text-align: center; }

/* ---------- Penambah jumlah (stepper) untuk input Qty ---------- */
.qty-stepper {
    display: flex; align-items: stretch;
    flex: 1; min-width: 104px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.item-row .qty-stepper { flex: 1; }
.qty-btn {
    width: 36px; flex: 0 0 auto;
    border: none;
    background: #f9fafb;
    color: var(--primary);
    font-size: 1.15rem; font-weight: 700; line-height: 1;
    cursor: pointer;
    user-select: none;
}
.qty-btn:hover { background: var(--warning-bg); }
.qty-btn:active { background: var(--primary); color: #fff; }
.qty-btn:first-child { border-right: 1px solid var(--border); }
.qty-btn:last-child  { border-left: 1px solid var(--border); }
.qty-stepper .qty-input {
    flex: 1; width: 100%; min-width: 0;
    border: none; border-radius: 0;
    text-align: center;
    padding: 9px 4px;
    -moz-appearance: textfield;     /* sembunyikan panah di Firefox */
}
.qty-stepper .qty-input:focus { box-shadow: none; }
/* Sembunyikan panah spinner bawaan di Chrome/Safari/Edge */
.qty-stepper .qty-input::-webkit-outer-spin-button,
.qty-stepper .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
