/* GLOBAL STYLES */
body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 20px;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 30px; 
    min-width: 320px;
}

/* ------------------ INPUT FORM STYLES (Responsif Vertikal) ------------------ */
.input-form {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    width: 95%; 
    max-width: 700px; 
    position: static; 
}

/* (Gaya input-form dipertahankan) */
.input-form h2 { border-bottom: 2px solid #ddd; padding-bottom: 5px; margin-top: 15px; }
.input-group { margin-bottom: 10px; }
.input-form label { display: block; font-weight: bold; margin-bottom: 3px; font-size: 0.9em; }
.input-form input, .input-form select { width: 100%; padding: 6px; margin-bottom: 5px; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; }
#item-input-container { border: 1px dashed #ccc; padding: 10px; margin-bottom: 15px; }
.item-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; align-items: center; border-bottom: 1px dotted #eee; padding-bottom: 5px; }
.item-row input, .item-row select { flex: 1 1 150px; }
.remove-btn { background-color: #dc3545; color: white; border: none; padding: 5px 8px; cursor: pointer; border-radius: 4px; font-size: 0.8em; flex: 0 0 80px; }
.input-form button:not(.remove-btn) { margin-top: 10px; padding: 10px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer; width: 100%; }
.input-form .print-btn { background-color: #17a2b8; }
hr { margin: 20px 0; border: 0; border-top: 1px solid #ccc; }


/* ------------------ INVOICE TEMPLATE STYLES (MATCHING IMAGE) ------------------ */
.invoice-container {
    background-color: white;
    padding: 30px 40px;
    width: 210mm; 
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    font-size: 11pt;
    max-width: 95%; 
}

/* Kop Surat Utama */
.header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
}

.header-logo-title {
    display: flex;
    align-items: flex-start;
    flex-grow: 1; 
    gap: 10px;
}

.logo {
    width: 120px; 
    height: auto;
    flex-shrink: 0; 
}

.title-and-address {
    flex-grow: 1;
    line-height: 1.2;
    padding-top: 5px; 
}

.title-and-address h2 {
    font-size: 1.1em;
    margin: 0;
    padding: 0 0 2px 0;
    border-bottom: none; /* PERBAIKAN: Hapus garis bawah nama Puslat Banjarnegara */
    display: block; 
    width: 200px; 
}

.contact-info {
    font-size: 0.8em;
    line-height: 1.4;
    text-align: left;
    margin-top: 0;
}

.contact-info p {
    margin: 0;
}
.contact-info .email-p {
    color: red; 
}
.contact-info .email {
    color: red;
}

/* Kotak INVOICE */
.invoice-box-container {
    flex-shrink: 0; 
    margin-left: 20px;
    margin-top: 5px;
}

.invoice-box {
    border: 1px solid #000;
    padding: 5px 15px; 
    font-size: 1em;
    font-weight: bold;
    text-align: center;
}

/* Garis Pemisah Kop Surat */
.header-divider {
    border-top: 3px solid #000; /* PERBAIKAN: Tebalkan garis horizontal */
    margin-top: 5px;
    margin-bottom: 10px;
}

/* Dokumen Details (Nomor dan Tanggal) */
.document-details.top-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.9em;
    border-bottom: none; /* PERBAIKAN: Hapus garis bawah detail nomor surat */
    padding-bottom: 0;
}

.doc-right {
    text-align: right;
}

.client-and-subject {
    font-size: 0.9em;
    line-height: 1.4;
    margin-bottom: 20px;
}
.client-and-subject p {
    margin: 3px 0;
}


.salam {
    margin-top: 20px;
    margin-bottom: 5px;
}

/* Tabel Item - PRESISI TINGGI */
.item-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.item-table th, .item-table td {
    border: 1px solid #000;
    padding: 5px; 
    vertical-align: middle;
    background-color: white !important; 
}

.item-table th {
    text-align: center;
    font-weight: bold;
}

/* Pengaturan Lebar Kolom Presisi */
.item-table .no { width: 4%; text-align: center;}
.item-table .unit-desc { width: 25%; }
.item-table .qty-col { width: 10%; text-align: center; } 
.item-table .satuan-col { width: 10%; text-align: center; } 
.item-table .harga { width: 17%; text-align: right; }
.item-table .jumlah { width: 18%; text-align: right; }
.item-table .ket { width: 16%; }

/* Footer Table - Total */
.item-table tfoot td {
    border: 1px solid #000;
    font-weight: bold;
    padding: 5px;
    text-align: center;
}

.total-label-bank {
    text-align: center; 
    padding-left: 0;
    background-color: #f0f0f0; 
}

.grand-total-value-cell {
    text-align: right;
    width: 34%; 
}


/* Bank Info Table - Presisi */
.bank-info-container {
    width: 45%;
    line-height: 1.2;
}
.bank-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 5px;
    font-size: 0.9em;
    margin-bottom: 10px;
}
.bank-table tr td {
    border: 1px solid #000;
    padding: 5px;
}
.bank-table tr td:first-child {
    width: 40%;
}

/* Footer Block */
.footer-block {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    line-height: 1.2;
}

.signature-block {
    width: 35%; 
    text-align: center;
    margin-top: 20px;
}

.signature-image {
    width: 150px; 
    height: auto;
    display: block;
    margin: 5px auto 0;
}

.admin-name {
    margin-top: 0;
    margin-bottom: 0;
    font-weight: bold;
    border-bottom: 1px solid #000; 
    display: inline-block;
    padding: 0 10px 2px 10px;
}
.admin-title {
    margin-top: 2px;
}


/* MEDIA QUERIES UNTUK LAYAR KECIL/MOBILE */
@media (max-width: 600px) {
    /* Kop surat di layar kecil dibuat menumpuk agar muat */
    .header-main {
        flex-direction: column;
        align-items: flex-start;
    }
    .header-logo-title {
        margin-bottom: 10px;
    }
    .invoice-box-container {
        align-self: flex-end; 
        margin-left: 0;
    }
    
    .footer-block {
        flex-direction: column;
        align-items: flex-start;
    }
    .bank-info-container {
        width: 100%;
        margin-bottom: 20px;
    }
    .bank-table {
        width: 100%;
    }
    .signature-block {
        width: 100%;
        text-align: left;
        margin-left: 0;
    }
    .signature-image {
        margin-left: 0;
    }
}


/* MEDIA PRINT - PENTING: MENGATUR TAMPILAN CETAK UNTUK PDF YANG AKURAT */
@media print {
    .input-form {
        display: none !important; 
    }
    .print-btn {
        display: none !important; 
    }
    
    body {
        background-color: white;
        padding: 0;
        margin: 0;
        display: block;
        font-size: 11pt; 
        width: 100%;
        height: 100vh;
    }

    /* PENTING: Menghilangkan header/footer dan watermark (jika ada) di hasil print */
    @page { 
        margin: 10mm; /* Margin yang sama dengan padding invoice container */
    }

    .invoice-container {
        box-shadow: none;
        margin: 0;
        border: none;
        padding: 10mm; 
        width: 210mm;
        box-sizing: border-box;
    }
    
    /* Memastikan layout 2 kolom tetap stabil saat dicetak */
    .header-main, .footer-block, .document-details {
        flex-direction: row !important; 
        align-items: center !important; 
    }
    .bank-info-container {
        width: 45%;
        margin-bottom: 0;
    }
    .signature-block {
        width: 40%;
    }
}