:root {
    /* Base (light-dark balanced) */
    --bg:           #f4f8f6;
    --surface:      #ffffff;
    --surface-2:    #ecfdf5;
    --surface-3:    #e6fff4;

    /* Borders */
    --border:       #d1fae5;
    --border-hover: #a7f3d0;
    --border-focus: #34d399;

    /* Primary (fresh green) */
    --primary:      #22c55e;
    --primary-dim:  rgba(34, 197, 94, 0.15);
    --primary-glow: rgba(34, 197, 94, 0.25);

    /* Accent colors (happy palette 🎉) */
    --accent-blue:   #38bdf8;
    --accent-purple: #a78bfa;
    --accent-pink:   #f472b6;
    --accent-yellow: #facc15;

    /* Text */
    --text:         #1f2937;
    --text-sub:     #4b5563;
    --text-muted:   #6b7280;
    --text-faint:   #9ca3af;

    /* States */
    --error:        #fb7185;
    --error-dim:    rgba(251, 113, 133, 0.15);
    --success:      #22c55e;

    /* Shape */
    --radius:       14px;
    --radius-sm:    10px;
    --radius-xs:    6px;

    /* Font & Motion */
    --font: 'Vazirmatn', system-ui, -apple-system, sans-serif;
    --ease: .2s ease;
}

--gradient-main: linear-gradient(135deg, #22c55e, #38bdf8);
--gradient-fun: linear-gradient(135deg, #a78bfa, #f472b6);
--gradient-sun: linear-gradient(135deg, #facc15, #fb7185);
--gradient-mix: linear-gradient(135deg, #22c55e, #a78bfa, #f472b6);

/* ── global base ───────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

/* ── form card ─────────────────────────────────────────────── */
.form-card {
    width: 100%;
    max-width: 1100px;
    margin: 2rem auto;
    padding: 2.25rem 2.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}

/*
 * Signature element: thin 3-colour gradient stripe at top.
 * Communicates "smart / tech" without shouting.
 */
.form-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg,
    #5b8ef0 0%,
    #a78bfa 45%,
    #34d399 100%
    );
}

.form-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .3rem;
}

.form-card > h4,
.form-card > p {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.75;
    margin-bottom: .4rem;
}

/* ── message / alert ───────────────────────────────────────── */
.message-box {
    display: none;
    padding: .65rem .9rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    direction: rtl;
}

.message-box.error {
    background: var(--error-dim);
    border: 1px solid var(--error);
    color: var(--error);
}

.message-box.success {
    background: rgba(62, 207, 142, .1);
    border: 1px solid var(--success);
    color: var(--success);
}

.message-box ul { padding-right: 1.1rem; }
.message-box li { margin-bottom: .15rem; }

/* ── two-column layout ─────────────────────────────────────── */
.form-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1.5rem;
}

.form-column-right,
.form-column-left {
    display: flex;
    flex-direction: column;
    gap: .7rem;
}

/* ── label ─────────────────────────────────────────────────── */
.form-label {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: .3rem;
    letter-spacing: .01em;
}

/* ── text inputs ───────────────────────────────────────────── */
.form-input {
    width: 100%;
    padding: .58rem .85rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    outline: none;
    transition:
        border-color var(--ease),
        box-shadow var(--ease);
    direction: rtl;
}

.form-input::placeholder {
    color: var(--text-faint);
    font-size: 1rem;
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.form-input[readonly] {
    opacity: .55;
    cursor: default;
}

/* ── select ────────────────────────────────────────────────── */
.form-select-wrapper {
    display: flex;
    flex-direction: column;
}

.form-select {
    width: 100%;
    padding: .58rem .85rem .58rem 2.1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font);
    font-size: .925rem;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    /* chevron icon on the left (RTL = logical end) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%237a8ba8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left .85rem center;
    cursor: pointer;
    transition:
        border-color var(--ease),
        box-shadow var(--ease);
    direction: rtl;
}

.form-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.form-select option {
    background: var(--surface-2);
    color: var(--text);
}

/* ── addons section ────────────────────────────────────────── */
.addons-section {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: .85rem .9rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    flex: 1;
}

.addons-title {
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    padding-bottom: .55rem;
    margin-bottom: .3rem;
    border-bottom: 1px solid var(--border);
}

.addon-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .4rem .1rem;
    border-bottom: 1px solid var(--border);
    gap: .6rem;
}

.addon-item:last-child { border-bottom: none; }

.addon-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1rem;
    color: var(--text-sub);
    cursor: pointer;
    flex: 1;
    transition: color var(--ease);
}

.addon-label:hover { color: var(--text); }


