/* ============================================================
   POS Enterprise - Production Styles (Touch Friendly & Fast)
   ============================================================ */

:root {
    /* Skema Warna: Ocean Dark & Emerald */
    --accent: #10B981;
    --accent-rgb: 16, 185, 129;
    --accent-hover: #059669;
    --accent-light: rgba(16, 185, 129, 0.12);

    --bg0: #020617;
    --bg1: #0f172a;
    --bg2: #1e293b;
    --bg3: #334155;
    --surface: #1e293b;
    --surface-glass: rgba(30, 41, 59, 0.85);

    --border: rgba(255, 255, 255, 0.08);
    --border-active: rgba(16, 185, 129, 0.5);

    --text: #f8fafc;
    --text-dim: #94a3b8;
    --muted: #64748b;

    --danger: #ef4444;
    --danger-rgb: 239, 68, 68;
    --warn: #f59e0b;
    --info: #3b82f6;
    --success: #10b981;

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 15px 40px rgba(0, 0, 0, 0.5);

    --font-sans: "Plus Jakarta Sans", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", monospace;
}

/* Light Mode: Modern Elegant & Anti Silau */
body.light-mode {
    --bg0: #e2e8f0;      
    --bg1: #f0f5f9;      
    --bg2: #ffffff;      
    --bg3: #f8fafc;      
    --surface: #ffffff;  
    --surface-glass: rgba(255, 255, 255, 0.80);

    --border: rgba(51, 65, 85, 0.08);
    --border-active: rgba(16, 185, 129, 0.4);

    --text: #1e293b;       
    --text-dim: #64748b;   
    --muted: #94a3b8;      

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 10px 15px -3px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 20px 40px -10px rgba(0, 0, 0, 0.06);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background: var(--bg1);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 10px; }

/* ============================================================
   1. LIGHT MODE ENHANCEMENTS
   ============================================================ */
body.light-mode .topbar, 
body.light-mode .sidebar-desktop {
    background: var(--surface-glass) !important;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-color: rgba(51, 65, 85, 0.06) !important;
}

body.light-mode .card {
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

body.light-mode .btn-primary {
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}
body.light-mode .btn-primary:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

/* ============================================================
   2. LOADER & LANDING PAGE
   ============================================================ */
.loader-wrap {
    position: fixed; inset: 0; background: var(--bg1);
    display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.loader-spin {
    width: 40px; height: 40px; border: 3px solid var(--bg3);
    border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite;
}

.lp-container {
    display: flex; height: 100vh; align-items: center; justify-content: center;
    flex-direction: column; text-align: center; padding: 20px;
    background: radial-gradient(circle at 50% 0%, var(--bg2) 0%, var(--bg1) 60%);
}
.lp-logo {
    width: 80px; height: 80px; background: var(--accent-light); color: var(--accent);
    border-radius: 24px; display: flex; align-items: center; justify-content: center;
    font-size: 32px; margin-bottom: 20px; box-shadow: 0 0 40px var(--accent-light);
}
.lp-title { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.lp-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 32px; }
.lp-clock { font-family: var(--font-mono); font-size: 48px; font-weight: 700; margin-bottom: 40px; letter-spacing: -1px; }
.lp-clock span { color: var(--accent); }
.lp-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }

/* ============================================================
   3. AUTH CARD & FORMS
   ============================================================ */
.auth-card {
    width: 100%; max-width: 380px; background: var(--surface); padding: 32px;
    border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 24px; text-align: center; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }

/* ============================================================
   4. COMPONENTS (Buttons, Inputs, Cards, Tables)
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
    border: none; cursor: pointer; transition: all .2s; font-family: inherit; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px var(--accent-light); }
.btn-outline { background: var(--bg2); color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: rgba(var(--danger-rgb), .1); color: var(--danger); border: 1px solid rgba(var(--danger-rgb), .2); }
.btn-lg { padding: 14px 20px; font-size: 15px; width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 12px; }
.w-full { width: 100%; }

.inp {
    width: 100%; padding: 12px 14px; background: var(--bg1); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-size: 15px; font-family: inherit;
    outline: none; transition: all .2s;
}
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.lbl { font-size:12px; font-weight:600; color:var(--text-dim); display:block; margin-bottom:6px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; }

.rtbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.rtbl thead th {
    background: var(--bg2); color: var(--muted); font-weight: 700; font-size: 11px;
    text-transform: uppercase; padding: 12px; text-align: left; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 2;
}
.rtbl tbody td { padding: 12px; border-bottom: 1px solid var(--border); }
.rtbl .tc { text-align: center; }
.rtbl .tr { text-align: right; }
.mono { font-family: var(--font-mono); }
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }

.badge { display: inline-flex; padding: 4px 8px; border-radius: 20px; font-size: 10px; font-weight: 700; }
.b-success { background: rgba(16, 185, 129, .1); color: var(--success); }
.b-warn { background: rgba(245, 158, 11, .1); color: var(--warn); }
.b-danger { background: rgba(239, 68, 68, .1); color: var(--danger); }

/* ============================================================
   5. MODAL & TOAST
   ============================================================ */
.modal-bg {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; animation: fadeIn .2s;
}
.modal-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: slideUp .25s;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; }

