:root {
    --bg-main: #f1f5f9;
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --receipt-bg: #ffffff;
    --receipt-text: #0f172a;
    --receipt-border: #94a3b8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Header & Sidebar */
.app-header {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-back:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.title-area h1 {
    font-size: 1.4rem;
    font-weight: 800;
}

.title-area h1 span { color: var(--primary); }

.title-area p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.action-area {
    display: flex;
    gap: 12px;
}

.btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #e2e8f0; color: var(--text-main); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #fee2e2; color: #ef4444; border: 1px solid #fca5a5; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; margin-top: 10px; }
.hidden { display: none !important; }

/* Layout Utama */
.app-container {
    display: flex;
    height: calc(100vh - 75px);
}

.control-panel {
    width: 400px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    overflow-y: auto;
}

.panel-section {
    margin-bottom: 30px;
}

.panel-section h3 {
    font-size: 0.95rem;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--bg-main);
    color: var(--text-main);
    text-transform: uppercase;
    font-weight: 700;
}

.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group textarea,
.form-group input[type="file"],
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: var(--text-main);
    outline: none;
    transition: border 0.2s;
    background-color: var(--panel-bg);
}

.form-group input:focus,
.form-group textarea:focus,
.form-select:focus {
    border-color: var(--primary);
}

.form-group textarea { resize: vertical; }
.hint { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.status-indicator { font-size: 0.75rem; font-style: italic; color: var(--primary); }

/* Toggle Switch */
.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-main);
    padding: 10px 12px;
    border-radius: 6px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px; width: 16px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(18px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Area Preview Kanan (Kertas Kuitansi) */
.preview-panel {
    flex: 1;
    background: #cbd5e1;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
}

.receipt-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
}

.receipt-paper {
    background: var(--receipt-bg);
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    position: relative;
    color: var(--receipt-text);
    padding: 40px 50px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

/* Dinamika Ukuran Kertas di Layar (Preview) */
.size-receipt {
    max-width: 850px;
    min-height: 400px; /* Asumsi rasio landscape standar */
}
.size-a5 {
    max-width: 210mm;
    min-height: 148mm; /* A5 Landscape */
}
.size-a4 {
    max-width: 210mm;
    min-height: 297mm; /* A4 Portrait */
    display: flex;
    flex-direction: column;
}
/* Jika A4, posisikan konten di atas, sisa ruang kosong di bawah */
.size-a4 .r-footer {
    margin-top: auto; /* Dorong footer agak ke bawah atau biarkan normal, kita biarkan normal saja dengan jarak lega */
}

/* Latar Belakang Garis Kuitansi */
.receipt-paper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border: 2px solid #e2e8f0;
    margin: 10px;
    pointer-events: none;
    z-index: 1;
}

.r-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px double var(--receipt-text);
    padding-bottom: 20px;
    margin-bottom: 25px;
    position: relative;
    z-index: 2;
}

.r-company-info {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 60%;
}

.r-logo-container {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.r-logo-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.r-company-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.r-company-text p {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.4;
}

.r-title-box {
    text-align: right;
}

.r-title-box h2 {
    font-size: 2.2rem;
    font-family: 'Playfair Display', serif;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.r-no { font-size: 1rem; font-weight: 600; }

.r-body {
    margin-bottom: 30px;
    position: relative;
    z-index: 2;
}

.r-row {
    display: flex;
    margin-bottom: 15px;
    align-items: flex-end;
    font-size: 1.05rem;
}

.r-label {
    width: 180px;
    font-weight: 600;
    flex-shrink: 0;
}

.r-colon { width: 20px; text-align: center; font-weight: 600; }

.r-value {
    flex: 1;
    min-height: 24px;
    padding-left: 10px;
    font-style: italic;
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
}

.r-border-bottom { border-bottom: 1px dashed var(--receipt-border); }

.r-terbilang-box {
    background: #f8fafc;
    border: 1px solid var(--receipt-border);
    padding: 8px 15px;
    font-weight: 700;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,0.02) 10px, rgba(0,0,0,0.02) 20px);
}

.r-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    position: relative;
    z-index: 2;
    margin-top: 30px;
}

.r-nominal-box {
    display: flex;
    align-items: center;
    border: 2px solid var(--receipt-text);
    padding: 10px 25px;
    background: #f8fafc;
}

.r-nominal-box .rp { font-weight: 700; font-size: 1.2rem; margin-right: 15px; }
.r-nominal-box .amount { font-size: 1.6rem; font-weight: 800; letter-spacing: 1px; }

.r-signature-box { text-align: center; width: 250px; }
.r-date { font-size: 1rem; margin-bottom: 60px; }
.r-signer-name { font-weight: 700; text-decoration: underline; font-size: 1.05rem; }

/* PENGATURAN CETAK (PRINT) DINAMIS */
@media print {
    .no-print { display: none !important; }
    
    body {
        background: white;
        margin: 0;
        padding: 0;
    }
    
    .app-container, .preview-panel {
        display: block;
        height: auto;
        padding: 0;
        margin: 0;
        background: white;
    }
    
    .receipt-wrapper { display: block; }
    
    .receipt-paper {
        box-shadow: none;
        margin: 0;
        padding: 20px;
        page-break-inside: avoid;
    }

    /* Override dimensi khusus saat dicetak agar mengikuti setting CSS bawaan browser page layout */
    .receipt-paper.size-receipt, 
    .receipt-paper.size-a5, 
    .receipt-paper.size-a4 {
        max-width: 100%;
        min-height: auto;
    }
}

/* Modifikasi CSS Rule @page berdasarkan kelas body (diubah via JS) */
body.print-size-receipt @page { size: 210mm 100mm landscape; margin: 0; }
body.print-size-a5 @page { size: A5 landscape; margin: 0; }
body.print-size-a4 @page { size: A4 portrait; margin: 0; }

@media (max-width: 900px) {
    .app-container { flex-direction: column; height: auto; }
    .control-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); }
    .preview-panel { padding: 20px; }
    .receipt-paper { padding: 25px; }
    .r-header { flex-direction: column; align-items: center; text-align: center; }
    .r-company-info { max-width: 100%; flex-direction: column; text-align: center; margin-bottom: 15px;}
    .r-title-box { text-align: center; }
    .r-row { flex-direction: column; align-items: flex-start; }
    .r-label { width: 100%; }
    .r-colon { display: none; }
    .r-value { width: 100%; border-bottom: 1px solid var(--receipt-border); }
    .r-footer { flex-direction: column; align-items: center; gap: 30px; }
}
/* -- (Gunakan semua CSS dari versi sebelumnya di sini) -- */
/* Sisipkan baris di bawah ini ke dalam style.css Anda */

.btn-outline-success {
    background: white;
    border: 1px solid #22c55e;
    color: #15803d;
}
.btn-outline-success:hover {
    background: #f0fdf4;
}

/* Container Cetak Massal */
#bulkContainer {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Modifikasi Print Global untuk Cetak Massal */
@media print {
    body.is-bulk-print #receiptWrapper {
        display: none !important;
    }
    body.is-bulk-print #bulkContainer {
        display: block !important;
        margin: 0;
        padding: 0;
    }
    
    body.is-bulk-print .receipt-paper {
        page-break-after: always; /* Memastikan tiap kuitansi excel ganti kertas */
        box-shadow: none;
        margin: 0;
        padding: 20px;
    }
    body.is-bulk-print .receipt-paper:last-child {
        page-break-after: auto;
    }
}