/**
 * مودال سراسری رادیوتون
 */

.rt-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    direction: rtl;
    transition: opacity 0.2s ease;
}

.rt-modal[hidden] {
    display: none;
}

.rt-modal.is-open {
    opacity: 1;
}

.rt-modal::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.rt-modal__dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: var(--rt-bg-primary, #ffffff);
    color: var(--rt-text-primary, #1e293b);
    border: 1px solid var(--rt-border, #e2e8f0);
    border-radius: var(--rt-radius, 16px);
    box-shadow: var(--rt-shadow, 0 20px 50px rgba(0, 0, 0, 0.25));
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s ease;
    overflow: hidden;
}

.rt-modal.is-open .rt-modal__dialog {
    transform: translateY(0) scale(1);
}

.rt-modal__dialog:focus {
    outline: none;
}

.rt-modal__dialog--sm {
    max-width: 420px;
}

.rt-modal__dialog--lg {
    max-width: 760px;
}

.rt-modal__dialog--xl {
    max-width: 1000px;
}

.rt-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--rt-border, #e2e8f0);
    background: var(--rt-bg-secondary, #f8fafc);
    flex: 0 0 auto;
}

.rt-modal__title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.6;
    color: var(--rt-text-primary, #0f172a);
}

.rt-modal__title[hidden] {
    display: none;
}

.rt-modal__close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--rt-bg-tertiary, #f1f5f9);
    color: var(--rt-text-secondary, #475569);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.rt-modal__close:hover {
    background: var(--rt-border, #e2e8f0);
    color: var(--rt-text-primary, #0f172a);
}

.rt-modal__close svg {
    width: 18px;
    height: 18px;
}

.rt-modal__body {
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.9375rem;
    line-height: 1.9;
}

.rt-modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--rt-border, #e2e8f0);
    background: var(--rt-bg-secondary, #f8fafc);
    flex: 0 0 auto;
}

.rt-modal__footer[hidden] {
    display: none;
}

/* ===== حالت پذیرش مودال‌های موجود ===== */

/*
 * مودال‌های موجود سر جای خودشان در DOM می‌مانند و پس‌زمینه و چیدمان خودشان را
 * دارند. پوسته در این حالت فقط لایهٔ کنترل است (Escape / focus trap / scroll lock)
 * و نباید چیزی رسم کند، وگرنه روی مودال قرار می‌گیرد.
 */
.rt-modal.is-adopted,
.rt-modal.is-adopted .rt-modal__dialog,
.rt-modal.is-adopted .rt-modal__header,
.rt-modal.is-adopted .rt-modal__body,
.rt-modal.is-adopted .rt-modal__footer {
    display: none;
}

.rt-modal__body--flush {
    padding: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

.rt-modal__body--flush > * {
    flex: 1 1 auto;
    min-height: 0;
}

/* فهرستٔ پس‌زمینهٔ مودال‌های پذیرفته‌شده: کلیک روی آن می‌بندد */
[data-rt-adopted] {
    outline: none;
}

/* ===== حالت بدون فوتر ===== */

.rt-modal__dialog--no-footer .rt-modal__body {
    padding-bottom: 22px;
}

/* ===== تم تیره ===== */

html.dark .rt-modal::before,
body.dark .rt-modal::before,
[data-theme="dark"] .rt-modal::before {
    background: rgba(2, 6, 23, 0.72);
}

@media (max-width: 640px) {
    .rt-modal {
        padding: 12px;
        align-items: flex-end;
    }

    .rt-modal__dialog {
        max-height: 92vh;
        border-radius: 16px;
    }

    .rt-modal__body {
        padding: 16px;
    }
}
