﻿/* ────────────────────────────────
   مودال - فوق فشرده برای موبایل
   ──────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn .25s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: #fff;
    margin: auto;
    width: min(98%, 600px);
    /* استفاده از dvh برای موبایل‌های مدرن */
    max-height: min(98dvh, calc(100vh - 20px)); /* fallback برای مرورگرهای قدیمی */
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    direction: rtl;
    animation: modalSlideIn .25s ease-out;
    display: flex;
    flex-direction: column;
}


@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* هدر - فشرده */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}


    .modal-header h3 {
        margin: 0;
        font: 600 16px/1.2 'Vazir', sans-serif;
        color: #495057;
    }

.close {
    font: bold 24px/1 Arial, sans-serif;
    color: #6c757d;
    cursor: pointer;
    transition: color .2s;
}

    .close:hover {
        color: #dc3545;
    }

/* بدنه - اسکرول فقط در بدنه */
.modal-body {
    padding: 8px 10px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* مهم: جلوگیری از overflow در محیط‌های مختلف */
    min-height: 0; /* برای فعال‌کردن flex shrinking صحیح */
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 10px 10px;
    flex-shrink: 0;
}


.btn-submit,
.btn-cancel {
    flex: 1;
    min-width: 80px;
    padding: 9px 12px;
    border: none;
    border-radius: 6px;
    font: 500 13px 'Vazir', sans-serif;
    cursor: pointer;
    transition: background .2s;
}

.btn-submit {
    background: #007bff;
    color: #fff;
}

    .btn-submit:hover {
        background: #0056b3;
    }

.btn-cancel {
    background: #6c757d;
    color: #fff;
}

    .btn-cancel:hover {
        background: #545b62;
    }

/* فرم - فشرده */
.form-group {
    margin-bottom: 14px;
}

    .form-group label {
        display: block;
        margin-bottom: 4px;
        font: 500 13px 'Vazir', sans-serif;
        color: #495057;
    }

.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font: 13px/1.4 'Vazir', sans-serif;
    background: #fff;
    transition: all .25s ease;
}

    .form-control:focus {
        outline: none;
        border-color: #007bff;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
    }

/* تاریخ - فشرده */
.date-inputs {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 36px;
    direction: rtl;
    width: 100%;
    box-sizing: border-box;
}

.date-separator {
    color: #495057;
    font-size: 14px;
    padding: 0 2px;
}

.date-input-field {
    height: 36px;
    width: auto;
    min-width: 2.6rem;
    max-width: 4.5rem;
    padding: 0;
    text-align: center;
    font: 13px/1 'Vazir', sans-serif;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #495057;
    direction: ltr;
    box-sizing: border-box;
    transition: all .2s ease;
}

    .date-input-field.year {
        min-width: 4rem;
        max-width: 5.5rem;
    }

    .date-input-field:focus {
        border-color: #007bff;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
        outline: none;
    }

    .date-input-field::placeholder {
        color: #6c757d;
        opacity: 0.7;
        font-size: 0.8rem;
    }

    .date-input-field.is-invalid {
        border-color: #dc3545;
        box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15);
    }

/* TomSelect - فشرده + اسکرول بیرونی */
.tom-select {
    width: 100%;
}

.ts-wrapper {
    direction: rtl;
}

.ts-control {
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: #fff;
    font: 0.9rem 'Vazir', sans-serif;
    color: #495057;
    display: flex;
    align-items: center;
    position: relative;
    transition: all .25s ease;
}

    .ts-control.focus {
        border-color: #007bff;
        box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
    }

    .ts-control::after {
        content: '';
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        border: 5px solid transparent;
        border-top-color: #666;
        transition: transform .2s ease;
    }

    .ts-control.focus::after {
        transform: translateY(-50%) rotate(180deg);
    }

.ts-dropdown {
    max-height: 180px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    margin-top: 3px;
    direction: rtl;
    text-align: right;
    z-index: 1050;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

    .ts-dropdown::-webkit-scrollbar {
        width: 5px;
    }

    .ts-dropdown::-webkit-scrollbar-track {
        background: transparent;
        border-radius: 3px;
    }

    .ts-dropdown::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.25);
        border-radius: 3px;
    }

        .ts-dropdown::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 0, 0, 0.4);
        }

