/* ================================================
   SIMPLE INVOICE — PROFESSIONAL CLEAN DESIGN
   ================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px; color: #111; background: #fff;
}

.simple-invoice {
    width: 100%;
    flex: 1;                /* fills #invoicePreview container on screen */
    min-height: 277mm;      /* A4 - 10mm top - 10mm bottom margins */
    display: flex;
    flex-direction: column;
}

/* ---- HEADER ACCENT ---- */
.si-accent { height: 4px; background: linear-gradient(90deg, #2563eb, #1e3a5f); }

/* ---- HEADER ---- */
.si-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 14px 10px;
    border-bottom: 1.5px solid #2563eb;
    background: #fff;
    color: #111;
}
.si-company-name { font-size: 20px; font-weight: 800; color: #1e3a5f; letter-spacing: 0.3px; margin-bottom: 4px; }
.si-company-info { font-size: 11.5px; color: #444; line-height: 1.65; }
.si-invoice-meta { text-align: right; font-size: 10.5px; line-height: 1.75; color: #333; }
.si-title {
    font-size: 14px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; margin-bottom: 6px;
    color: #2563eb; border: 1.5px solid #2563eb;
    display: inline-block; padding: 3px 10px;
}
#barcode { display: block; margin: 6px 0 0 auto; max-width: 130px; height: 36px; }

/* ---- PARTY ---- */
.si-party {
    border-bottom: 1px solid #dde3ea;
    padding: 8px 14px; font-size: 11px; line-height: 1.6;
    background: #f8faff;
}
.si-party b { color: #1e3a5f; }

/* ---- ITEMS — full width, table-layout:fixed ---- */
.si-items {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 10px;
    border-bottom: 2px solid #2563eb;
}
.si-items thead { display: table-header-group; }
.si-items thead tr { background: #e8edf8; color: #1e3a5f; }
.si-items th {
    padding: 5px 4px;
    text-align: center;
    font-size: 9.5px; font-weight: 700; letter-spacing: 0.3px;
    border-right: 1px solid #c5d0e8;
    overflow: hidden;
}
.si-items th:last-child  { border-right: none; }
.si-items th:nth-child(2) { text-align: left; }

.si-items td {
    padding: 4px 4px; vertical-align: top;
    border-bottom: 1px solid #c5d0e8;
    border-right: 1px solid #c2cfe0;
    overflow-wrap: break-word;
    word-break: break-word;
}
.si-items td:last-child { border-right: none; }
.si-items tbody tr:nth-child(even) td { background: #f5f8ff; }
.si-items tbody tr { page-break-inside: avoid; break-inside: avoid; }
.si-desc { font-size: 9px; color: #666; margin-top: 2px; }
.si-filler-row td { height: 18px; border-bottom: 1px solid #c5d0e8; border-right: 1px solid #c2cfe0; }
.si-filler-row td:last-child { border-right: none; }
.si-filler-row:last-child td { border-bottom: none; }

/* Column widths are set dynamically via inline styles in layout.php */

/* ---- BOTTOM SECTION (totals → footer) stays together on print ---- */
.si-bottom {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-top: auto;       /* push footer to bottom of page when items are few */
}

/* ---- TOTALS (right-aligned table) ---- */
.si-totals-wrap { display: flex; justify-content: flex-end; border-bottom: 1px solid #dde3ea; }
.si-totals { width: 42%; border-collapse: collapse; font-size: 11px; }
.si-totals td { padding: 4px 10px; border-bottom: 1px solid #edf0f3; }
.si-totals td:first-child { color: #555; }
.si-totals td:last-child { text-align: right; font-weight: 600; }
.si-grand td {
    background: #1e3a5f; color: #fff;
    font-weight: 700; font-size: 12px; border-bottom: none;
    padding: 6px 10px;
}
.si-grand td:first-child { color: #fbbf24; }

/* ---- WORDS ---- */
.si-words {
    font-size: 10.5px; background: #f0f4ff;
    border-bottom: 1px solid #dde3ea;
    padding: 5px 14px;
}

/* ---- HSN ---- */
.si-hsn {
    width: 100%; border-collapse: collapse; font-size: 10px;
    border-bottom: 1px solid #dde3ea;
}
.si-hsn thead { display: table-header-group; }
.si-hsn thead tr { background: #e8edf8; }
.si-hsn th { padding: 4px 6px; text-align: center; font-weight: 600; border-right: 1px solid #dde3ea; color: #1e3a5f; }
.si-hsn th:last-child { border-right: none; }
.si-hsn td { padding: 4px 6px; border-bottom: 1px solid #edf0f3; border-right: 1px solid #edf0f3; }
.si-hsn td:last-child { border-right: none; }

/* ---- BANK + QR ---- */
.si-bank {
    display: flex; justify-content: space-between; align-items: flex-start;
    border-bottom: 1px solid #dde3ea;
    padding: 8px 14px; background: #fff; font-size: 10.5px; line-height: 1.7;
}
.si-bank-list { display: flex; gap: 24px; flex-wrap: wrap; }
.si-bank-item { font-size: 10.5px; line-height: 1.7; }
.si-bank-item b { color: #1e3a5f; }
.si-qr { text-align: center; font-size: 10px; }
#upiQR { margin: 4px auto; }

/* ---- FOOTER ---- */
.si-footer {
    display: flex; justify-content: space-between;
    border-top: 2px solid #2563eb;
    padding: 8px 14px; font-size: 10px; line-height: 1.6;
}
.si-sign { text-align: right; }

/* ---- HELPERS ---- */
.c { text-align: center; }
.r { text-align: right; }

/* ---- PRINT ---- */
@media print {
    @page { size: A4 portrait; margin: 10mm; }
    html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
    #invoicePreview { padding: 0 !important; }

    /* Force background colors to print */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

    /* Items can break across pages, each row stays intact */
    .si-items { page-break-inside: auto; }
    .si-items tbody tr { page-break-inside: avoid; break-inside: avoid; }

    /* Keep all footer content together; pushes to next page if needed */
    .si-bottom { page-break-inside: avoid; break-inside: avoid; }
}
