/* ----------------------------------------------------
   1. Design Tokens & System Variables
   ---------------------------------------------------- */
:root {
    --primary-blue: #1e3b6e;
    --primary-gold: #c59b27;
    --dark-gold: #947116;
    --bg-parchment: #f9f6ef;
    --paper-border: #bca885;
    --text-dark: #1a1a1a;
    --text-muted: #4b5563;
    --table-header-bg: #1e293b;
    --table-header-text: #ffffff;
    --border-color: #000000;
    
    --font-arabic: 'Tajawal', sans-serif;
    --font-serif: 'Amiri', serif;
}

/* ----------------------------------------------------
   2. Base Setup
   ---------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-arabic);
    background-color: #334155;
    color: var(--text-dark);
    direction: rtl;
    line-height: 1.35;
    min-height: 100vh;
    padding-bottom: 40px;
}

/* ----------------------------------------------------
   3. Admin Control Bar
   ---------------------------------------------------- */
.admin-control-bar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #0f172a;
    color: #ffffff;
    padding: 12px 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border-bottom: 2px solid var(--primary-gold);
}

.control-bar-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.brand-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: #f8fafc;
}

.control-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-family: var(--font-arabic);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease-in-out;
}

.btn-add { background-color: #10b981; color: #ffffff; }
.btn-add:hover { background-color: #059669; }

.btn-regenerate { background-color: #3b82f6; color: #ffffff; }
.btn-regenerate:hover { background-color: #2563eb; }

.btn-reset { background-color: #ef4444; color: #ffffff; }
.btn-reset:hover { background-color: #dc2626; }

.btn-print {
    background-color: var(--primary-gold);
    color: #0f172a;
    box-shadow: 0 2px 8px rgba(197, 155, 39, 0.4);
}
.btn-print:hover {
    background-color: #d9a82e;
    transform: translateY(-1px);
}

.btn-export-pdf {
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}
.btn-export-mobile {
    background-color: #0284c7;
}
.btn-export-mobile:hover {
    background-color: #0369a1;
    transform: translateY(-1px);
}
.btn-export-desktop {
    background-color: #475569;
    box-shadow: 0 2px 8px rgba(71, 85, 105, 0.4);
}
.btn-export-desktop:hover {
    background-color: #334155;
    transform: translateY(-1px);
}
.btn-export-pdf:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none !important;
}

@media (max-width: 700px) {
    .control-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    .btn-export-pdf {
        min-width: 132px;
        justify-content: center;
    }
}

/* ----------------------------------------------------
   4. Document Preview Container & Pages Layout
   ---------------------------------------------------- */
.document-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    margin-top: 30px;
}

.a4-page {
    width: 210mm;
    height: 297mm;
    min-height: 297mm;
    max-height: 297mm;
    background: url('https://i.postimg.cc/Bbs40NJc/alkhlfyt.jpg') no-repeat center center / 100% 100% !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    page-break-after: always;
    page-break-inside: avoid;
    break-after: page;
    break-inside: avoid;
}

/* ----------------------------------------------------
   5. Top Header & Brand Styling
   ---------------------------------------------------- */
.doc-header-fixed {
    position: absolute;
    top: 5mm;
    left: 14mm;
    right: 14mm;
    height: 26mm;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.company-brand {
    text-align: center;
}

.company-title {
    display: block;
    width: 100%;
    font-family: var(--font-arabic) !important;
    font-size: 2.15rem;
    font-weight: 900;
    color: var(--primary-blue);
    line-height: 1.2;
    margin: 0 auto 2px;
    letter-spacing: normal !important;
    direction: rtl;
    text-align: center !important;
    text-align-last: center !important;
}

.company-sub {
    font-family: var(--font-arabic) !important;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-blue);
    line-height: 1.25;
}

.company-logo {
    position: absolute;
    left: 0;
    top: 0;
    width: 95px;
    height: 95px;
}

.official-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.18));
}

/* ----------------------------------------------------
   6. Inner Document Body Layout
   ---------------------------------------------------- */
.doc-inner-body {
    position: absolute;
    top: 40mm; 
    bottom: 16mm;
    left: 14mm;
    right: 14mm;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
}

.content-block {
    width: 100%;
}

.doc-title-bar {
    text-align: center;
    margin: 0 0 8px 0;
}

.doc-title {
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--primary-blue);
    display: inline-block;
    padding-bottom: 1px;
    border-bottom: 2px solid var(--primary-blue);
}

.doc-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 10px;
    padding: 0 2px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.meta-label {
    color: var(--text-dark);
}