.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9998; display: flex; flex-direction: column; gap: 8px; }
.toast {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; backdrop-filter: blur(10px); border: 1px solid var(--border);
    box-shadow: var(--shadow-lg); animation: slideInRight .3s; max-width: 320px;
}
.t-ok { background: rgba(16, 185, 129, .15); color: var(--success); }
.t-err { background: rgba(239, 68, 68, .15); color: var(--danger); }
.t-info { background: rgba(59, 130, 246, .15); color: var(--info); }

/* ============================================================
   6. LAYOUT (App Shell, Sidebar, Topbar, Bottom Nav)
   ============================================================ */
.app-shell { display: flex; height: 100vh; }

.sidebar-desktop {
    width: 240px; background: var(--surface); border-right: 1px solid var(--border);
    padding: 16px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex-shrink: 0;
}
.main-content { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
    height: 60px; display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.page-content { flex: 1; padding: 16px; overflow-y: auto; padding-bottom: 80px; }

.sb-link {
    display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius-sm);
    color: var(--text-dim); cursor: pointer; transition: all .2s; border: none; background: none;
    width: 100%; text-align: left; font-family: inherit; font-size: 14px; font-weight: 500;
}
.sb-link:hover { background: var(--bg2); color: var(--text); }
.sb-link.on { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.sb-link i { width: 20px; text-align: center; }

.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: 65px; background: var(--surface);
    border-top: 1px solid var(--border); display: none; justify-content: space-around; align-items: center; padding: 0 8px; z-index: 100;
}
.bn-link {
    display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted);
    font-size: 10px; font-weight: 600; background: none; border: none; cursor: pointer;
}
.bn-link i { font-size: 18px; }
.bn-link.on { color: var(--accent); }

/* ============================================================
   7. SIDEBAR GRUP & MOBILE DRAWER
   ============================================================ */
.sb-group { margin-bottom: 4px; }
.sb-group-title {
    padding: 10px 12px; font-size: 11px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; cursor: pointer; display: flex; justify-content: space-between;
    align-items: center; list-style: none; user-select: none;
}
.sb-group-title::-webkit-details-marker { display: none; }
.sb-group .sb-link { padding-left: 24px; }
.sb-group[open] .sb-arrow { transform: rotate(180deg); }
.sb-arrow { transition: transform 0.2s ease; font-size: 10px; }
.sb-separator { height: 1px; background: var(--border); margin: 12px 8px; }

@media (max-width: 1024px) {
    .sb-toggle-btn { display: none !important; }
    .sidebar-desktop {
        display: flex !important; position: fixed; top: 0; right: 0; height: 100vh; width: 280px;
        z-index: 1001; transform: translateX(100%); transition: transform 0.3s ease-in-out;
        box-shadow: -4px 0 20px rgba(0,0,0,0.2); background: var(--surface); padding: 16px; overflow-y: auto;
    }
    body.drawer-open .sidebar-desktop { transform: translateX(0); }
    
    .drawer-overlay {
        display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
        backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    }
    body.drawer-open .drawer-overlay { display: block; }
    
    .bottom-nav .bn-link { flex: 1; }
}

