﻿
:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --text-main: #333;
    --text-light: #7f8c8d;
    --border-color: #ecf0f1;
}

/* Page Setup */
@page {
    size: A4 portrait;
    margin: 0;
}

body {
    margin: 0;
    padding: 0;
    background: #eee;
    font-family: sans-serif;
}

.page_a4 {
    width: 210mm;
    min-height: 297mm;
    padding: 20mm;
    margin: 10mm auto;
    background: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    position: relative;
    box-sizing: border-box;
}

@media print {
    body {
        background: none;
    }

    .page_a4 {
        margin: 0;
        box-shadow: none;
    }

    .no-print {
        display: none;
    }
}

/* Header - Uses grid with logical alignment */
header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.clinic-info {
    padding: 0 15px;
}

    .clinic-info h1 {
        margin: 0;
        color: var(--primary-color);
        font-size: 24px;
        text-transform: uppercase;
    }

    .clinic-info p {
        margin: 2px 0;
        font-size: 13px;
        color: var(--text-light);
    }

.invoice-label h2 {
    margin: 0;
    color: var(--accent-color);
    font-size: 32px;
    text-align: end;
}

/* Logo Box */
.logo-container {
    width: 80px;
    height: 80px;
    border: 2px solid #1d3557;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Details Grid */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.section-title {
    font-size: 12px;
    font-weight: bold;
    color: var(--accent-color);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.text-size {
    font-size: 15px;
    font-weight: bolder !important;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

th {
    background-color: #f8f9fa;
    color: var(--primary-color);
    text-align: start;
    padding: 12px;
    font-size: 14px;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}


/* 1. The outer wrapper that pushes the box to the side */
.summary-container {
    display: flex;
    grid-template-columns: 1fr 70%;
    justify-content: flex-end; /* Right side for LTR */
    margin-top: 30px;
}

/* 2. The inner box with a fixed width */
.summary-table {
    width: 350px;
}

    /* 3. The row logic - 3 columns: Label | USD | IQD */
    .summary-table div {
        display: grid;
        grid-template-columns: 150px 1fr;
        gap: 10px;
        padding: 5px 0;
        align-items: center;
    }

    /* 4. Text alignment: 'start' and 'end' handle RTL automatically */
    .summary-table span:first-child {
        text-align: start; /* Left in LTR, Right in RTL */
        font-weight: bold;
        color: var(--primary-color);
    }

    .summary-table span:not(:first-child) {
        text-align: end; /* Right in LTR, Left in RTL */
        font-weight: bold;
    }

/* 5. Special Row Styles */
.total-row-border {
    border-top: 2px solid var(--primary-color);
    margin-top: 5px;
    padding-top: 10px !important;
}

/* --- RTL OVERRIDE --- */
html[dir="rtl"] .summary-container {
    justify-content: flex-start; /* Pushes box to the Left for Arabic */
}

/* Force the grid to stay Label | USD | IQD even in RTL */
html[dir="rtl"] .summary-table div {
    grid-template-columns: 1fr 100px 100px;
}


.text-success {
    color: #28a745;
}

.text-danger {
    color: #dc3545;
}

footer {
    position: absolute;
    bottom: 20mm;
    left: 20mm;
    right: 20mm;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    text-align: center;
}

    footer p {
        font-size: 11px;
        color: var(--text-light);
        margin: 3px 0;
    }


/* Global RTL Support */
html[dir="rtl"] {
    direction: rtl;
}

    html[dir="rtl"] .summary-container {
        justify-content: flex-start;
    }
