/* Explain: Styles for the invoice page, including header, customer/store info, item table, totals, footer, and print view. */
/* ---------- Invoice page ---------- */
.invoice-page {
    max-width: 840px;
}

.invoice-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.invoice-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.invoice-paper {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.inv-sheet {
    padding: clamp(1.25rem, 3.5vw, 2.25rem);
    color: var(--text-color);
}

.inv-sheet[contenteditable="true"] {
    outline: 2px dashed var(--primary-color);
    outline-offset: 8px;
}

/* ---------- Header ---------- */
.inv-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);
}

.inv-brand {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.inv-brand-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--primary-color);
}

.inv-brand-sub {
    font-family: var(--font-display);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: var(--text-muted);
}

.inv-meta {
    display: grid;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: end;
}

.inv-meta b {
    color: var(--text-color);
}

.inv-title-row {
    margin-top: 1.1rem;
    text-align: center;
}

.inv-title-row h1 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(1.3rem, 4vw, 1.55rem);
    font-weight: 800;
    color: var(--text-color);
}

.inv-title-row p {
    margin: 0.35rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ---------- Info boxes ---------- */
.inv-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
    margin-top: 1.1rem;
}

.inv-box {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-color);
}

.inv-box-title {
    background: var(--secondary-color);
    color: var(--primary-hover);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.82rem;
    padding: 0.6rem 0.85rem;
}

.inv-box-body {
    display: grid;
    gap: 0.45rem;
    padding: 0.85rem;
}

.inv-line {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.6rem;
    font-size: 0.8rem;
}

.inv-line span {
    flex-shrink: 0;
    color: var(--text-muted);
}

.inv-line b {
    color: var(--text-color);
    font-weight: 700;
    text-align: end;
    word-break: break-word;
}

/* ---------- Items table ---------- */
.inv-table-wrap {
    margin-top: 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
}

.inv-table th {
    background: var(--secondary-color);
    color: var(--primary-hover);
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 0.76rem;
    padding: 0.7rem 0.5rem;
    text-align: center;
}

.inv-table td {
    padding: 0.7rem 0.5rem;
    font-size: 0.8rem;
    color: var(--text-color);
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.inv-table td.prod {
    text-align: start;
    font-weight: 700;
}

/* ---------- Totals ---------- */
.inv-totals {
    display: grid;
    gap: 0.45rem;
    margin-top: 1.1rem;
}

.inv-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--field-bg);
    font-size: 0.82rem;
    color: var(--text-muted);
}

.inv-total-row b {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.92rem;
    color: var(--text-color);
}

.inv-total-row.grand {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: rgba(255, 255, 255, 0.85);
    font-weight: 800;
}

.inv-total-row.grand b {
    color: #ffffff;
    font-size: 1.05rem;
}

.inv-total-row .riyal,
.inv-line .riyal,
.inv-table .riyal {
    font-size: 1.05em;
}

/* ---------- Footer ---------- */
.inv-foot {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.4rem;
    padding-top: 1.1rem;
    border-top: 1px dashed var(--border-color);
}

.inv-stamp {
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    padding: 0.55rem 1rem;
    color: var(--primary-color);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.82rem;
    line-height: 1.4;
    text-align: center;
}

.inv-stamp span {
    display: block;
    font-size: 0.62rem;
    font-weight: 600;
    opacity: 0.75;
}

.inv-thanks {
    max-width: 24rem;
    font-size: 0.8rem;
    line-height: 1.85;
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .invoice-page {
        max-width: 100%;
    }

    .invoice-toolbar-actions {
        width: 100%;
    }

    .invoice-toolbar-actions > * {
        flex: 1 1 auto;
    }

    .inv-cols {
        grid-template-columns: 1fr;
    }

    .inv-meta {
        text-align: start;
    }
}

/* ---------- Print ---------- */
@media print {
    @page {
        size: A4;
        margin: 12mm;
    }

    html,
    body {
        background: #ffffff !important;
    }

    .site-header,
    .site-footer,
    .back-to-top,
    .wa-float,
    .cart-drawer,
    .nav-overlay,
    .no-print {
        display: none !important;
    }

    .section {
        padding-top: 0 !important;
    }

    .wrap.invoice-page {
        max-width: 100% !important;
        padding: 0 !important;
    }

    .invoice-paper {
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .inv-sheet {
        padding: 0 !important;
    }

    .inv-box-title,
    .inv-table th,
    .inv-total-row.grand,
    .inv-stamp {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}