/* ============================================================
   8. MINI SIDEBAR (ICON RAIL) & HOVER EXPAND - DESKTOP ONLY
   ============================================================ */
.sb-text, .sb-group-title, .sb-link { white-space: nowrap; overflow: hidden; }

@media (min-width: 1025px) {
    .sb-toggle-btn { display: flex !important; }
    body.sidebar-collapsed .sidebar-desktop {
        width: 64px; position: absolute; z-index: 999; height: 100vh;
        box-shadow: 4px 0 15px rgba(0,0,0,0.1); transition: width 0.3s ease;
    }
    body.sidebar-collapsed .sb-text { opacity: 0; width: 0; transition: opacity 0.1s ease; }
    body.sidebar-collapsed .sb-link { justify-content: center; padding-left: 0; padding-right: 0; }
    body.sidebar-collapsed .sb-group-title { justify-content: center; }
    body.sidebar-collapsed .sb-logo-text { display: none; }
    body.sidebar-collapsed .sb-header { justify-content: center; }

    body.sidebar-collapsed .sidebar-desktop:hover { width: 240px; box-shadow: 8px 0 30px rgba(0,0,0,0.2); }
    body.sidebar-collapsed .sidebar-desktop:hover .sb-text { opacity: 1; width: auto; transition: opacity 0.2s ease 0.15s; }
    body.sidebar-collapsed .sidebar-desktop:hover .sb-link { justify-content: flex-start; padding-left: 16px; padding-right: 12px; }
    body.sidebar-collapsed .sidebar-desktop:hover .sb-group-title { justify-content: space-between; }
    body.sidebar-collapsed .sidebar-desktop:hover .sb-logo-text { display: block; }
    body.sidebar-collapsed .sidebar-desktop:hover .sb-header { justify-content: space-between; }
    
    /* Dorong konten utama ke kanan agar tidak menembus saat sidebar sempit */
    body.sidebar-collapsed .main-content {
        padding-left: 64px;
        transition: padding-left 0.3s ease;
    }
}

/* ============================================================
   9. POS LAYOUT (Kasir)
   ============================================================ */
.pos-layout { display: grid; grid-template-columns: 1fr 360px; gap: 16px; height: 100%; }
.pos-left { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-md); border: 1px solid var(--border); overflow: hidden; }
.pos-search-wrap { padding: 12px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; }
.pos-grid { flex: 1; overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; align-content: start; }

.pos-card {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px;
    cursor: pointer; transition: all .15s; display: flex; flex-direction: column; justify-content: space-between; min-height: 90px;
}
.pos-card:active { transform: scale(0.96); border-color: var(--accent); }
.pos-card .ic { font-size: 24px; color: var(--muted); margin-bottom: 8px; }
.pos-card .nm { font-size: 12px; font-weight: 600; margin-bottom: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.pos-card .pr { font-size: 13px; font-weight: 700; color: var(--accent); font-family: var(--font-mono); }
.pos-card .st { font-size: 10px; color: var(--muted); margin-top: 2px; }

.pos-right { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-md); border: 1px solid var(--border); overflow: hidden; }
.cart-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.cart-list { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; /* Trik Flexbox agar scroll aman */ }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--bg2); }
.cart-item .info { flex: 1; }
.cart-item .nm { font-size: 13px; font-weight: 600; }
.cart-item .sub { font-size: 11px; color: var(--muted); }