.ts-dropdown-content {
    overflow: visible !important;
    max-height: none !important;
}

.ts-dropdown .option {
    padding: 8px 10px;
    color: #333;
    border-bottom: 1px solid #f8f9fa;
    transition: background .2s;
}

    .ts-dropdown .option:hover {
        background: #f8f9fa;
    }

    .ts-dropdown .option.active {
        background: #007bff;
        color: #fff;
    }

.ts-dropdown .create {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    color: #333;
    font-size: 0.85rem;
}

    .ts-dropdown .create::before {
        content: "+";
        font-weight: bold;
        order: 2;
    }

    .ts-dropdown .create strong {
        order: 1;
        flex-grow: 1;
        text-align: right;
    }

    .ts-dropdown .create:hover {
        background: #f5f5f5;
    }

.ts-dropdown .no-results {
    padding: 8px;
    color: #999;
    font-size: 0.85rem;
    text-align: right;
}

/* تاگل - فشرده */
.bank-fund-toggle {
    margin: 8px 0;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 0;
}

.toggle-slider {
    width: 50px;
    height: 26px;
    background: #007bff;
    border-radius: 13px;
    position: relative;
    transition: background .3s;
    margin: 0 8px;
}

    .toggle-slider::before {
        content: '';
        position: absolute;
        width: 22px;
        height: 22px;
        background: #fff;
        border-radius: 50%;
        top: 2px;
        right: 2px;
        transition: transform .3s;
    }

#bankFundToggle:checked + .toggle-label .toggle-slider {
    background: #28a745;
}

    #bankFundToggle:checked + .toggle-label .toggle-slider::before {
        transform: translateX(-24px);
    }

.toggle-text {
    font-weight: 500;
    color: #495057;
    min-width: 50px;
}

    .toggle-text::after {
        content: attr(data-on);
    }

#bankFundToggle:checked + .toggle-label .toggle-text::after {
    content: attr(data-off);
}

/* چک */
.cheque-section {
    background: #f8f9fa;
    padding: 14px;
    border-radius: 6px;
    margin-top: 14px;
    border: 1px solid #e9ecef;
}

/* ───── فرم ردیف ───── */
.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 14px;
}

    .form-row .form-group {
        flex: 1;
        margin: 0;
        padding: 0;
    }

        .form-row .form-group label {
            display: block;
            margin-bottom: 4px;
            font: 500 13px 'Vazir', sans-serif;
            color: #495057;
        }

/* ───── تاگل پرداخت ───── */
.bank-fund-toggle,
.payment-toggle {
    display: flex;
    position: relative;
    background-color: #f0f0f4;
    border-radius: 6px;
    height: 36px;
    width: 100%;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.03);
    direction: ltr;
    font-family: 'Vazir', sans-serif;
    box-sizing: border-box;
}

/* گزینه‌های داخلی */
.bank-fund-toggle .toggle-option,
.payment-toggle .toggle-option {
    flex: 1;
    display: grid;
    place-content: center;
    font: 500 13px/1 'Vazir', sans-serif;
    color: #7a7a80;
    cursor: pointer;
    user-select: none;
    z-index: 1;
    padding: 0;
    text-align: center;
}

/* مخفی کردن دکمه‌های رادیویی */
.bank-fund-toggle input[type="radio"],
.payment-toggle input[type="radio"] {
    display: none;
}

/* پس‌زمینه متحرک برای انتخاب */
.bank-fund-toggle::before,
.payment-toggle::before {
    content: '';
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    width: calc(50% - 2px);
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s;
    z-index: 0;
}

/* حالت فعال - جابه‌جایی پس‌زمینه */
.bank-fund-toggle[data-active="credit"]::before,
.payment-toggle[data-active="credit"]::before {
    transform: translateX(100%);
}

/* ───── پیام‌ها ───── */
.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Media query برای موبایل (اختیاری ولی توصیه‌شده) */
@media (max-width: 768px) {
    .modal-content {
        width: 98%;
        max-height: 98dvh; /* dynamic viewport height */
        margin: 1dvh auto; /* فاصله کم و هوشمند */
    }
}

