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

.rt-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    direction: ltr;
    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: #fff;
    color: #1e293b;
    border-radius: 16px;
    box-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 #e2e8f0;
    flex: 0 0 auto;
}

.rt-modal__title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.6;
    color: #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: #f1f5f9;
    color: #475569;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.rt-modal__close:hover {
    background: #e2e8f0;
    color: #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 #e2e8f0;
    background: #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;
}

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

@media (prefers-color-scheme: dark) {
    .rt-modal::before {
        background: rgba(2, 6, 23, 0.72);
    }

    .rt-modal__dialog {
        background: #1e293b;
        color: #e2e8f0;
    }

    .rt-modal__title {
        color: #f1f5f9;
    }

    .rt-modal__header {
        border-bottom-color: #334155;
    }

    .rt-modal__close {
        background: #334155;
        color: #cbd5e1;
    }

    .rt-modal__close:hover {
        background: #475569;
        color: #f8fafc;
    }

    .rt-modal__footer {
        border-top-color: #334155;
        background: #172033;
    }

    .rt-modal__body a {
        color: #93c5fd;
    }
}

@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;
    }
}
