/* ==========================================================================
   MINIMAL FUNCTIONAL CSS & ORIGINAL ID CARD SYSTEM (ISO CR-80)
   ========================================================================== */

/* ── MODAL OVERLAY & DIALOG FUNCTIONAL DISPLAY ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ── ORIGINAL ID CARD DESIGN SYSTEM (ISO CR-80 85.6mm x 54.0mm) UNTOUCHED ── */
.modal-card-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 0;
}

.card-wrapper-scale {
    transform: scale(1.6);
    transform-origin: center center;
    margin: 1.5rem 0 1.25rem;
    transition: transform 0.2s ease;
}

@media (max-width: 1200px) {
    .card-wrapper-scale {
        transform: scale(1.25);
        margin: 0.75rem 0;
    }
}

.id-card {
    box-sizing: border-box;
    position: relative;
    background-color: #ffffff;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    user-select: none;
    border: 0.15mm solid #222;
}

.id-card.landscape {
    width: 85.6mm;
    height: 54mm;
    border-radius: 3.18mm;
}

.id-card .card-company-name {
    position: absolute;
    left: 24%;
    top: 6%;
    font-size: 3mm;
    font-weight: 700;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    width: 71%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
}

.id-card .card-divider-line {
    position: absolute;
    left: 0;
    top: 14%;
    width: 100%;
    height: 2px;
    background-color: #000000;
}

.id-card .card-name {
    position: absolute;
    left: 8%;
    top: 23%;
    font-size: 4.3mm;
    font-weight: 700;
    color: #000000;
    width: 49%;
    text-align: left;
    white-space: nowrap;
    overflow: visible;
    line-height: 1.2;
}

.id-card .card-npk {
    position: absolute;
    left: 8%;
    top: 31%;
    font-size: 4.6mm;
    font-weight: 700;
    color: #000000;
    text-transform: uppercase;
    width: 49%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.id-card .card-epm {
    position: absolute;
    left: 9%;
    top: 67%;
    font-size: 3.5mm;
    font-weight: 600;
    color: #000000;
    text-transform: uppercase;
    width: 48%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.id-card .card-site {
    position: absolute;
    left: 9%;
    top: 69%;
    font-size: 3mm;
    font-weight: 600;
    color: #000000;
    text-transform: uppercase;
    width: 48%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.id-card .card-qr {
    position: absolute;
    left: 59%;
    top: 32%;
    width: 31mm;
    height: 31mm;
    background: #ffffff;
    padding: 0.5mm;
    border: 0.2mm solid #000;
    border-radius: 1mm;
    display: flex;
    align-items: center;
    justify-content: center;
}

.id-card .card-qr canvas {
    width: 100% !important;
    height: 100% !important;
}

.qr-payload-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #0f172a;
    border: 1px solid #334155;
    padding: 12px 16px;
    border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 700;
}

/* ── HIDE ISOLATED PRINT BULK CONTAINER ON SCREEN ── */
#print-bulk-container {
    display: none !important;
}

/* ── BULK PRINT A4 SCREEN PREVIEW STYLING ── */
.a4-sheet-container {
    background: #ffffff;
    color: #000000;
    padding: 6mm;
    margin: 0 auto;
    width: 210mm;
    box-sizing: border-box;
}

.a4-page-grid {
    display: grid;
    grid-template-columns: repeat(2, 85.6mm);
    gap: 1.5mm 5mm;
    justify-content: center;
    align-content: start;
}

.a4-card-item {
    position: relative;
    width: 85.6mm;
    height: 54mm;
    border: 1px dashed #64748b;
    box-sizing: border-box;
    page-break-inside: avoid;
    break-inside: avoid;
    border-radius: 3.18mm;
    overflow: hidden;
    background: #ffffff;
}

/* ── DEDICATED CLEAN PRINT MEDIA ENGINE (EPSON L5290 & NISCA PR-C101) ── */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    html, body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
    }

    /* Hide EVERYTHING by default during print */
    body * {
        display: none !important;
    }

    /* Single Card Print Engine */
    body.print-single #card-preview-modal {
        display: block !important;
        visibility: visible !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 85.6mm !important;
        height: 54.0mm !important;
        background: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }
    body.print-single #card-preview-modal * {
        visibility: visible !important;
    }

    /* Bulk A4 Print Engine - Clean isolated container */
    #pdf-gen-stage,
    body.print-bulk #print-bulk-container {
        display: block !important;
        visibility: visible !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 210mm !important;
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }
    #pdf-gen-stage *,
    body.print-bulk #print-bulk-container * {
        visibility: visible !important;
    }

    body.print-bulk .a4-sheet-container {
        display: block !important;
        width: 210mm !important;
        height: 285mm !important;
        max-height: 287mm !important;
        box-sizing: border-box !important;
        padding: 6mm 6mm 0 6mm !important;
        margin: 0 auto !important;
        background: #ffffff !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        page-break-after: always !important;
        break-after: page !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        overflow: hidden !important;
    }

    body.print-bulk .a4-sheet-container:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
    }

    body.print-bulk .a4-page-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 85.6mm) !important;
        gap: 1.5mm 6mm !important;
        justify-content: center !important;
        align-content: start !important;
        width: 100% !important;
        margin: 0 auto !important;
        padding: 0 !important;
    }

    body.print-bulk .a4-card-item {
        display: block !important;
        width: 85.6mm !important;
        height: 54.0mm !important;
        box-sizing: border-box !important;
        border: 1px dashed #000000 !important;
        border-radius: 3.18mm !important;
        overflow: hidden !important;
        position: relative !important;
        background: #ffffff !important;
    }

    .id-card {
        box-shadow: none !important;
        position: relative !important;
        background-color: #ffffff !important;
    }

    .id-card .card-company-name,
    .id-card .card-divider-line,
    .id-card .card-name,
    .id-card .card-npk,
    .id-card .card-epm,
    .id-card .card-site,
    .id-card .card-qr {
        display: block !important;
        position: absolute !important;
        visibility: visible !important;
    }

    .id-card .card-qr canvas {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
    }

    .card-wrapper-scale {
        transform: scale(1) !important;
        margin: 0 !important;
    }
}
