/* =========================================================
   CALCULATOR PAGE
========================================================= */
.page-container {
    width: min(1600px, calc(100% - 30px));
}
.calculator-page {
    direction: rtl;
}

option {
    color: #000;
}

/* =========================================================
   HEADER
========================================================= */

.calculator-container {
    padding-top: 30px;
    padding-bottom: 80px;
}

.calculator-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 25px;
    padding: 25px;
    margin-bottom: 22px;
}

.calculator-title {
    text-align: right;
}

.calculator-title h1 {
    margin: 8px 0;
    font-size: clamp(1.8rem, 3vw, 3rem);
    color: var(--text-primary, var(--text));
}

.calculator-title p {
    color: var(--muted);
    max-width: 700px;
    line-height: 2;
    margin: 0;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-size: x-large;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}


/* =========================================================
   SECTIONS
========================================================= */

.calculator-section {
    padding: 24px;
    margin-bottom: 22px;
}

.calculator-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
}

.section-kicker {
    color: var(--accent);
    font-size: 16px;
    display: block;
    margin-bottom: 10px;
    text-align: start;
}

.calculator-section-head h2,
.product-form-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.section-icon,
.product-form-header>i {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: var(--accent);
    background:
        radial-gradient(circle,
            rgba(215, 179, 106, .18),
            transparent 70%);
    border: 1px solid rgba(215, 179, 106, .22);
    font-size: 20px;
}


/* =========================================================
   FORMS
========================================================= */

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--color-text-soft, var(--muted));
    font-size: 14px;
}

.form-label small {
    opacity: .65;
    font-size: 12px;
}

.form-input {
    width: 100%;
    min-height: 45px;
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 0 13px;
    outline: none;
    color: var(--text);
    background:
        linear-gradient(135deg,
            rgba(255, 255, 255, .075),
            rgba(255, 255, 255, .025));

    transition:
        border-color .25s ease,
        box-shadow .25s ease,
        transform .25s ease,
        background .25s ease;
}

textarea.form-input {
    padding-top: 10px;
    padding-bottom: 10px;

    resize: vertical;
}

.form-input:hover {
    border-color: rgba(215, 179, 106, .35);
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow:
        0 0 0 3px rgba(215, 179, 106, .08),
        0 10px 35px rgba(0, 0, 0, .15);
    background:
        linear-gradient(135deg,
            rgba(215, 179, 106, .08),
            rgba(255, 255, 255, .035));
}

.form-input::placeholder {
    color: rgba(255, 255, 255, .35);
}

.input-with-unit {
    position: relative;
}

.input-with-unit .form-input {
    padding-left: 45px;
}

.input-with-unit>span {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    font-size: 12px;
}


/* =========================================================
   PRODUCT TABS
========================================================= */

.product-calculator-section {
    display: grid;
    gap: 18px;
}

.calculator-tabs {
    display: flex;
    gap: 8px;
    padding: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.calculator-tabs::-webkit-scrollbar {
    display: none;
}

.calculator-tab {
    min-height: 48px;
    padding: 0 18px;
    border-radius: 13px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition:
        color .25s ease,
        background .25s ease,
        border-color .25s ease,
        transform .25s ease;
}

.calculator-tab:hover {
    color: var(--text);
    transform: translateY(-2px);
    background: rgba(255, 255, 255, .05);
}

.calculator-tab.active {
    color: #18120b;
    background:
        linear-gradient(110deg,
            #bd873d,
            #efc979 52%,
            #c68e42);
    border-color: rgba(255, 226, 169, .35);
    box-shadow:
        0 8px 25px rgba(190, 133, 58, .18);
}


/* =========================================================
   PRODUCT PANEL
========================================================= */

.product-form-panel {
    display: none;
    padding: 25px;
    animation: calculatorFadeIn .4s ease forwards;
}

.product-form-panel.active {
    display: block;
}

@keyframes calculatorFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }

}


/* =========================================================
   PRODUCT HEADER
========================================================= */

.product-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}


/* =========================================================
   MEASUREMENT
========================================================= */

.pricing-base-grid {
    margin-bottom: 25px;
}