.editable-field {
    background: transparent;
    border: 1px dashed transparent;
    font-family: var(--font-arabic) !important;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    padding: 1px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.editable-field:hover, .editable-field:focus {
    background-color: rgba(255, 255, 255, 0.85);
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.meta-input {
    width: 140px;
    font-weight: 700;
}

.client-section {
    margin-bottom: 10px;
    padding: 0 2px;
}

.client-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 3px;
}

.client-input {
    flex: 1;
    min-width: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--primary-blue);
    text-align: center !important;
    text-align-last: center !important;
    direction: rtl;
    font-family: var(--font-arabic) !important;
}

.greeting-text {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-align: center;
}

.intro-text {
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.35;
}

/* ----------------------------------------------------
   7. Tables & Pricing Grid
   ---------------------------------------------------- */
.items-table-section {
    margin-bottom: 0px;
}

.quote-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0px;
    font-size: 0.78rem;
    text-align: center;
    table-layout: fixed;
}

.quote-table th {
    background-color: #3d3010;
    color: #e8c84a;
    padding: 4px 1px;
    border: 1px solid #2a1f00;
    font-weight: 800;
    font-size: 0.65rem;
    line-height: 1.15;
    white-space: normal !important;
    word-break: break-word !important;
    overflow: visible;
}

.en-head {
    font-size: 0.58rem;
    font-weight: 400;
    display: block;
    color: #d4a827;
}

