/* ==========================================================================
   TEMPLATES.CSS - 8 OFFICIAL THEMES FOR INVOICE & KWITANSI (A4 READY)
   Themes: Modern, Simple, Classic, Aesthetic, Minimalis, Kwitansi Umum, Biru Styles, Yellow Formal
   ========================================================================== */

/* -------------------------------------------------------------
   A4 SHEET CONTAINER SPECIFICATION
   ------------------------------------------------------------- */
.sheet-a4 {
    width: 210mm;
    min-height: 297mm;
    padding: 20mm 18mm;
    margin: 0 auto;
    background: #ffffff;
    box-sizing: border-box;
    position: relative;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    color: #1e293b;
    font-size: 13px;
    line-height: 1.5;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    transition: all 0.2s ease-in-out;
}

/* Print Rules - Exact A4 Zero Cutoff */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }
    html, body {
        width: 210mm;
        height: 297mm;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .no-print, .app-header, .editor-sidebar, .toast-container, .mobile-tabs {
        display: none !important;
    }
    .preview-column {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
    }
    .preview-wrapper {
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
    }
    .sheet-a4 {
        width: 210mm !important;
        min-height: 297mm !important;
        padding: 18mm 16mm !important;
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
    }
}

/* =============================================================
   SHARED COMPONENTS INSIDE A4 SHEET
   ============================================================= */
.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}
.brand-section {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 55%;
}
.brand-logo-img {
    max-height: 70px;
    max-width: 160px;
    object-fit: contain;
}
.brand-info h2 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 700;
}
.brand-info p {
    margin: 0;
    font-size: 11.5px;
    color: #475569;
    line-height: 1.4;
}
.doc-title-block {
    text-align: right;
}
.doc-type-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0 0 4px 0;
}
.doc-meta-table {
    margin-left: auto;
    font-size: 12px;
}
.doc-meta-table td {
    padding: 2px 6px;
}
.doc-meta-table td.label {
    color: #64748b;
    text-align: right;
}
.doc-meta-table td.val {
    font-weight: 600;
    text-align: right;
}

.parties-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 6px;
}
.party-col h4 {
    margin: 0 0 6px 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}
.party-col .party-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
}
.party-col .party-detail {
    font-size: 12px;
    color: #475569;
    line-height: 1.4;
}

/* Document Items Table */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}
.items-table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.items-table td {
    padding: 10px 12px;
    font-size: 12.5px;
    border-bottom: 1px solid #f1f5f9;
}
.items-table .text-right {
    text-align: right;
}
.items-table .text-center {
    text-align: center;
}

/* Calculation & Totals Section */
.summary-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 20px;
}
.terbilang-box {
    flex: 1;
    background: #f8fafc;
    border-left: 3px solid #3b82f6;
    padding: 12px 16px;
    border-radius: 0 6px 6px 0;
}
.terbilang-box .lbl {
    font-size: 10.5px;
    text-transform: uppercase;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 4px;
}
.terbilang-box .text {
    font-size: 12.5px;
    font-weight: 600;
    font-style: italic;
    color: #1e293b;
    line-height: 1.4;
}
.totals-table {
    width: 260px;
    font-size: 12.5px;
}
.totals-table td {
    padding: 4px 0;
}
.totals-table td.val {
    text-align: right;
    font-weight: 600;
}
.totals-table tr.grand-total td {
    padding-top: 8px;
    border-top: 2px solid #e2e8f0;
    font-size: 14px;
    font-weight: 800;
}

/* Payment & Signatures */
.doc-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 30px;
    gap: 30px;
}
.payment-info {
    flex: 1;
    font-size: 11.5px;
    color: #475569;
}
.payment-info h4 {
    margin: 0 0 6px 0;
    font-size: 11.5px;
    color: #1e293b;
    text-transform: uppercase;
    font-weight: 700;
}
.payment-info p {
    margin: 0 0 4px 0;
}
.signatures-box {
    text-align: center;
    width: 180px;
}
.signatures-box .sig-title {
    font-size: 11.5px;
    color: #64748b;
    margin-bottom: 8px;
}
.signature-img {
    max-height: 60px;
    max-width: 140px;
    object-fit: contain;
    margin: 0 auto 6px auto;
    display: block;
}
.signature-spacer {
    height: 60px;
}
.signature-name {
    font-size: 13px;
    font-weight: 700;
    border-top: 1px solid #cbd5e1;
    padding-top: 4px;
}
.signature-role {
    font-size: 11px;
    color: #64748b;
}