.measurement-section {
    margin-top: 20px;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, .075);
    border-radius: 18px;
    background:
        linear-gradient(145deg,
            rgba(255, 255, 255, .045),
            rgba(255, 255, 255, .015));
    transition:
        border-color .25s ease,
        transform .25s ease;
}

.measurement-section:hover {
    border-color: rgba(215, 179, 106, .2);
    transform: translateY(-1px);
}

.measurement-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 14px;
}

.measurement-header h3 {
    margin: 0;
    color: var(--text);
    font-size: 18px;
}

.measurement-header span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 14px;
}


/* =========================================================
   BUTTONS
========================================================= */

.small-add-btn {
    min-height: 38px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 11px;
    color: var(--accent);
    border: 1px solid rgba(215, 179, 106, .25);
    background: rgba(215, 179, 106, .07);
    cursor: pointer;
    transition: transform .2s ease, background .2s ease, border-color .2s ease;
}

.small-add-btn:hover {
    transform: translateY(-2px);
    background: rgba(215, 179, 106, .14);
    border-color: rgba(215, 179, 106, .45);
}

.calculate-button {
    width: 100%;
    min-height: 52px;
    margin-top: 25px;
    border: 1px solid rgba(255, 226, 169, .35);
    border-radius: 14px;
    color: #18120b;
    font-weight: 700;
    background: linear-gradient(110deg, #bd873d, #efc979 52%, #c68e42);
    box-shadow: 0 10px 30px rgba(190, 133, 58, .18);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
}

.calculate-button:hover {
    transform: translateY(-3px);
    filter: brightness(1.06);
    box-shadow: 0 15px 40px rgba(190, 133, 58, .3);
}


/* =========================================================
   DYNAMIC ROWS
========================================================= */

.dynamic-rows {
    display: grid;
    gap: 10px;
}

.dynamic-row {
    display: grid;
    grid-template-columns: 1.1fr .7fr .8fr .8fr .8fr 45px;
    gap: 9px;
    padding: 11px;
    border: 1px solid rgba(255, 255, 255, .065);
    border-radius: 14px;
    background: rgba(255, 255, 255, .025);
    animation: rowEnter .3s ease forwards;
}

@keyframes rowEnter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.99);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

}

.row-field {
    min-width: 0;
}

.row-field label {
    display: block;
    color: rgba(255, 255, 255, .55);
    font-size: 14px;
    margin-bottom: 5px;
}

.row-field input,
.row-field select {
    width: 100%;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 10px;
    outline: none;
    padding: 0 9px;
    color: var(--text);
    background: rgba(0, 0, 0, .15);
}

.remove-row-btn {
    width: 40px;
    height: 40px;
    align-self: end;
    border: 1px solid rgba(255, 100, 100, .18);
    border-radius: 10px;
    color: #ff8585;
    background: rgba(255, 80, 80, .05);
    cursor: pointer;
    transition: .2s ease;
}

.remove-row-btn:hover {
    background: rgba(255, 80, 80, .14);
    transform: scale(1.05);
}


/* =========================================================
   STANDARD PRODUCT ROW
========================================================= */

.standard-row {
    grid-template-columns: 1fr 1fr 1.3fr 45px;
}

.other-row {
    grid-template-columns: 1fr 1fr 45px;
}


/* =========================================================
   INVOICE
========================================================= */

.invoice-result-section {
    margin-top: 30px;
    animation: invoiceEnter .6s ease forwards;
}

@keyframes invoiceEnter {
    from {
        opacity: 0;
        transform: translateY(25px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }

}

.invoice-result-section.hidden {
    display: none;
}

.invoice-paper {
    color: #171717;
    background: #fff;
    border-radius: 18px;
    padding: 35px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, .35);
    direction: rtl;
}

.invoice-header {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    gap: 20px;
    padding-bottom: 22px;
    border-bottom: 2px solid #222;
}

.invoice-store {
    font-size: 22px;
    font-weight: 800;
}

.invoice-store {
    text-align: center;
}

.invoice-title h2 {
    margin: 0;
    font-size: 24px;
    color: #666;
}

.invoice-title span {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 11px;
}

.invoice-number {
    text-align: left;
    font-size: 12px;
}

.invoice-customer {
    /* display: grid;
    grid-template-columns: repeat(3, 1fr); */
    display: flex;
    justify-content: space-around;

    gap: 12px;
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 10px;
}

