/* ========================================================
   ROGX Tech - Invoice Template System
======================================================== */

.invoice-page {
    /* Base styling for A4 Page */
    width: 794px;
    min-height: 1123px;
    height: auto;
    background-color: #ffffff;
    color: #333333;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
    /* CSS Variables customized by JS */
    --inv-primary: #012E4F;
    --inv-secondary: #EE303A;
    --inv-accent: #EE303A;
    --inv-title: #012E4F;
    --inv-text: #333333;
    --inv-muted: #6b7280;
    --inv-bg: #ffffff;
    --inv-border: #e5e7eb;
    
    font-size: 14px;
    line-height: 1.5;
}

#preview-b-name {
    color: var(--inv-title, var(--inv-primary));
}

.invoice-page .inv-title h2 {
    color: var(--inv-title, var(--inv-primary));
}

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

/* Base Print Styles for html2pdf */
.invoice-page .inv-header {
    background-color: #ffffff;
}

/* ========================================================
   THEME: MODERN CORPORATE
======================================================== */
.theme-modern {
    font-family: 'Inter', sans-serif;
}
.theme-modern .inv-header {
    border-top: 8px solid var(--inv-primary);
    border-bottom: 1px solid var(--inv-border);
}
.theme-modern .inv-title h2 {
    color: var(--inv-muted);
    opacity: 0.5;
}
.theme-modern .inv-footer {
    border-bottom: 8px solid var(--inv-primary);
    border-top: 1px solid var(--inv-border);
}
.theme-modern th {
    color: var(--inv-primary);
    border-bottom: 2px solid var(--inv-border);
}
.theme-modern .item-row {
    border-bottom: 1px solid var(--inv-bg);
}

/* ========================================================
   THEME: MINIMAL
======================================================== */
.theme-minimal {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --inv-bg: #ffffff;
}
.theme-minimal .inv-header {
    border-top: none;
    border-bottom: 1px solid var(--inv-text);
    padding-bottom: 40px;
    margin-bottom: 20px;
}
.theme-minimal .inv-footer {
    border-bottom: none;
    border-top: 1px solid var(--inv-text);
}
.theme-minimal th {
    color: var(--inv-text);
    border-bottom: 1px solid var(--inv-text);
}
.theme-minimal .item-row {
    border-bottom: 1px solid var(--inv-border);
}
.theme-minimal .bg-gray-50 {
    background-color: transparent !important;
}

/* ========================================================
   THEME: EXECUTIVE
======================================================== */
.theme-executive {
    font-family: 'Georgia', serif;
}
.theme-executive .inv-header {
    border-top: none;
    background-color: var(--inv-primary);
    color: #ffffff;
}
.theme-executive .inv-header * {
    color: #ffffff;
}
.theme-executive .inv-title h2 {
    color: #ffffff;
    opacity: 0.8;
}
.theme-executive #preview-b-tax, .theme-executive #preview-inv-status {
    background-color: rgba(255,255,255,0.2);
    color: #fff;
}
.theme-executive .inv-footer {
    border-bottom: none;
    background-color: var(--inv-primary);
    color: rgba(255,255,255,0.8);
}
.theme-executive th {
    background-color: var(--inv-bg);
    color: var(--inv-primary);
    border: none;
}

/* ========================================================
   THEME: CREATIVE
======================================================== */
.theme-creative {
    font-family: 'Outfit', sans-serif;
}
.theme-creative .inv-header {
    border-top: none;
    background: linear-gradient(135deg, var(--inv-primary) 0%, var(--inv-accent) 100%);
    color: #ffffff;
    border-radius: 0 0 40px 40px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.theme-creative .inv-header * {
    color: #ffffff;
}
.theme-creative #preview-inv-status {
    background-color: rgba(255,255,255,0.2);
    color: #fff;
}
.theme-creative .inv-footer {
    border-bottom: none;
    border-radius: 40px 40px 0 0;
    background-color: var(--inv-bg);
}
.theme-creative th {
    color: var(--inv-accent);
    border-bottom: 2px dashed var(--inv-border);
}
.theme-creative .item-row {
    border-bottom: 1px dashed var(--inv-border);
}

/* ========================================================
   Print Adjustments (html2pdf & Browser Print)
======================================================== */
.html2pdf__container {
    background: white;
    width: 794px !important;
}

/* Prevent bad page breaks inside rows and blocks */
tr.item-row,
.inv-header,
.inv-footer,
#preview-notes-block,
#preview-terms-block,
#preview-bank-block,
#preview-signature-block {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

#print-area {
    display: none;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm 0;
    }
    
    html, body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    /* Hide everything on the site except #print-area */
    body > *:not(#print-area) {
        display: none !important;
    }
    
    #print-area {
        display: block !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 210mm !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        z-index: 99999 !important;
    }
    
    #print-area .invoice-page {
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
        min-height: 297mm !important;
        height: auto !important;
        max-height: none !important;
        box-shadow: none !important;
        transform: scale(1) !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }
}
