/* ============================= */
/* BASE STYLES (SCREEN) */
/* ============================= */

.enhanced-po-view {
    font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
    color: #1e293b;
    background: #fff;
}

/* Header */
.enhanced-po-view .header-box {
    border-bottom: 3px solid #64748b;
    padding-bottom: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.enhanced-po-view .title-section {
    text-align: center;
}

.enhanced-po-view .title-section h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    color: #0f172a;
    text-transform: uppercase;
}

.enhanced-po-view .title-section h2 {
    margin: 0;
    font-size: 18px;
    color: #64748b;
}

/* Info cards */
.enhanced-po-view .info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.enhanced-po-view .info-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.enhanced-po-view .info-card-header {
    background: #64748b;
    color: #fff;
    padding: 8px 15px;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
}

.enhanced-po-view .info-card-body {
    padding: 12px 15px;
    font-size: 12px;
    line-height: 1.6;
}

/* Table */
.enhanced-po-view .items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    border: 1px solid #e2e8f0;
}

.enhanced-po-view .items-table th {
    background: #f1f5f9;
    color: #475569;
    font-weight: 700;
    padding: 10px;
    text-align: center;
    font-size: 11px;
}

.enhanced-po-view .items-table td {
    padding: 10px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    font-size: 12px;
}

.enhanced-po-view .text-left { text-align: left; }
.enhanced-po-view .text-right { text-align: right; }

/* Totals */
.enhanced-po-view .totals-section {
    display: flex;
    justify-content: flex-end;
}

.enhanced-po-view .totals-table {
    width: 350px;
    border-collapse: collapse;
    border: 1px solid #e2e8f0;
}

.enhanced-po-view .totals-table td {
    padding: 10px;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
}

.enhanced-po-view .label-cell {
    background: #f8fafc;
    font-weight: 600;
}

.enhanced-po-view .value-cell {
    text-align: right;
    font-weight: 700;
}

/* ============================= */
/* PRINT STYLES (FIXED VERSION) */
/* ============================= */

@media print {

    /* Reset everything */
    * {
        overflow: visible !important;
        box-shadow: none !important;
    }

    html, body {
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        min-height: auto !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

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

    .enhanced-po-view {
        width: 100% !important;
        display: block !important;
        position: static !important;
        margin: 0 !important;
        padding: 0 !important;
        page-break-before: avoid !important;
        break-before: avoid !important;
    }

    /* 🔴 Kill GRID & FLEX (print-safe layout) */
    .info-grid {
        display: grid !important;
        gap: 20px !important;
    }

    .info-card {
        margin-bottom: 0 !important;
        border-radius: 8px !important;
    }

    .header-box {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        text-align: left !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .totals-section {
        display: flex !important;
        justify-content: flex-end !important;
        margin-top: 20px;
    }

    /* 🔴 TABLE FIXES (MOST IMPORTANT) */
    .items-table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: auto;
        border: 1px solid #334155 !important;
    }

    .items-table thead {
        display: table-header-group;
    }

    .items-table th {
        background-color: #f1f5f9 !important;
        border: 1px solid #334155 !important;
        -webkit-print-color-adjust: exact;
        color: #1e293b !important;
    }

    .items-table td {
        border: 1px solid #334155 !important;
        page-break-inside: avoid;
    }

    .items-table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    /* 🔴 TOTALS & INFO BORDERS */
    .totals-table {
        border: 1px solid #334155 !important;
        width: 350px !important;
        margin-left: auto !important;
    }

    .totals-table td {
        border: 1px solid #334155 !important;
    }

    .label-cell {
        background-color: #f8fafc !important;
        -webkit-print-color-adjust: exact;
    }

    .info-card {
        border: 1px solid #334155 !important;
        margin-bottom: 15px !important;
    }

    .info-card-header {
        background-color: #64748b !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
    }

    /* 🔴 REMOVE RISKY STYLES */
    .items-table,
    .info-card,
    .totals-table {
        border-radius: 0 !important;
    }

    /* 🔴 FIX MODAL ISSUE */
    .modal,
    .modal-dialog,
    .modal-content,
    .modal-body {
        display: block !important;
        position: static !important;
        overflow: visible !important;
        max-height: none !important;
        height: auto !important;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    #printable_area {
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
    }

    /* Page setup */
    @page {
        size: A4;
        margin: 10mm;
    }
}