@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Bootstrap primary → Blue ── */
:root {
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-font-sans-serif: 'Inter', system-ui, sans-serif;

    /* Layout */
    --sidebar-w: 250px;
    --header-h: 60px;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;
    --sidebar-text: #64748b;
    --sidebar-active-bg: #eff6ff;
    --sidebar-active-text: #2563eb;

    /* Compat shims */
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;
    --blue-600: #2563eb;
    --success:  #059669;
    --danger:   #e11d48;
    --warning:  #d97706;
    --white:    #ffffff;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    font-size: 14px;
}

/* ── Bootstrap overrides ── */
.btn-primary { background-color: #2563eb; border-color: #2563eb; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { background-color: #1d4ed8 !important; border-color: #1d4ed8 !important; }
.btn-outline-primary { color: #2563eb; border-color: #2563eb; }
.btn-outline-primary:hover { background-color: #2563eb; border-color: #2563eb; }
.form-control:focus, .form-select:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.badge.bg-primary { background-color: #2563eb !important; }

/* ── LAYOUT ── */
.app-layout { display: flex; min-height: 100vh; }

/* Cegah flex/grid child menolak ngecil (penyebab umum konten meluber ke samping di HP) */
.app-layout, .main-area, .page-content, .kasir-layout,
.produk-area, .produk-grid, .keranjang, .keranjang-items, .topbar {
    min-width: 0;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.sidebar-logo .logo-icon {
    width: 36px; height: 36px;
    background: #2563eb;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.sidebar-logo .logo-icon svg { width: 18px; height: 18px; color: white; }
.sidebar-logo .brand { font-size: 16px; font-weight: 700; color: #0f172a; letter-spacing: -0.3px; }

.sidebar-nav { flex: 1; padding: 10px 12px; }

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    padding: 12px 10px 5px;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: all .15s ease;
    margin-bottom: 2px;
}
.nav-link-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-link-item:hover { background: #f1f5f9; color: #0f172a; }
.nav-link-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; }
.nav-link-item.active svg { color: #2563eb; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--sidebar-border); flex-shrink: 0; }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.sidebar-user .s-avatar {
    width: 32px; height: 32px;
    background: #dbeafe;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    color: #2563eb;
    flex-shrink: 0;
}
.sidebar-user .s-info { flex: 1; min-width: 0; }
.sidebar-user .s-name { font-size: 13px; font-weight: 600; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .s-role { font-size: 11px; color: #94a3b8; text-transform: capitalize; }

.btn-sidebar-logout {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    flex-shrink: 0;
}
.btn-sidebar-logout:hover { background: #fee2e2; color: #e11d48; }
.btn-sidebar-logout svg { width: 15px; height: 15px; }

/* ── MAIN AREA ── */
.main-area { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── TOPBAR ── */
.topbar {
    height: var(--header-h);
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 12px;
}
.topbar-title { font-size: 17px; font-weight: 700; color: #0f172a; letter-spacing: -0.3px; margin: 0; }
.topbar-sub { font-size: 13px; color: #94a3b8; margin-left: auto; }

/* ── PAGE CONTENT ── */
.page-content { padding: 24px 28px; flex: 1; }

/* ── STAT CARDS ── */
.stat-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 100%;
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.indigo  { background: #dbeafe; color: #2563eb; }
.stat-icon.emerald { background: #d1fae5; color: #059669; }
.stat-icon.amber   { background: #fef3c7; color: #d97706; }
.stat-icon.rose    { background: #fee2e2; color: #e11d48; }
.stat-label { font-size: 12px; color: #64748b; font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; color: #0f172a; letter-spacing: -0.5px; margin-top: 2px; }

/* ── KASIR LAYOUT ── */
.kasir-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    height: calc(100vh - var(--header-h) - 48px);
}

.produk-area {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.produk-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
    overflow-y: auto;
    padding-right: 4px;
    align-content: start;
}

.produk-card {
    background: white;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.produk-card:hover { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); transform: translateY(-1px); }
.produk-card.stok-habis { opacity: 0.4; pointer-events: none; }
.produk-card .p-kode { font-size: 10px; color: #94a3b8; font-weight: 500; }
.produk-card .p-nama { font-size: 13px; font-weight: 700; color: #0f172a; line-height: 1.3; }
.produk-card .p-harga { font-size: 13px; font-weight: 700; color: #2563eb; margin-top: 4px; }
.produk-card .p-stok { font-size: 11px; color: #94a3b8; }

/* ── KERANJANG ── */
.keranjang {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.keranjang-header {
    padding: 15px 18px;
    border-bottom: 1px solid #f1f5f9;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.keranjang-header h3 { font-size: 14px; font-weight: 700; margin: 0; color: #0f172a; }
.keranjang-items { flex: 1; overflow-y: auto; padding: 4px 0; }

.cart-item { padding: 10px 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #f8fafc; }
.cart-item .item-info { flex: 1; min-width: 0; }
.cart-item .item-nama { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #0f172a; }
.cart-item .item-harga { font-size: 11px; color: #94a3b8; }

.qty-control { display: flex; align-items: center; gap: 6px; }
.qty-btn {
    width: 24px; height: 24px;
    border-radius: 6px;
    border: 1.5px solid #e2e8f0;
    background: white;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    color: #64748b;
    transition: all .1s;
    line-height: 1;
}
.qty-btn:hover { background: #2563eb; color: white; border-color: #2563eb; }
.qty-val { font-size: 13px; font-weight: 700; min-width: 22px; text-align: center; color: #0f172a; }
.cart-subtotal { font-size: 13px; font-weight: 700; color: #2563eb; white-space: nowrap; }

.keranjang-footer { border-top: 1px solid #f1f5f9; padding: 16px 18px; flex-shrink: 0; }
.total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.total-label { font-size: 12px; color: #64748b; font-weight: 500; }
.total-value { font-size: 20px; font-weight: 800; color: #0f172a; letter-spacing: -0.5px; }

.empty-cart { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #cbd5e1; padding: 40px 20px; height: 100%; }
.empty-cart svg { width: 40px; height: 40px; }
.empty-cart p { font-size: 13px; margin: 0; color: #94a3b8; }

/* ── FILTER KATEGORI ── */
.filter-kategori {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding-bottom: 12px;
    flex-shrink: 0;
    scrollbar-width: none;
}
.filter-kategori::-webkit-scrollbar { display: none; }
.filter-btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1.5px solid transparent;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    flex-shrink: 0;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    line-height: 1.6;
}
.filter-btn:not(.active):hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transform: translateY(-1px);
}
.filter-btn.active {
    color: white !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

/* ── STRUK ── */
.struk {
    font-family: 'Courier New', monospace;
    font-size: 12.5px;
    background: #f8fafc;
    border-radius: 8px;
    padding: 16px;
    line-height: 1.7;
    color: #1e293b;
}
.struk-divider { border: none; border-top: 1px dashed #cbd5e1; margin: 8px 0; }
.struk-total { font-size: 14px; font-weight: 800; display: flex; justify-content: space-between; }
.struk-row { display: flex; justify-content: space-between; font-size: 12px; }
.struk-item-name { font-size: 12px; }
.struk-item-sub { display: flex; justify-content: space-between; font-size: 12px; color: #64748b; padding-left: 8px; }

/* ── TOAST ── */
#app-toast {
    position: fixed;
    bottom: 24px; right: 24px;
    background: #0f172a;
    color: white;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transform: translateY(8px);
    transition: all .25s ease;
    max-width: 300px;
    pointer-events: none;
}
#app-toast.show { opacity: 1; transform: translateY(0); }
#app-toast.success { background: #059669; }
#app-toast.error   { background: #e11d48; }

/* ── LOGIN PAGE ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #dbeafe 0%, #f8fafc 60%);
    padding: 20px;
}

/* ── CARD TWEAKS ── */
.card { border-color: #e2e8f0; border-radius: 12px; }
.card-header { background: white; border-bottom: 1px solid #f1f5f9; font-weight: 700; font-size: 14px; color: #0f172a; }

/* ── TABLE TWEAKS ── */
.table thead th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #64748b; background: #f8fafc; border-bottom-width: 1px; }
.table tbody td { font-size: 13.5px; vertical-align: middle; }
.table > :not(caption) > * > * { padding: 11px 14px; }

/* ── PRINT ── */
@media print {
    .sidebar, .topbar, .modal-footer, .btn { display: none !important; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ── RESPONSIVE ── */
.btn-menu-toggle {
    width: 34px; height: 34px;
    display: none;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: #334155;
    flex-shrink: 0;
    cursor: pointer;
}
.btn-menu-toggle:hover { background: #f1f5f9; }
.btn-menu-toggle svg { width: 20px; height: 20px; }

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

@media (max-width: 991.98px) {
    .btn-menu-toggle { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,.12);
    }
    .sidebar.open { transform: translateX(0); }

    .main-area { margin-left: 0; }

    /* ── Topbar: bungkus & jangan biarkan kontrol lebar-tetap (date/select) meluber ── */
    .topbar {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-h);
        padding: 12px 16px;
        row-gap: 10px;
    }
    .topbar .ms-auto {
        margin-left: 0 !important;
        width: 100%;
        flex-wrap: wrap;
        gap: 8px !important;
    }
    .topbar .ms-auto > * { flex: 1 1 140px; }
    .topbar input[type="date"],
    .topbar input[type="text"],
    .topbar select {
        width: 100% !important;
        min-width: 0 !important;
    }

    .page-content { padding: 16px; }

    /* ── Kasir: stack penuh, satu alur scroll (bukan scroll bertingkat) ── */
    .kasir-layout {
        display: block;
        height: auto;
    }
    .produk-area { overflow: visible; margin-bottom: 16px; }
    .produk-grid {
        max-height: none;
        overflow: visible;
    }
    .keranjang {
        max-height: 60vh;
    }
    .keranjang-items { max-height: 40vh; }

    /* ── Tabel & filter kategori: scroll halus di HP ── */
    .table-responsive, .filter-kategori { -webkit-overflow-scrolling: touch; }
    .filter-kategori { padding-bottom: 8px; }

    /* ── Target sentuh lebih besar ── */
    .btn, .form-control, .form-select { min-height: 38px; }
    .btn-sm { min-height: 32px; }
    .qty-btn { width: 30px; height: 30px; }

    .row.g-3 > [class*="col-"] { margin-bottom: 0; }
}

@media (max-width: 575.98px) {
    .produk-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
    .stat-value { font-size: 18px; }
    .topbar-title { font-size: 15px; }
    .page-content { padding: 12px; }
    .keranjang-header, .cart-item, .keranjang-footer { padding-left: 14px; padding-right: 14px; }

    /* topbar: satu kontrol per baris biar gak sempit */
    .topbar .ms-auto { flex-direction: column; align-items: stretch; }
    .topbar .ms-auto > * { flex: 1 1 auto; width: 100%; }

    /* Jasa Print: tombol Print/Fotokopi ditumpuk biar gak kejepit */
    #btnPrint, #btnFotokopi { flex-basis: 100%; }

    .table thead th, .table tbody td { font-size: 12px; padding: 8px 10px; }
}