.qty-ctrl { display: flex; align-items: center; gap: 6px; margin: 0 10px; }
.qty-btn { width: 26px; height: 26px; border-radius: 6px; background: var(--bg3); border: none; color: var(--text); cursor: pointer; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.qty-input {
    width: 40px; text-align: center; background: var(--bg3); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text); font-weight: 700; font-size: 13px; padding: 2px; -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input:focus { border-color: var(--accent); outline: none; }

.cart-item .total { font-weight: 700; font-size: 13px; min-width: 70px; text-align: right; font-family: var(--font-mono); }
.cart-footer { padding: 16px; border-top: 1px solid var(--border); background: var(--bg2); }
.cart-total { display: flex; justify-content: space-between; font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.cart-total .val { color: var(--accent); font-family: var(--font-mono); }

/* ============================================================
   10. KASIR MOBILE (STICKY MINI-CART & SLIDING CART)
   ============================================================ */
.pos-mini-cart {
    display: none;
}
.pos-qty-input-prompt {
    text-align: center;
    font-size: 32px;
    font-weight: 800;
    padding: 10px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: var(--font-mono);
    margin-bottom: 16px;
}

@media (max-width: 1024px) {
    .pos-layout {
        grid-template-columns: 1fr !important;
        grid-template-rows: 1fr !important;
        height: calc(100vh - 60px) !important; /* Tinggi dikurangi topbar */
    }
    
    /* Modal Keranjang Full Screen di HP */
    .pos-right {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: 100% !important; /* Hapus batas 400px agar full screen */
        height: 100vh;
        z-index: 998;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        border-radius: 0;
        box-shadow: -4px 0 20px rgba(0,0,0,0.2);
        padding-bottom: 65px; /* Tidak tertutup bottom nav */
    }
    body.cart-mobile-open .pos-right {
        transform: translateX(0);
    }
    
    /* Overlay Asli untuk menangkap klik di luar keranjang */
    .cart-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 997;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    body.cart-mobile-open .cart-overlay {
        display: block;
    }
    
    /* Tombol kembali khusus mobile di header keranjang */
    .cart-back-btn {
        display: flex !important;
    }
    
    /* Sticky Mini Cart di atas Bottom Nav */
    .pos-mini-cart {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        background: var(--surface);
        border-top: 1px solid var(--border);
        position: fixed;
        bottom: 65px; /* Di atas bottom nav */
        left: 0;
        right: 0;
        z-index: 100;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
        cursor: pointer;
    }
    .pos-mini-cart .mini-total {
        font-size: 18px;
        font-weight: 800;
        color: var(--accent);
        font-family: var(--font-mono);
    }
    .pos-mini-cart .mini-label {
        font-size: 11px;
        color: var(--muted);
        text-transform: uppercase;
    }
    
    /* Pastikan grid produk tidak tertutup mini-cart */
    .pos-grid {
        padding-bottom: 100px !important; 
    }
}

/* Sembunyikan tombol kembali di Desktop */
@media (min-width: 1025px) {
    .cart-back-btn { display: none !important; }
}

/* ============================================================
   11. ABSENSI WAJAH (Liveness Detection)
   ============================================================ */
.absen-standalone { position: fixed; inset: 0; z-index: 9999; background: var(--bg1); display: flex; flex-direction: column; }
.absen-topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 16px; }
.sa-cam-wrap { max-width: 320px; margin: 0 auto; width: 100%; }
.sa-preview { position: relative; width: 100%; aspect-ratio: 1/1; background: #000; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-lg); }
.sa-preview video, .sa-preview img { width: 100%; height: 100%; object-fit: cover; }
.sa-face-ring { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60%; height: 70%; border: 3px solid var(--border); border-radius: 50%; transition: border-color 0.3s ease; pointer-events: none; }
.liveness-step { width: 36px; height: 36px; border-radius: 50%; background: var(--bg3); display: flex; align-items: center; justify-content: center; font-size: 14px; border: 2px solid var(--border); color: var(--muted); transition: all 0.3s ease; }

/* ============================================================
   12. UTILITIES & RESPONSIVE
   ============================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }

@media (max-width: 1024px) {
    .sidebar-desktop { display: none; }
    .bottom-nav { display: flex; }
    .page-content { padding-bottom: 80px; }
}

@media (max-width: 640px) {
    .topbar { padding: 0 12px; }
    .page-content { padding: 12px; }
    .pos-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; padding: 8px; }
    .pos-card { padding: 10px; min-height: 90px; }
    .pos-card .nm { font-size: 12px; margin-bottom: 6px; }
    .pos-card .pr { font-size: 13px; }
    .pos-card .st { font-size: 10px; }
    .cart-total { font-size: 18px; }
    .modal-bg { padding: 0; align-items: flex-end; }
    .modal-box { width: 100%; max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    .hide-mobile { display: none !important; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
