/* ============================================================
   POS Luminary Shop — Custom CSS (CI4 Bootstrap 5)
   ============================================================ */

:root {
    --pos-primary:    #2D1F7E;
    --pos-accent:     #FF6B35;
    --pos-topbar-h:   52px;
    --pos-sidebar-w:  72px;
    --pos-cart-w:     420px;
    --pos-font:       'Nunito Sans', system-ui, sans-serif;
    --pos-mono:       'DM Mono', 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--pos-font);
    background: #F5F5F7;
    overflow: hidden;
}

/* ── TOP BAR ──────────────────────────────────────────────────────────────── */
.pos-topbar {
    height: var(--pos-topbar-h);
    background: var(--pos-primary);
    color: white;
    flex-shrink: 0;
    z-index: 100;
}

.topbar-logo {
    width: 30px; height: 30px;
    background: var(--pos-accent);
    border-radius: 8px;
    font-size: .7rem;
    font-weight: 900;
    display: flex; align-items: center; justify-content: center;
}

.topbar-brand {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -.5px;
}

.topbar-divider { background: rgba(255,255,255,0.2); }
.topbar-date    { font-size: .75rem; }

.topbar-nav-btn {
    display: flex; align-items: center;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: .75rem; font-weight: 700;
    color: rgba(255,255,255,.6);
    text-decoration: none;
    transition: all .15s;
}
.topbar-nav-btn:hover  { color: #fff; background: rgba(255,255,255,.1); }
.topbar-nav-btn.active { color: #fff; background: rgba(255,255,255,.2); }

.topbar-alert-badge {
    font-size: .7rem; font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    text-decoration: none;
    display: flex; align-items: center;
}

.topbar-user {
    display: flex; align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,.1);
    cursor: pointer;
    transition: background .15s;
}
.topbar-user:hover { background: rgba(255,255,255,.2); }

.topbar-clock {
    font-family: var(--pos-mono);
    font-size: .85rem;
    font-weight: 500;
    color: rgba(255,255,255,.9);
    margin-left: 8px;
}

/* ── LAYOUT ───────────────────────────────────────────────────────────────── */
.pos-app   { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.pos-main  { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.pos-layout{ height: 100%; }

/* ── CATEGORY SIDEBAR ─────────────────────────────────────────────────────── */
.cat-sidebar {
    width: var(--pos-sidebar-w);
    background: white;
    border-right: 1px solid #E5E7EB;
    flex-shrink: 0;
    overflow-y: auto;
}

.cat-btn {
    width: 54px; height: 54px;
    border-radius: 12px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    font-size: .6rem; font-weight: 700;
    color: #9CA3AF;
    text-decoration: none;
    transition: all .15s;
    text-align: center;
}
.cat-btn i          { font-size: 1rem; }
.cat-btn:hover      { background: #F3F4F6; color: #374151; }
.cat-btn.active     { background: var(--pos-primary); color: white; }

/* ── SEARCH BAR ───────────────────────────────────────────────────────────── */
.search-bar {
    background: white;
    flex-shrink: 0;
}
.search-bar .form-control:focus { box-shadow: none; }

/* ── PRODUCT GRID ─────────────────────────────────────────────────────────── */
.product-grid { background: #F5F5F7; }

.product-card {
    background: white;
    border-radius: 14px;
    border: 1px solid #E5E7EB;
    overflow: hidden;
    transition: all .15s;
    user-select: none;
}
.product-card:hover        { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-1px); }
.product-card.out-of-stock { opacity: .5; filter: grayscale(.5); }
.product-card:focus        { outline: none; }
.product-card[tabindex]:focus-visible,
.product-card[tabindex]:focus {
    outline: none;
    border-color: var(--pos-primary);
    box-shadow: 0 0 0 3px rgba(45,31,126,.35);
    transform: translateY(-1px);
}
.product-card.card-added {
    border-color: #34A853;
    box-shadow: 0 0 0 3px rgba(52,168,83,.55);
}

.product-icon {
    height: 80px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    position: relative;
}

.product-tag {
    position: absolute;
    top: 6px; right: 6px;
    font-size: .6rem;
    background: var(--pos-primary);
    color: white;
    border-radius: 999px;
    padding: 2px 7px;
}

.product-info {
    padding: 8px 10px 10px;
}
.product-name  { font-size: .78rem; font-weight: 700; line-height: 1.3; color: #111827; }
.product-price { font-family: var(--pos-mono); font-size: .75rem; font-weight: 700; color: var(--pos-primary); }

/* ── SEARCH RESULTS (muncul hanya saat mencari) ──────────────────────────── */
.search-results {
    background: #fff;
    flex-shrink: 0;
    max-height: 42vh;
    display: flex;
    flex-direction: column;
}
.search-results-body {
    overflow-y: auto;
}

/* ── CART — AREA UTAMA (full) ─────────────────────────────────────────────── */
.cart-main   { background: #F5F5F7; min-width: 0; }
.cart-header { background: #fff; flex-shrink: 0; }

.cart-table-head {
    display: grid;
    grid-template-columns: minmax(0,1fr) 130px 130px 130px 40px;
    gap: 10px;
    align-items: center;
    padding: 6px 16px;
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
    font-size: .65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #9CA3AF;
    flex-shrink: 0;
}

.cart-items { background: #fff; }

.cart-row {
    display: grid;
    grid-template-columns: minmax(0,1fr) 130px 130px 130px 40px;
    gap: 10px;
    align-items: center;
    padding: 4px 16px;
    background: #fff;
    border-bottom: 1px solid #EEF0F2;
}
.cart-row:hover { background: #FAFAFB; }

.cart-emoji { font-size: 1.1rem; line-height: 1; flex-shrink: 0; }
.cart-name  { font-size: .82rem; font-weight: 600; color: #111827; }
.cart-unit  { font-size: .8rem; }
.cart-sub   { font-size: .82rem; color: #111827; }

.qty-btn {
    width: 24px; height: 24px;
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #374151;
    cursor: pointer;
    transition: all .15s;
    flex-shrink: 0;
}
.qty-btn:hover           { background: #F3F4F6; }
.qty-btn.primary         { background: var(--pos-primary); border-color: var(--pos-primary); color: #fff; }
.qty-btn.primary:hover   { filter: brightness(1.1); }
.qty-btn:disabled        { opacity: .4; cursor: not-allowed; }
.qty-btn i               { font-size: .8rem; }

/* Baris keranjang: qty input lebih ringkas */
.cart-qty .qty-input { width: 40px; padding: 1px 2px; }

/* ── SUMMARY / PEMBAYARAN PANEL ───────────────────────────────────────────── */
.summary-panel {
    width: var(--pos-cart-w);
    min-width: 340px;
    flex-shrink: 0;
    background: white;
}
.summary-body   { background: #fff; }
.summary-footer { background: #fff; flex-shrink: 0; }

/* ── STOK OPNAME ──────────────────────────────────────────────────────────── */
.opname-head,
.opname-row {
    display: grid;
    grid-template-columns: minmax(0,1fr) 120px 190px 110px 48px;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
}
.opname-head {
    background: #F9FAFB;
    border-bottom: 1px solid #E5E7EB;
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #9CA3AF;
}
.opname-row { border-bottom: 1px solid #F1F3F5; transition: background .3s; }
.opname-row:last-child { border-bottom: none; }
.opname-row:hover { background: #FAFAFB; }
.opname-row.row-flash   { background: #FEF3C7; }
.opname-row.row-counted { background: #F0FDF4; }
.opname-row.row-counted:hover { background: #E7FBEE; }

.opname-emoji   { font-size: 1.4rem; line-height: 1; flex-shrink: 0; }
.selisih-badge  { font-family: var(--pos-mono); font-weight: 700; font-size: .95rem; }
.opname-footer  { flex-shrink: 0; }

.phys-input:focus { box-shadow: none; border-color: var(--pos-primary); }

@media (max-width: 768px) {
    .opname-head,
    .opname-row { grid-template-columns: minmax(0,1fr) 70px 150px 70px 40px; gap: 8px; padding: 8px; }
}

/* ── REVIEW LAPORAN (dalam modal) ─────────────────────────────────────────── */
.report-print { color: #111827; font-size: 13px; }
.report-print h2 { font-size: 20px; margin: 0 0 2px; font-weight: 800; }
.report-print h3 { font-size: 14px; margin: 18px 0 6px; border-bottom: 2px solid #E5E7EB; padding-bottom: 4px; font-weight: 800; }
.report-print .rp-sub  { color: #6B7280; font-size: 12px; }
.report-print .rp-head { margin-bottom: 10px; }
.report-print .rp-table { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.report-print .rp-table td,
.report-print .rp-table th { padding: 5px 8px; border-bottom: 1px solid #EEF0F2; text-align: left; vertical-align: top; }
.report-print .rp-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: #9CA3AF; }
.report-print .num   { text-align: right; font-family: var(--pos-mono); white-space: nowrap; }
.report-print .muted { color: #9CA3AF; }
.report-print .rp-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.report-print .rp-tx   { margin-bottom: 12px; }
.report-print .rp-tx thead th { background: #F9FAFB; color: #374151; font-weight: 700; }
.report-print .rp-total td { font-weight: 800; border-top: 2px solid #D1D5DB; }
.report-print .rp-line td  { border-top: 1px solid #D1D5DB; }
.report-print .rp-foot { margin-top: 16px; text-align: center; font-size: 11px; }
@media (max-width: 576px) { .report-print .rp-2col { grid-template-columns: 1fr; } }

/* ── HINT PINTASAN KEYBOARD ────────────────────────────────────────────────── */
.kbd-hint {
    display: inline-block;
    font-family: var(--pos-mono);
    font-size: .62rem;
    font-weight: 700;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 5px;
    background: #EEF0F4;
    color: #6B7280;
    border: 1px solid #E1E4EA;
    vertical-align: middle;
}
.kbd-hint-light {
    background: rgba(255,255,255,.22);
    color: #fff;
    border-color: rgba(255,255,255,.35);
}

/* ── CHECKOUT MODAL ───────────────────────────────────────────────────────── */
.pay-method-btn {
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    padding: 10px 8px;
    background: white;
    cursor: pointer;
    transition: all .15s;
    text-align: center;
}
.pay-method-btn:hover  { border-color: var(--pos-primary); }
.pay-method-btn.active { border-color: var(--pos-primary); background: rgba(45,31,126,.05); color: var(--pos-primary); }

/* ── PAGE HEADER (Products/Reports) ─────────────────────────────────────── */
.page-header {
    background: white;
    flex-shrink: 0;
    z-index: 10;
}

/* ── KPI ──────────────────────────────────────────────────────────────────── */
.kpi-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    font-size: 1.1rem;
}

.bg-purple       { background-color: #7c3aed !important; }
.text-purple      { color: #7c3aed !important; }
.bg-purple-subtle { background-color: #ede9fe !important; }

/* ── TYPOGRAPHY ───────────────────────────────────────────────────────────── */
.font-mono { font-family: var(--pos-mono); }

/* ── ACCORDION ────────────────────────────────────────────────────────────── */
.accordion-button::after { flex-shrink: 0; margin-left: auto; }
.accordion-button:not(.collapsed) { color: inherit; box-shadow: none; background: #F9FAFB; }
.accordion-button:focus  { box-shadow: none; }

/* ── SCROLLBAR ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: #CBD5E1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ── SUCCESS SCREEN ───────────────────────────────────────────────────────── */
.success-check { animation: bounceIn .5s ease; }
@keyframes bounceIn {
    0%   { transform: scale(.5); opacity: 0; }
    70%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* ── SCAN OCR MODAL ───────────────────────────────────────────────────────── */
.scan-frame-box {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -55%);
    width: 270px; height: 130px;
    border: 2.5px solid rgba(255,107,53,.9);
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.42);
    animation: scanFramePulse 2.5s ease-in-out infinite;
    pointer-events: none;
}
@keyframes scanFramePulse {
    0%, 100% { border-color: rgba(255,107,53,.9); }
    50%       { border-color: rgba(255,107,53,.35); }
}

/* Sudut aksen di pojok frame */
.scan-frame-box::before,
.scan-frame-box::after {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    border-color: #FF6B35;
    border-style: solid;
}
.scan-frame-box::before { top: -4px; left: -4px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.scan-frame-box::after  { bottom: -4px; right: -4px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

.scan-line-anim {
    position: absolute;
    left: 50%;
    width: 250px;
    height: 2px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(255,107,53,.9) 40%, rgba(255,107,53,.9) 60%, transparent);
    top: 30%;
    animation: scanLineSlide 2.5s ease-in-out infinite;
    pointer-events: none;
}
@keyframes scanLineSlide {
    0%        { top: 30%; opacity: 1; }
    80%, 100% { top: 60%; opacity: 0; }
}

.scan-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.76);
    gap: 6px;
}

/* ── VOICE SEARCH ─────────────────────────────────────────────────────────── */
.voice-btn {
    cursor: pointer;
    transition: background .15s;
    font-size: .9rem;
}
.voice-btn:hover { background: #f3f4f6 !important; }
.voice-btn.voice-listening { background: #fff0f0 !important; }
.voice-btn.voice-listening .bi-mic-fill {
    animation: micPulse .8s ease-in-out infinite;
}
@keyframes micPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(.85); }
}

/* ── QTY INPUT ────────────────────────────────────────────────────────────── */
.qty-input {
    width: 38px;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    background: #f9fafb;
    font-family: var(--pos-mono);
    font-weight: 700;
    font-size: .78rem;
    padding: 1px 3px;
    color: #111827;
    transition: border-color .15s, background .15s;
}
.qty-input:focus {
    outline: none;
    border-color: var(--pos-primary);
    background: white;
}
.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.qty-input { -moz-appearance: textfield; }

/* ── TIER / DISKON PELANGGAN ──────────────────────────────────────────────── */
.tier-btn {
    flex: 1;
    padding: 4px 6px;
    border: 1.5px solid #E5E7EB;
    border-radius: 8px;
    background: white;
    font-size: .7rem;
    font-weight: 700;
    color: #6B7280;
    cursor: pointer;
    transition: all .15s;
    text-align: center;
    line-height: 1.4;
}
.tier-btn:hover  { border-color: var(--pos-primary); color: var(--pos-primary); }
.tier-btn.active { border-color: var(--pos-primary); background: var(--pos-primary); color: white; }
.tier-badge {
    display: inline-block;
    background: rgba(255,255,255,.25);
    border-radius: 4px;
    padding: 0 4px;
    font-size: .6rem;
}
.tier-btn.active .tier-badge { background: rgba(255,255,255,.3); }

/* ── P&L STATEMENT ────────────────────────────────────────────────────────── */
.pl-section-title { letter-spacing: .03em; }
.pl-row:hover     { background: #F9FAFB; border-radius: 6px; }

/* ── VOICE MIC BUTTON (in input-group) ───────────────────────────────────── */
.voice-mic-btn { transition: background .15s; }
.voice-mic-btn i { font-size: .85rem; }
.voice-mic-btn.voice-listening { background: #fff0f0 !important; border-color: #f5c6cb !important; }
.voice-mic-btn.voice-listening i { color: #dc3545; animation: micPulse .8s ease-in-out infinite; }

/* ── PRODUCT AUTOCOMPLETE ────────────────────────────────────────────────── */
.product-ac-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1070;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.16);
    border: 1px solid #E5E7EB;
    max-height: 240px;
    overflow-y: auto;
    margin-top: 3px;
}
.product-ac-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #F3F4F6;
    transition: background .1s;
}
.product-ac-item:last-child { border-bottom: none; }
.product-ac-item:hover { background: #F9FAFB; }

/* ── BARCODE SCANNER ─────────────────────────────────────────────────────── */
.barcode-video-wrap { background: #111; }
.barcode-frame {
    width: 220px;
    height: 110px;
    border: 2px solid rgba(255,107,53,.9);
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
    animation: scanFramePulse 2.5s ease-in-out infinite;
    position: relative;
}
.barcode-frame::before,
.barcode-frame::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-color: #FF6B35;
    border-style: solid;
}
.barcode-frame::before { top: -3px; left: -3px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.barcode-frame::after  { bottom: -3px; right: -3px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

/* ── STOCK INDICATOR in purchase rows ───────────────────────────────────── */
.stock-indicator { font-size: .7rem; min-height: 16px; }

/* ── RESPONSIVE FIX ───────────────────────────────────────────────────────── */
@media (max-width: 992px) {
    :root { --pos-sidebar-w: 56px; --pos-cart-w: 320px; }
    .topbar-brand { display: none; }
    .cat-btn      { width: 44px; height: 44px; }
    .summary-panel { min-width: 300px; }

    /* Tabel keranjang: sembunyikan kolom harga satuan agar muat */
    .cart-table-head,
    .cart-row {
        grid-template-columns: minmax(0,1fr) 130px 120px 40px;
    }
    .cart-table-head > div:nth-child(2),
    .cart-row .cart-unit { display: none; }
}