.addon-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;

    width: 18px;
    height: 18px;

    border: 2px solid var(--border-hover);
    border-radius: 5px;
    background: var(--surface);

    cursor: pointer;
    position: relative;
    flex-shrink: 0;

    transition: all var(--ease);
}

/* hover */
.addon-label input[type="checkbox"]:hover {
    border-color: var(--primary);
}

/* وقتی تیک میخوره */
.addon-label input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

/* تیک */
.addon-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;

    left: 5px;
    top: 1px;

    width: 4px;
    height: 9px;

    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* فوکوس */
.addon-label input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-dim);
}

/* ── quantity control ──────────────────────────────────────── */
.quantity-control {
    display: flex;
    align-items: center;
    gap: .3rem;
    flex-shrink: 0;
}

.quantity-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-sub);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition:
        background var(--ease),
        border-color var(--ease),
        color var(--ease);
    user-select: none;
}

.quantity-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.quantity-input {
    width: 38px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font);
    font-size: .9rem;
    padding: .25rem 0;
}

/* ── terms box ─────────────────────────────────────────────── */
.terms-box {
    margin-top: 1.25rem;
    padding: .85rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: .85rem;
    color: var(--text-muted);
    line-height: 1.85;
}

/* ── submit / edit buttons ─────────────────────────────────── */
.submit-btn {
    display: block;
    width: 100%;
    padding: .7rem 1.5rem;
    margin-top: 1.25rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-xs);
    font-family: var(--font);
    font-size: .975rem;
    font-weight: 600;
    cursor: pointer;
    transition:
        opacity var(--ease),
        box-shadow var(--ease),
        transform 80ms ease;
}

.submit-btn:hover:not(:disabled) {
    opacity: .9;
    box-shadow: 0 4px 18px var(--primary-glow);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: none;
}

.submit-btn:disabled {
    opacity: .38;
    cursor: not-allowed;
}

.edit-btn {
    display: block;
    width: 100%;
    padding: .62rem 1.5rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: var(--font);
    font-size: .925rem;
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease);
}

.edit-btn:hover {
    background: var(--surface-2);
    border-color: var(--border-hover);
}

/* ── modal ─────────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 16, .78);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem 1.5rem 1.5rem;
    width: 100%;
    max-width: 540px;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
    direction: rtl;
    /* entry animation */
    animation: modal-in .22s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.modal-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .35rem;
}

.modal-content > p {
    font-size: .88rem;
    color: var(--text-muted);
    margin-bottom: .75rem;
}

.modal-close-btn {
    position: absolute;
    top: .8rem;
    left: .8rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.modal-close-btn:hover {
    color: var(--text);
    background: var(--surface-3);
    border-color: var(--border-hover);
}

/* ── invoice ───────────────────────────────────────────────── */
.invoice-user-details {
    margin-bottom: .85rem;
    padding: .65rem .8rem;
    background: var(--surface-2);
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
}

.invoice-user-details p {
    font-size: .88rem;
    color: var(--text-muted);
    margin-bottom: .2rem;
}

.invoice-user-details p:last-child { margin-bottom: 0; }
.invoice-user-details strong { color: var(--text); font-weight: 500; }

.invoice-details {
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.invoice-header {
    padding: .55rem .8rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.invoice-header h4 {
    font-size: .83rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .87rem;
}

.invoice-table thead th {
    padding: .5rem .75rem;
    text-align: right;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.invoice-table tbody td {
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.invoice-table tbody tr:last-child td { border-bottom: none; }

.invoice-table tbody tr:hover td {
    background: var(--primary-dim);
}

.invoice-totals {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .7rem .8rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
}

.price-item {
    display: flex;
    justify-content: space-between;
    font-size: .87rem;
    color: var(--text-muted);
}

.price-total {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    padding-top: .5rem;
    margin-top: .2rem;
    border-top: 1px solid var(--border);
}

/* ── scrollbar (webkit) ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── responsive: tablet ────────────────────────────────────── */
@media (max-width: 820px) {
    .form-card {
        padding: 1.75rem 1.5rem;
    }

    .form-columns {
        gap: 1.25rem;
    }
}

/* ── responsive: mobile ────────────────────────────────────── */
@media (max-width: 640px) {
    .form-card {
        margin: 0;
        padding: 1.25rem 1rem;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    /* gradient stripe full-width on mobile */
    .form-card::before { border-radius: 0; }

    .form-columns {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-column-right { order: 1; }
    .form-column-left  { order: 2; margin-top: .85rem; }

    .form-card h2 { font-size: 1.1rem; }

    .modal-content {
        padding: 1.25rem 1rem 1rem;
    }

    .invoice-table { font-size: .82rem; }
    .invoice-table thead th,
    .invoice-table tbody td { padding: .42rem .5rem; }
}

/* ── reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