.statement-input {
    display: block;
    width: 100%;
    min-height: 0;
    height: auto;
    resize: none;
    overflow: hidden;
    padding: 0 !important;
    margin: 0;
    border: 0 !important;
    line-height: 1.2;
    font-family: var(--font-arabic);
    font-size: inherit;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.quote-table tbody tr:nth-child(odd) td {
    border: 1px solid #b8960c;
    padding: 2px 2px;
    vertical-align: middle;
    background-color: rgba(255, 253, 235, 0.85);
    font-weight: 700;
    color: #1a1a1a;
}

.quote-table tbody tr:nth-child(even) td {
    border: 1px solid #b8960c;
    padding: 2px 2px;
    vertical-align: middle;
    background-color: rgba(218, 172, 20, 0.18);
    font-weight: 700;
    color: #1a1a1a;
}

.quote-table td, 
.table-select, 
.car-type-input {
    white-space: normal !important;
    word-break: break-word !important;
}

.total-cell, .price-cell {
    white-space: nowrap !important;
    font-size: 10px !important;
    letter-spacing: -0.3px;
    overflow: visible !important;
}

.table-input {
    width: 100%;
    text-align: center;
    font-size: 0.78rem;
    box-sizing: border-box;
}

.table-select {
    width: 100%;
    text-align: center;
    text-align-last: center;
    background: transparent;
    border: 1px dashed transparent;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
}
.table-select:hover, .table-select:focus {
    background: #ffffff;
    border-color: #3b82f6;
}

.car-type-select {
    width: 100%;
    font-size: 0.74rem;
    font-weight: 700;
    font-family: inherit;
    text-align: center;
    text-align-last: center;
    background: transparent;
    border: 1px dashed transparent;
    color: inherit;
    padding: 2px 0;
    cursor: pointer;
}
.car-type-select:hover, .car-type-select:focus {
    background: #ffffff;
    border-color: #3b82f6;
}

.custom-car-input-group {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
}
.car-type-input {
    flex: 1;
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
}
.btn-toggle-select {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 0.72rem;
    padding: 1px 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-del-row {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin: 0 auto;
}
.btn-del-row:hover { background: #dc2626; }

/* ----------------------------------------------------
   8. Totals & Stamp Wrapper Section
   ---------------------------------------------------- */
#quote-summary-and-stamp {
    width: 100%;
}

.totals-summary-container {
    display: flex;
    justify-content: center;
    margin-top: -1px;
    width: 100%;
}

.totals-table {
    border-collapse: collapse;
    width: 100%;
    max-width: 500px;
    font-size: 0.85rem;
    font-weight: 800;
    table-layout: auto;
}

.totals-table td {
    border: 1px solid #b8960c;
    padding: 5px 12px;
}

.total-label {
    background-color: #3d3010;
    color: #e8c84a;
    font-weight: 800;
    text-align: center;
    width: 60%;
}

.total-value {
    background-color: rgba(255, 253, 235, 0.9);
    direction: ltr;
    font-family: sans-serif;
    color: #1a1a1a;
    text-align: center;
    white-space: nowrap;
    width: 40%;
}

.grand-total-row .total-label {
    background-color: #5a4a1e;
    color: #f0d060;
}

.grand-total-row .total-value {
    background-color: rgba(218, 172, 20, 0.25);
    font-size: 0.9rem;
    font-weight: 900;
    white-space: nowrap;
}

.riyal-symbol {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
}

.closing-section-wrapper {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.closing-wish {
    text-align: center;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.closing-salutation-bottom {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.salutation-text {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 4px;
    text-align: center;
}

.company-sign-wrapper {
    display: inline-block;
    text-align: center;
    position: relative;
}

.company-sign-title {
    font-size: 0.95rem;
    font-weight: 900;
    color: var(--text-dark);
}

.official-stamp-box {
    margin-top: 2px;
    width: 140px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.official-stamp-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

/* الملاحظات والشروط المترجمة أسفل الختم (ضبط اتجاه العربي للجهة اليمنى والإنجليزي لليسار) */
.terms-translation-container {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 10px;
    width: 100%;
    direction: rtl; /* وضع الاتجاه العام لليمين لتوافق العربية يمين والإنجليزي يسار */
}

.terms-box {
    width: 49%;
    font-size: 0.78rem;
}

.terms-box strong {
    display: block;
    margin-bottom: 3px;
    color: var(--primary-blue);
}

.ar-box {
    text-align: right;
    direction: rtl;
}

.en-box {
    text-align: left;
    direction: ltr;
}

.terms-box textarea {
    width: 100%;
    height: 60px;
    resize: none;
    font-size: 0.68rem;
    line-height: 1.25;
    background: rgba(255, 255, 255, 0.6);
    border: 1px dashed #b8960c;
    border-radius: 4px;
    padding: 4px;
    box-sizing: border-box;
}

.terms-box textarea:focus {
    background: #ffffff;
    border-style: solid;
    border-color: #3b82f6;
}

/* ----------------------------------------------------
   9. Terms & Bank Section
   ---------------------------------------------------- */
.terms-section {
    margin-top: 0px;
    font-size: 0.74rem;
    line-height: 1.3;
}

.bilingual-terms-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
}

.terms-col-ar { text-align: right; }
.terms-col-en { text-align: left; font-family: sans-serif; }

.terms-title, .terms-title-en {
    font-size: 0.85rem;
    font-weight: 800;
    margin-bottom: 3px;
    color: var(--text-dark);
}

.term-unit { margin-bottom: 4px; }
.term-ar-head, .term-en-head { font-weight: 800; color: var(--text-dark); }
.term-ar-text, .term-en-text { margin-top: 1px; }

.term-list-ar, .term-list-en { list-style-type: none; }
.term-list-ar { padding-right: 4px; }
.term-list-en { padding-left: 4px; }

.term-list-ar li::before, .term-list-en li::before {
    content: "• ";
    font-weight: bold;
}

.bank-details-section {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    padding: 0 2px;
}

/* Banking table: Arabic account labels on the right, their values on the left. */
.bank-table {
    direction: rtl !important;
    table-layout: fixed;
}
.bank-table tr > .bank-label,
.bank-table tr > td.bank-label {
    text-align: right !important;
    direction: rtl !important;
}
.bank-table tr > .bank-value,
.bank-table tr > td.bank-value {
    text-align: left !important;
    direction: ltr;
    unicode-bidi: plaintext;
    overflow-wrap: anywhere;
}
#pdf-export-stage .bank-table {
    direction: rtl !important;
}
#pdf-export-stage .bank-table .bank-label {
    text-align: right !important;
    direction: rtl !important;
}
#pdf-export-stage .bank-table .bank-value {
    text-align: center !important;
    vertical-align: middle !important;
}
.bank-table .bank-value {
    text-align: center !important;
    vertical-align: middle !important;
}
.bank-table .bank-label {
    vertical-align: middle !important;
}
.bank-table {
    border-collapse: collapse;
    width: 60%;
    font-size: 0.82rem;
    font-weight: 800;
}

.bank-table td {
    border: 1px solid #b8960c;
    padding: 5px 12px;
}

.bank-label {
    background-color: #3d3010;
    color: #e8c84a;
    font-weight: 800;
    width: 32%;
    text-align: center;
    padding: 5px;
}

.bank-value {
    background-color: rgba(255, 253, 235, 0.9);
    text-align: center;
    padding: 5px;
    color: #1a1a1a;
}
.font-bold { font-weight: 800; }
.font-en { font-family: sans-serif; font-weight: 700; direction: ltr; }

/* ----------------------------------------------------
   10. Fixed Bottom Footer
   ---------------------------------------------------- */
.doc-footer-fixed {
    position: absolute;
    bottom: 5mm;
    left: 14mm;
    right: 14mm;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary-blue);
    z-index: 10;
    page-break-inside: avoid;
    break-inside: avoid;
}

.footer-content {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.footer-sep {
    width: 1px;
    height: 12px;
    background-color: var(--primary-blue);
}

/* ----------------------------------------------------
   11. PDF Rendering Helper Classes
   ---------------------------------------------------- */
body.rendering-pdf {
    background-color: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.rendering-pdf .document-wrapper {
    margin: 0 !important;
    gap: 0 !important;
}

body.rendering-pdf .a4-page {
    box-shadow: none !important;
    margin: 0 !important;
    border: none !important;
}

/* ----------------------------------------------------
   12. Print Media Rules (@media print)
   ---------------------------------------------------- */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    html, body {
        background: #ffffff !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 210mm;
        height: 297mm;
    }

    .no-print {
        display: none !important;
    }

    .document-wrapper {
        margin: 0 !important;
        gap: 0 !important;
    }

    .a4-page {
        width: 210mm !important;
        height: 296mm !important;
        min-height: 296mm !important;
        max-height: 296mm !important;
        box-shadow: none !important;
        page-break-after: always !important;
        page-break-inside: avoid !important;
        background: url('https://i.postimg.cc/Bbs40NJc/alkhlfyt.jpg') no-repeat center center / 100% 100% !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .editable-field {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
        padding: 0 !important;
    }

    .terms-box textarea {
        border: none !important;
        background: transparent !important;
        resize: none !important;
        font-size: 0.68rem !important;
        line-height: 1.25 !important;
    }

    .statement-input {
        font-size: inherit !important;
        line-height: 1.15 !important;
        padding: 0 !important;
        margin: 0 !important;
        resize: none !important;
    }

    #page-overflow-items {
        display: none !important;
    }

    .table-select, .car-type-select {
        appearance: none !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
        font-size: 0.74rem !important;
        font-weight: 800 !important;
        color: #000000 !important;
        text-align: center !important;
        text-align-last: center !important;
        width: 100% !important;
        padding: 0 !important;
    }

    .btn-toggle-select, .row-action-col {
        display: none !important;
    }
}

/* ----------------------------------------------------
   Quote database / history UI
   ---------------------------------------------------- */
.btn-save-quote,
.btn-history {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.quote-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
}
.quote-modal.is-open { display: flex; }
.quote-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(3px);
}
.quote-modal-card {
    position: relative;
    width: min(1180px, 100%);
    max-height: min(88vh, 900px);
    overflow: hidden;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0,0,0,.28);
    direction: rtl;
    display: flex;
    flex-direction: column;
}
.quote-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.quote-modal-head h2 { margin: 0; font-size: 1.25rem; }
.quote-device-summary { margin-top: 5px; color: #64748b; font-size: .85rem; }
.quote-modal-close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: #f1f5f9;
    font-size: 25px;
    cursor: pointer;
}
.quote-history-toolbar {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.quote-history-toolbar input {
    flex: 1;
    min-width: 0;
    padding: 11px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-family: inherit;
    font-size: .95rem;
}
.btn-history-refresh {
    border: 0;
    border-radius: 10px;
    padding: 0 16px;
    cursor: pointer;
    background: var(--primary-blue);
    color: #fff;
    font-family: inherit;
}
.quote-history-status { padding: 10px 20px; color: #64748b; font-size: .85rem; }
.quote-history-table-wrap { overflow: auto; padding: 0 20px 20px; }
.quote-history-table { width: 100%; border-collapse: collapse; min-width: 850px; }
.quote-history-table th,
.quote-history-table td { padding: 10px 9px; border-bottom: 1px solid #e5e7eb; text-align: right; white-space: nowrap; }
.quote-history-table th { background: #f8fafc; position: sticky; top: 0; z-index: 1; }
.quote-history-action { display: flex; gap: 6px; }
.quote-history-action button {
    border: 0;
    border-radius: 8px;
    padding: 7px 9px;
    cursor: pointer;
    font-family: inherit;
}
.quote-history-open { background: #e2e8f0; }
.quote-history-delete { background: #fee2e2; color: #991b1b; }
.quote-history-pdf { background: #dbeafe; color: #1d4ed8; }
.quote-history-no-pdf { display: inline-flex; align-items: center; padding: 7px 9px; border-radius: 8px; background: #f1f5f9; color: #64748b; font-size: .78rem; }
.quote-history-empty { text-align: center !important; color: #94a3b8; padding: 30px !important; }

@media (max-width: 700px) {
    .quote-modal { padding: 8px; }
    .quote-modal-card { max-height: 94vh; border-radius: 12px; }
    .quote-history-toolbar { flex-direction: column; }
    .btn-history-refresh { min-height: 42px; }
}

.btn-manager { background: #334155; color: #fff; }
.manager-only[hidden] { display: none !important; }
.manager-login-card { max-width: 460px; }
.manager-login-form { padding: 20px; display: grid; gap: 14px; }
.manager-login-form label { display: grid; gap: 7px; font-weight: 700; color: #334155; }
.manager-login-form input { width: 100%; border: 1px solid #cbd5e1; border-radius: 10px; padding: 11px 12px; font: inherit; box-sizing: border-box; }
.manager-login-form input:focus { outline: 2px solid #94a3b8; border-color: #64748b; }
.manager-logout { background: #f1f5f9; color: #334155; }
.quote-history-edit { background: #dcfce7; color: #166534; }


/* Revised quotation table */
.statement-input {
    display:block;
    width:100%;
    min-height:42px;
    height:42px;
    box-sizing:border-box;
    padding:4px 6px;
    resize:vertical;
    overflow:hidden;
    white-space:pre-wrap !important;
    text-align:right;
    line-height:1.3;
    font:inherit;
}
.bank-details-section { margin-top:6px; padding:0; }
.bank-table { width:82%; font-size:0.68rem; }
.bank-table td { padding:2px 7px; }
@media print {
  .statement-input {
    height:auto !important;
    min-height:0 !important;
    resize:none !important;
    overflow:visible !important;
    border:0 !important;
    background:transparent !important;
    box-shadow:none !important;
    padding:0 !important;
  }
}


/* Final layout refinements */
.bank-details-section {
    display: grid !important;
    grid-template-columns: 1fr minmax(0, 2fr) 1fr;
    align-items: center;
    justify-items: stretch;
    gap: 10px;
    width: 100%;
    margin-top: auto;
    padding: 8px 12px 12px;
    box-sizing: border-box;
    direction: ltr;
}
.bank-details-section .bank-table {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    justify-self: center;
}
.bank-details-section .bank-stamp-box {
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
    align-self: center;
    margin: 0;
}
.bank-details-section .bank-stamp-box .official-stamp-img {
    max-width: 115px;
    max-height: 95px;
    object-fit: contain;
}
.terms-box textarea {
    height: auto;
    min-height: 60px;
    overflow-y: hidden;
    resize: none;
    white-space: pre-wrap;
}
@media print {
    .bank-details-section { margin-top: auto; }
}
@media (max-width: 700px) {
    .bank-details-section {
        grid-template-columns: 1fr minmax(0, 2fr) 1fr;
        gap: 5px;
        padding-left: 4px;
        padding-right: 4px;
    }
    .bank-details-section .bank-stamp-box .official-stamp-img {
        max-width: 76px;
        max-height: 76px;
    }
    .bank-table { font-size: 0.62rem; }
    .bank-table td { padding: 2px 4px; }
}


/* Inline add-item control and clear calculation columns */
.add-item-table-row td {
    text-align: right;
    padding: 5px 8px;
    border-top: 1px dashed #b8960c;
}
.btn-add-inline {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: #14532d;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    padding: 4px 8px;
}
.btn-add-inline:hover { text-decoration: underline; }


/* Ensure Arabic/English notes retain every line in print */
.terms-box textarea {
    display: block;
    height: auto;
    min-height: 60px;
    overflow: hidden;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.3;
}
/* Keep the company name centered even while editing or exporting. */
.company-brand {
    width: 100%;
    min-width: 0;
    text-align: center !important;
}
.company-brand .company-title,
.company-brand input.company-title,
.company-brand [contenteditable="true"].company-title {
    display: block;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center !important;
    text-align-last: center !important;
}

/* Arabic terms must use an Arabic-capable font and connected-script shaping. */
.terms-box textarea,
.terms-print-text {
    font-family: 'Tajawal', Arial, sans-serif !important;
    font-kerning: normal;
    font-variant-ligatures: normal;
    letter-spacing: normal !important;
    word-spacing: normal;
    unicode-bidi: plaintext;
}
#pdf-export-stage .terms-print-text {
    font-family: 'Tajawal', Arial, sans-serif !important;
    direction: rtl;
    unicode-bidi: plaintext;
    text-align: right;
    letter-spacing: normal !important;
    line-height: 1.5 !important;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
}

.terms-print-text {
    display: block;
    height: auto;
    min-height: 60px;
    white-space: pre-wrap;
    overflow: visible;
    overflow-wrap: anywhere;
    line-height: 1.3;
}
@media print {
    .terms-box textarea {
        height: auto !important;
        min-height: 60px !important;
        overflow: visible !important;
        white-space: pre-wrap !important;
        overflow-wrap: anywhere !important;
        resize: none !important;
    }
}
