* {
    box-sizing: border-box;
}

@page {
    size: A4 portrait;
    margin: 0;
}

body {
    background-color: #e5e7eb;
    margin: 0;
    padding: 0 0 30px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: Arial, sans-serif;
}

/* Header & Tombol Print */
.header-bar {
    width: 100%;
    background-color: #ffffff;
    border-bottom: 1px solid #d1d5db;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-back {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-back:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
    color: #111827;
}

.btn-print {
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.15s ease;
}

.btn-print:hover {
    background-color: #1d4ed8;
}

.btn-print:active {
    background-color: #1e40af;
}

/* Tampilan Kertas A4 di Layar */
.a4-page {
    width: 210mm;
    min-height: 297mm;
    padding: 0;
    margin: 0 auto 20px auto;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
    position: relative;
}

/* Card Batas Potong */
.card-potong,
.batas-potong {
    width: 130mm;
    height: 39mm;
    border-right: 1px dashed #000;
    border-bottom: 1px dashed #000;
    border-top: none;
    border-left: none;
    box-sizing: border-box;
    display: flex;
    position: relative;
}

/* Card Label */
.card-label,
.label-card {
    width: 115mm;
    max-width: 115mm;
    height: 32mm;
    max-height: 35mm;
    margin-top: 5px;
    margin-left: 23px;
    margin-right: auto;
    margin-bottom: auto;
    border: 1px solid #000;
    box-sizing: border-box;
    background-color: #ffffff;
    overflow: hidden;
    display: flex;
    flex-direction: row;
}

/* Card Logo - Lebar 30% dari card-label, tinggi 100% */
.card-logo {
    width: 30%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 2px;
}

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

/* Card Detail Label - Lebar 70% dari card-label, tinggi 100% */
.card-detail-label {
    width: 70%;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3px 8px;
    border-left: 1px solid #000;
    gap: 3px;
}

.kode-barang {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-bottom: 1px solid #000000;
    padding-bottom: 2px;
}

.kode-barang p {
    margin: 0;
    font-size: 25px;
    font-weight: 700;
    color: #000000;
    line-height: 1.2;
    letter-spacing: 0.5px;
    text-align: center;
    width: 100%;
}

.nama-barang {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: 1px;
}

.nama-barang p {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #111111;
    line-height: 1.25;
    text-transform: uppercase;
    text-align: center;
    width: 100%;
}

/* Pengaturan Cetak (Print Out) - Multi-halaman A4 Rapi */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .header-bar,
    .no-print {
        display: none !important;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }

    html, body {
        width: 210mm;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background-color: #ffffff !important;
        overflow: visible !important;
        display: block;
    }

    .a4-page {
        width: 210mm;
        height: 296mm;
        max-height: 296mm;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        page-break-after: always;
        break-after: page;
        overflow: hidden !important;
        box-sizing: border-box;
    }

    .a4-page:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
    }
}
