/* =================================================================
   1. GLOBAL & PENGATURAN DASAR
==================================================================== */
* { box-sizing: border-box; }
body { margin: 0; padding: 0; font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; color: #333; background: #f0f4f3; }

.card-section { background: white; padding: 20px; border-radius: 10px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); overflow: hidden; }
.section-title { background: #1b5e20; color: white; padding: 12px 20px; font-weight: bold; margin: -20px -20px 20px -20px; font-size: 15px; }

/* =================================================================
   2. HEADER & BRAND
==================================================================== */
.app-header { background-color: #1b5e20; color: white; }

.brand { display: flex; align-items: center; gap: 15px; }
.brand-logo { width: 95px; height: 95px; object-fit: contain; border: 4px solid #ffffff; border-radius: 50%; padding: 2px; background: #1b5e20; }
.brand-text h2 { margin: 0; font-family: 'Arial Black', 'Impact', sans-serif; font-size: 26px; font-weight: 900; color: #ffffff; letter-spacing: 0.5px; line-height: 1; }
.brand-text p { margin: 4px 0 8px 0; font-family: Arial, sans-serif; font-size: 13px; color: #f8f9fa; }

/* Wadah Tombol Berjajar (Logout & Backup) */
.header-action-group { display: flex; gap: 8px; align-items: center; margin-top: 6px; }

.btn-logout { background: #dc3545; color: white; border: none; padding: 4px 10px; font-size: 11px; border-radius: 4px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: 0.2s ease-in-out; }
.btn-logout:hover { background: #c82333; transform: scale(1.05); }

.btn-export { background: #ff9800; color: white; border: none; padding: 4px 10px; font-size: 11px; border-radius: 4px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: 0.2s ease-in-out; }
.btn-export:hover { background: #e68a00; transform: scale(1.05); }

.stat-box { flex: 1; text-align: center; border-right: 1px solid #eee; }
.stat-box:last-child { border-right: none; }
.stat-label { font-size: 9px; color: #777; display: block; }
.stat-value { font-size: 13px; color: #1b5e20; font-weight: bold; display: block; margin-top: 4px; }

/* =================================================================
   3. FORM INPUT & TOMBOL
==================================================================== */
.card-section input[type="text"], .card-section input[type="date"], .card-section input[type="number"]:not(.qty-input), .card-section select { width: 100%; padding: 12px 15px; margin-bottom: 12px; border: 1.5px solid #ced4da; border-radius: 8px; font-size: 14px; background-color: #f8f9fa; transition: all 0.3s ease; box-sizing: border-box; }
.card-section input[type="text"]:focus, .card-section input[type="date"]:focus, .card-section input[type="number"]:not(.qty-input):focus, .card-section select:focus { outline: none; border-color: #1b5e20; background-color: #ffffff; box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.15); }
.card-section input[type="date"] { background-color: #eef7ef; border-color: #cfe3d3; font-weight: 600; }
#panelForm label { font-size: 13px; font-weight: 600; color: #444; margin: 5px 0; display: block; }
#diskon { margin-top: 15px; }

.btn-primary { width: 100%; background: #1b5e20; color: white; padding: 12px; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; transition: 0.2s ease-in-out; }
.btn-primary:hover { background: #14452F; }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5a6268; }

/* =================================================================
   4. PANEL DATA, TABEL & STICKY HEADER
==================================================================== */
#mobilePanelBarang, #mobilePanelHistori { overflow-x: auto; }
#mobilePanelHistori { padding-bottom: 5px; }
.divider-dashed { border: none; border-bottom: 2px dashed #eee; margin-bottom: 20px; }

.form-inline-group { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 25px; }
#namaBarang { flex: 2; min-width: 140px; margin-bottom: 5px; }
#hargaBarang { flex: 1; min-width: 100px; margin-bottom: 5px; }
#stokBarang { flex: 1; min-width: 80px; margin-bottom: 5px; }
#btnSimpanBarang { flex: 1; min-width: 120px; margin-bottom: 5px; }

#daftarBarang, #historiTransaksi { max-height: 400px; overflow: auto; border-radius: 10px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05); background: white; margin-bottom: 10px; }
#daftarBarang::-webkit-scrollbar, #historiTransaksi::-webkit-scrollbar { width: 6px; height: 6px; }
#daftarBarang::-webkit-scrollbar-thumb, #historiTransaksi::-webkit-scrollbar-thumb { background: #1b5e20; border-radius: 4px; }
#daftarBarang::-webkit-scrollbar-track, #historiTransaksi::-webkit-scrollbar-track { background: transparent; }

#panelData table, #historiTransaksi table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 500px; margin: 0; }
#panelData th, #historiTransaksi th { background-color: #1b5e20; color: #ffffff; padding: 16px 15px; text-align: left; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border: none; position: sticky; top: 0; z-index: 2; }
#panelData td, #historiTransaksi td { padding: 14px 15px; border-bottom: 1px solid #f0f0f0; font-size: 14px; vertical-align: middle; background-color: #ffffff; color: #444; }
#panelData tr:last-child td, #historiTransaksi tr:last-child td { border-bottom: none; }
#panelData tr:nth-child(even) td, #historiTransaksi tr:nth-child(even) td { background-color: #f9fcf9; }
#panelData tr:hover td, #historiTransaksi tr:hover td { background-color: #e8f5e9; transition: background-color 0.2s ease-in-out; }

#daftarBarang button, #historiTransaksi button, .btn-aksi { background-color: #1b5e20; color: #ffffff; border: none; padding: 6px 12px; border-radius: 5px; cursor: pointer; margin-right: 4px; font-size: 12px; font-weight: bold; display: inline-block; box-shadow: 0 2px 4px rgba(0,0,0,0.1); transition: all 0.2s ease-in-out; }
#daftarBarang button:hover, #historiTransaksi button:hover, .btn-aksi:hover { background-color: #14452F; transform: scale(1.05); }
#daftarBarang button i, #historiTransaksi button i { color: #ffffff; }

/* =================================================================
   5. KERANJANG BARANG
==================================================================== */
#pilihanBarang { max-height: 250px; overflow-y: auto; padding-right: 5px; margin-bottom: 15px; border: 1px solid #eee; border-radius: 8px; padding: 10px; margin-top: 5px; }
#pilihanBarang::-webkit-scrollbar { width: 6px; }
#pilihanBarang::-webkit-scrollbar-thumb { background: #1b5e20; border-radius: 4px; }

.item-pilihan { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 10px; background: white; gap: 10px; }
.item-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.item-info input[type="checkbox"] { width: 20px !important; height: 20px !important; flex-shrink: 0 !important; margin: 0 !important; padding: 0 !important; cursor: pointer; }
.item-text { font-size: 13px; font-weight: bold; color: #1b5e20; line-height: 1.3; word-wrap: break-word; }
.item-text small { display: block; font-weight: normal; color: #666; font-size: 11px; margin-top: 3px; }

.qty-control { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.qty-btn { background: #1b5e20; color: white; border: none; width: 28px; height: 28px; border-radius: 6px; font-size: 16px; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
#pilihanBarang input[type="number"].qty-input { width: 45px !important; text-align: center !important; font-weight: bold; padding: 6px 4px !important; margin: 0 !important; appearance: textfield; border: 1px solid #ccc !important; border-radius: 6px !important; background: #ffffff !important; }
#pilihanBarang input[type="number"].qty-input::-webkit-inner-spin-button, #pilihanBarang input[type="number"].qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.chart-wrapper { position: relative; height: 240px; width: 100%; }
.icon-orange { color: #ff9800; }
.icon-blue { color: #5B8DEF; }
.icon-green { color: #4CAF50; }

/* =================================================================
   6. MODAL (POP-UP)
==================================================================== */
#modalNota, #modalEditTransaksi { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 999999; overflow-y: auto; }
.modal-table-wrapper { display: table; width: 100%; height: 100%; }
.modal-table-cell { display: table-cell; vertical-align: middle; padding: 20px; }

.modal-content { background: #ffffff; color: #333333; margin: 0 auto; width: 100%; max-width: 400px; padding: 20px; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.5); font-family: sans-serif; }
.modal-title { margin-top: 0; border-bottom: 1px solid #ddd; padding-bottom: 10px; margin-bottom: 15px; }
.modal-content label { font-size: 13px; font-weight: bold; display: block; margin-bottom: 5px; }
.modal-content input, .modal-content select { width: 100%; padding: 8px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 14px; font-family: inherit; }
.modal-content select { margin-bottom: 20px; }

.modal-flex-row { display: flex; gap: 10px; margin-bottom: 10px; }
.modal-flex-col { flex: 1; }
.modal-flex-row.action-buttons { margin-bottom: 0; }
.modal-btn { flex: 1; padding: 10px; border: none; border-radius: 5px; font-weight: bold; cursor: pointer; }

/* =================================================================
   7. STYLING NOTA (CETAK)
==================================================================== */
#previewNota { width: 100%; overflow-x: auto; text-align: center; }
#areaPrintNota { background-color: #ffffff; color: #000000; padding: 20px; width: 80mm; min-width: 280px; margin: 0 auto 15px auto; font-family: 'Courier New', Courier, monospace; font-size: 14px; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); line-height: 1.4; text-align: left; box-sizing: border-box; }
#areaPrintNota * { color: #000000; border-color: #000000; text-shadow: none; box-shadow: none; }
#areaPrintNota table { width: 100%; border-collapse: collapse; margin: 15px 0; table-layout: fixed; }
#areaPrintNota th, #areaPrintNota td { border: none; padding: 6px 0; background-color: transparent; font-size: 13px; vertical-align: top; }
#areaPrintNota td:nth-child(1) { width: 55%; padding-right: 5px; word-wrap: break-word; }
#areaPrintNota td:nth-child(2) { width: 15%; text-align: center; }
#areaPrintNota td:nth-child(3) { width: 30%; text-align: right; }

@media print {
    @page { margin: 0; }
    body > *:not(#modalNota) { display: none !important; } 
    #modalNota { display: block !important; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: white; padding: 0; z-index: 99999; }
    .modal-table-wrapper, .modal-table-cell, .modal-content { display: block; width: 100%; max-width: 100%; padding: 0; margin: 0; border: none; box-shadow: none; background: transparent; }
    #areaPrintNota { width: 80mm; padding: 5mm; border: none; margin: 0; box-shadow: none; border-radius: 0; }
}

/* =================================================================
   8. GAYA SCROLL HISTORI (MOBILE)
==================================================================== */
.histori-mobile { max-height: 65vh; overflow-y: auto; padding-right: 5px; padding-bottom: 10px; }
.histori-mobile::-webkit-scrollbar { width: 5px; }
.histori-mobile::-webkit-scrollbar-thumb { background: #1b5e20; border-radius: 4px; }
.histori-mobile::-webkit-scrollbar-track { background: transparent; }

/* =================================================================
   9. RESPONSIVE MOBILE (MAKSIMAL 767PX)
==================================================================== */
@media only screen and (max-width: 767px) {
    body { overflow-y: auto; }
    
    .app-header { display: block; background-color: #1b5e20; padding: 30px 20px 35px 20px; border-radius: 0 0 30px 30px; color: white; }
    .brand { margin-bottom: 25px; } 

    .stats-container { background: white; border-radius: 16px; padding: 15px; display: flex; margin: 0; box-shadow: 0 5px 15px rgba(0,0,0,0.08); position: relative; z-index: 10; }
    .stat-box { flex: 1; text-align: center; border-right: 1px solid #eee; }
    .stat-box:last-child { border-right: none; }
    .stat-label { font-size: 9px; color: #777; display: block; }
    .stat-value { font-size: 13px; color: #1b5e20; font-weight: bold; display: block; margin-top: 4px; }

    .mobile-menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 25px 20px; padding-bottom: 120px; }
    .menu-card { background: white; padding: 15px; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); cursor: pointer; }
    .menu-card i { font-size: 24px; margin-bottom: 10px; }
    .menu-text h4 { margin: 0; font-size: 13px; color: #222; }
    .menu-text p { margin: 4px 0 0 0; font-size: 10px; color: #888; }

    .bottom-nav { position: fixed; bottom: 0; left: 0; width: 100%; display: flex; justify-content: space-around; align-items: center; box-sizing: border-box; padding: 10px 0 15px 0; background: white; box-shadow: 0 -2px 15px rgba(0,0,0,0.05); border-radius: 20px 20px 0 0; z-index: 1000; }
    .nav-item { text-align: center; color: #A0A0A0; font-size: 10px; cursor: pointer; }
    .nav-item i { font-size: 20px; display: block; margin-bottom: 4px; }
    .nav-item.active { color: #1b5e20; font-weight: bold; }
    .nav-fab { background: #1b5e20; color: white; width: 55px; height: 55px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 24px; margin-top: -40px; cursor: pointer; border: 4px solid #f0f4f3; }

    .workspace, .sidebar, .content-area { display: none; }
    .workspace { padding: 20px; padding-bottom: 90px; }

    #panelAnalisis { margin: 20px 20px 100px 20px; position: relative; z-index: 10; display: none; }
    .chart-container-pie { display: flex; flex-direction: column; height: auto; gap: 25px; }
    .legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; margin: 0; }
    
    .histori-desktop { display: none; }
    .histori-mobile { display: block; }
}

/* =================================================================
   10. RESPONSIVE DESKTOP (MINIMAL 768PX)
==================================================================== */
@media only screen and (min-width: 768px) {
    body { padding: 20px 40px; } 
    
    .app-header { display: flex; justify-content: space-between; align-items: center; background-color: #1b5e20; padding: 20px 30px; border-radius: 12px; margin-bottom: 25px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); color: white; }
    .brand { margin-bottom: 0; }
    
    .stats-container { display: flex; gap: 15px; margin: 0; padding: 0; background: transparent; box-shadow: none; }
    .stat-box { background: rgba(255, 255, 255, 0.15); padding: 12px 20px; border-radius: 8px; min-width: 140px; text-align: center; border: none; }
    .stat-label { color: #c8e6c9; }
    .stat-value { font-size: 20px; margin-top: 4px; color: #ffffff; }

    #mobileDashboard, .bottom-nav { display: none; }
    
    #mainWorkspace { display: flex; gap: 25px; }
    #panelForm { display: block; width: 340px; flex-shrink: 0; }
    #panelData { display: block; flex: 1; min-width: 0; }
    #mobilePanelBarang, #mobilePanelHistori { display: block; }
    
    #panelAnalisis { display: block; }
    .chart-container-pie { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 30px; height: 300px; }
    .chart-wrapper { height: 100%; width: 100%; }
    
    .legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; align-content: start; max-height: 280px; overflow-y: auto; padding-right: 15px; margin: 0; }
    .legend-grid::-webkit-scrollbar { width: 6px; }
    .legend-grid::-webkit-scrollbar-thumb { background: #1b5e20; border-radius: 4px; }
    .legend-grid::-webkit-scrollbar-track { background: transparent; }
    
    .filter-dashboard { display: flex; gap: 12px; flex-direction: row; }
    
    .histori-desktop { display: block; }
    .histori-mobile { display: none; }
}

/* =================================================================
   11. LAYAR KUNCI & LOGIN (LOCK SCREEN)
==================================================================== */
#lockScreen {
    position: fixed; 
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #1b5e20; 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999999; 
}

.lock-box {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    width: 85%;
    max-width: 320px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

/* Styling Khusus Logo Login di Layar Kunci */
.lock-logo {
    width: 75px;
    height: 75px;
    object-fit: contain;
    border: 3px solid #1b5e20;
    border-radius: 50%;
    padding: 2px;
    background: #ffffff;
    margin-bottom: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.lock-box h2 { margin: 0; font-size: 20px; font-weight: 900; color: #333; }
.lock-box p { font-size: 13px; color: #777; margin-bottom: 20px; }

.login-input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 15px;
    text-align: center;
    font-size: 16px;
    border: 2px solid #ced4da;
    border-radius: 8px;
    font-weight: bold;
    outline: none;
    transition: 0.3s;
    box-sizing: border-box;
    color: #333;
}

.login-input:focus { border-color: #1b5e20; }