.invoice-customer-item strong {
    display: block;
    font-size: 10px;
    color: #666;
    margin-bottom: 5px;
}

.invoice-customer-item span {
    font-size: 13px;
    font-weight: 600;
}


/* =========================================================
   INVOICE TABLE
========================================================= */
.invoice-table-wrapper {
    margin-top: 22px;
    overflow-x: auto;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.invoice-table th,
.invoice-table td {
    padding: 10px 8px;
    border: 1px solid #ccc;
    text-align: center;
    vertical-align: middle;
}

.invoice-table th {
    background: #eee;
    font-weight: 800;
}

.invoice-table td {
    background: #fff;
}


/* =========================================================
   INVOICE TOTAL
========================================================= */

.invoice-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 420px;
    margin-top: 22px;
    margin-right: auto;
}

.invoice-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 14px;
    border-bottom: 1px solid #ddd;
    font-size: 12px;
}

.invoice-summary-row.total {
    margin-top: 8px;
    border: 2px solid #222;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 800;
}

.invoice-summary-row.advance {
    background: #f3f3f3;
}

.invoice-summary-row.remaining {
    background: #e8e8e8;
    font-weight: 800;
}

.invoice-expiry {
    margin-top: 18px;
    padding: 12px;
    border: 1px solid #bbb;
    border-radius: 8px;
    font-size: 11px;
}


/* =========================================================
   MODAL
========================================================= */

.invoice-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.invoice-modal.active {
    display: flex;
}

.invoice-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .72);
    backdrop-filter: blur(8px);
}

.invoice-modal-content {
    position: relative;
    z-index: 1;
    width: min(900px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    padding: 25px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: linear-gradient(145deg, rgba(25, 25, 25, .97), rgba(10, 10, 10, .96));
    box-shadow: 0 30px 100px rgba(0, 0, 0, .55);
    animation: modalEnter .3s ease;
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(.96) translateY(15px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }

}

.invoice-modal-close {
    position: sticky;
    top: 0;
    margin-right: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .06);
    cursor: pointer;
}


/* =========================================================
   PRINT
========================================================= */

@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    body {
        background: white !important;
        color: #000 !important;
    }

    body * {
        visibility: hidden !important;
    }

    #invoiceResult,
    #invoiceResult * {
        visibility: visible !important;
    }

    #invoiceResult {
        position: absolute;
        inset: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        display: block !important;
    }

    .invoice-paper {
        width: 100%;
        box-shadow: none;
        border: none;
        padding: 0;
        border-radius: 0;
    }

    .invoice-print-actions {
        display: none !important;
    }

    .invoice-table th {
        background: #eee !important;
        color: #000 !important;
    }

    .invoice-table td {
        color: #000 !important;
        background: white !important;
    }

    .invoice-header,
    .invoice-customer,
    .invoice-table,
    .invoice-summary,
    .invoice-expiry {
        color: #000 !important;
    }

}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1100px) {

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dynamic-row {
        grid-template-columns: repeat(3, 1fr);
    }

    .remove-row-btn {
        align-self: center;
    }

}


@media (max-width: 760px) {
    .calculator-header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions>* {
        flex: 1;
    }

    .calculator-tabs {
        justify-content: flex-start;
    }

    .product-form-panel,
    .calculator-section {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group-full {
        grid-column: auto;
    }

    .dynamic-row {
        grid-template-columns: 1fr 1fr;
        padding: 12px;
    }

    .dynamic-row .remove-row-btn {
        width: 100%;
        grid-column: 1 / -1;
    }

    .standard-row {
        grid-template-columns: 1fr;
    }

    .other-row {
        grid-template-columns: 1fr;
    }

    .invoice-header {
        /* grid-template-columns: 1fr; */
        text-align: center;
    }

    .invoice-number {
        text-align: center;
    }

    .invoice-customer {
        grid-template-columns: 1fr;
    }

}


@media (max-width: 480px) {
    .calculator-container {
        width: calc(100% - 12px);
    }

    .calculator-title h1 {
        font-size: 1.6rem;
    }

    .measurement-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .small-add-btn {
        width: 100%;
    }

    .calculator-tab {
        flex: 1;
        min-width: 125px;
    }

    .invoice-paper {
        padding: 15px;
    }

}