/* Stamp Watermark */
.stamp-watermark {
    position: absolute;
    top: 45%;
    right: 15%;
    transform: rotate(-15deg);
    padding: 8px 24px;
    border: 4px dashed;
    border-radius: 8px;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    opacity: 0.85;
    pointer-events: none;
    z-index: 10;
}
.stamp-paid {
    color: #16a34a;
    border-color: #16a34a;
}
.stamp-unpaid {
    color: #dc2626;
    border-color: #dc2626;
}
.stamp-draft {
    color: #64748b;
    border-color: #64748b;
}

/* =============================================================
   1. THEME: MODERN (Default sleek & sharp)
   ============================================================= */
.theme-modern .doc-type-title {
    color: var(--brand-color, #2563eb);
}
.theme-modern .items-table th {
    background: var(--brand-color, #2563eb);
    color: #ffffff;
}
.theme-modern .items-table tr:nth-child(even) {
    background: #f8fafc;
}
.theme-modern .totals-table tr.grand-total td {
    color: var(--brand-color, #2563eb);
    border-top: 2px solid var(--brand-color, #2563eb);
}
.theme-modern .terbilang-box {
    border-left-color: var(--brand-color, #2563eb);
}

/* =============================================================
   2. THEME: SIMPLE (Crisp, high-contrast monochrome)
   ============================================================= */
.theme-simple {
    font-family: 'Inter', -apple-system, sans-serif;
}
.theme-simple .parties-grid {
    background: transparent;
    border: 1px solid #e2e8f0;
}
.theme-simple .items-table th {
    background: #f1f5f9;
    color: #0f172a;
    border-top: 1px solid #0f172a;
    border-bottom: 1px solid #0f172a;
}
.theme-simple .items-table td {
    border-bottom: 1px solid #e2e8f0;
}
.theme-simple .terbilang-box {
    background: transparent;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #0f172a;
}
.theme-simple .doc-type-title {
    color: #0f172a;
}

/* =============================================================
   3. THEME: CLASSIC (Traditional serif, formal letterhead)
   ============================================================= */
.theme-classic {
    font-family: 'Times New Roman', Times, serif;
    color: #111827;
}
.theme-classic .doc-type-title {
    font-family: 'Georgia', serif;
    letter-spacing: 2px;
    color: #111827;
    border-bottom: 2px solid #111827;
    display: inline-block;
    padding-bottom: 4px;
}
.theme-classic .parties-grid {
    background: transparent;
    border-top: 1px solid #111827;
    border-bottom: 1px solid #111827;
    border-radius: 0;
}
.theme-classic .items-table th {
    border-bottom: 2px solid #111827;
    border-top: 1px solid #111827;
    background: transparent;
    color: #111827;
    font-style: italic;
}
.theme-classic .items-table td {
    border-bottom: 1px dotted #9ca3af;
}
.theme-classic .totals-table tr.grand-total td {
    border-top: 1px solid #111827;
    border-bottom: 3px double #111827;
}

/* =============================================================
   4. THEME: AESTHETIC (Soft pastel gradients & rounded cards)
   ============================================================= */
.theme-aesthetic {
    background: #fdfbf7;
    border-radius: 12px;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
.theme-aesthetic .parties-grid {
    background: #f3ede2;
    border-radius: 12px;
}
.theme-aesthetic .doc-type-title {
    color: #8b5cf6;
    letter-spacing: 2px;
}
.theme-aesthetic .items-table th {
    background: #ede9fe;
    color: #5b21b6;
    border-radius: 6px;
}
.theme-aesthetic .terbilang-box {
    background: #faf5ff;
    border-left: 3px solid #a855f7;
    border-radius: 10px;
}
.theme-aesthetic .totals-table tr.grand-total td {
    color: #6b21a8;
}

/* =============================================================
   5. THEME: MINIMALIS (Pure clean whitespace)
   ============================================================= */
.theme-minimalis {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.theme-minimalis .parties-grid {
    background: transparent;
    padding: 0;
    border: none;
    margin-bottom: 30px;
}
.theme-minimalis .items-table th {
    background: transparent;
    color: #94a3b8;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 500;
}
.theme-minimalis .items-table td {
    border-bottom: 1px solid #f8fafc;
    padding: 12px 10px;
}
.theme-minimalis .terbilang-box {
    background: transparent;
    border: none;
    border-top: 1px solid #e2e8f0;
    padding-left: 0;
}

/* =============================================================
   6. THEME: KWITANSI PADA UMUMNYA (Traditional Indonesian Kwitansi)
   ============================================================= */
.theme-kwitansi_umum {
    background: #fafffb;
    border: 3px double #15803d;
    padding: 15mm;
    position: relative;
    font-family: 'Courier New', Courier, monospace, serif;
}
.theme-kwitansi_umum::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    border: 1px solid #22c55e;
    pointer-events: none;
}
.theme-kwitansi_umum .doc-type-title {
    font-family: 'Arial Black', Impact, sans-serif;
    color: #166534;
    letter-spacing: 3px;
    text-shadow: 1px 1px 0px #bbf7d0;
}
.kwitansi-traditional-body {
    margin: 24px 0;
    font-size: 13.5px;
}
.kwitansi-row {
    display: flex;
    align-items: baseline;
    margin-bottom: 14px;
}
.kwitansi-label {
    width: 200px;
    font-weight: 700;
    text-transform: uppercase;
    color: #166534;
    font-size: 12px;
}
.kwitansi-dots {
    flex: 1;
    border-bottom: 1px dotted #166534;
    font-weight: 600;
    padding-bottom: 2px;
    color: #0f172a;
}
.kwitansi-terbilang-ribbon {
    background: #dcfce7;
    border: 1px solid #86efac;
    padding: 8px 14px;
    font-weight: 700;
    font-style: italic;
    color: #14532d;
    border-radius: 4px;
}
.kwitansi-nominal-stamp {
    display: inline-block;
    background: #ecfdf5;
    border: 2px solid #16a34a;
    padding: 10px 24px;
    font-size: 18px;
    font-weight: 900;
    color: #166534;
    border-radius: 6px;
    margin: 15px 0;
}
.kwitansi-stamp-box {
    border: 1px dashed #16a34a;
    width: 90px;
    height: 70px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #15803d;
    text-transform: uppercase;
    margin-right: 15px;
    vertical-align: middle;
}

/* =============================================================
   7. THEME: BIRU STYLES (Corporate Blue Waves)
   ============================================================= */
.theme-biru_styles .doc-header {
    background: #1e40af;
    color: #ffffff;
    margin: -20mm -18mm 24px -18mm;
    padding: 16mm 18mm 12mm 18mm;
}
.theme-biru_styles .brand-info p {
    color: #bfdbfe;
}
.theme-biru_styles .doc-type-title {
    color: #ffffff;
}
.theme-biru_styles .doc-meta-table td.label {
    color: #93c5fd;
}
.theme-biru_styles .doc-meta-table td.val {
    color: #ffffff;
}
.theme-biru_styles .items-table th {
    background: #1e3a8a;
    color: #ffffff;
}
.theme-biru_styles .items-table tr:nth-child(even) {
    background: #eff6ff;
}
.theme-biru_styles .terbilang-box {
    background: #eff6ff;
    border-left: 4px solid #1d4ed8;
}
.theme-biru_styles .totals-table tr.grand-total td {
    color: #1e40af;
    border-top: 2px solid #1e40af;
}

/* =============================================================
   8. THEME: YELLOW FORMAL (Executive Gold & Amber)
   ============================================================= */
.theme-yellow_formal {
    border-top: 8px solid #d97706;
}
.theme-yellow_formal .doc-type-title {
    color: #b45309;
}
.theme-yellow_formal .items-table th {
    background: #fef3c7;
    color: #92400e;
    border-top: 1px solid #f59e0b;
    border-bottom: 2px solid #d97706;
}
.theme-yellow_formal .parties-grid {
    background: #fffbeb;
    border-left: 3px solid #d97706;
}
.theme-yellow_formal .terbilang-box {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
}
.theme-yellow_formal .totals-table tr.grand-total td {
    color: #b45309;
    border-top: 2px solid #d97706;
}
