/* ============================================
   SettingsPanel.css - نسخه مودال وسط‌چین
   نسخه: v4.0 Modal - سازگار کامل با MIUI
   ============================================ */

/* ============================================
   دکمه تنظیمات در TopIcons
   ============================================ */
.TopIcons .settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, transform 0.2s ease;
}

.TopIcons .settings-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.TopIcons .settings-btn:active {
    transform: scale(0.92);
}

.TopIcons .settings-btn img {
    display: block;
    width: 28px;
    height: 28px;
    object-fit: contain;
    pointer-events: none;
    transition: transform 0.4s ease;
}

.TopIcons .settings-btn:hover img {
    transform: rotate(90deg);
}

html.theme-dark .TopIcons .settings-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ============================================
   Overlay تیره پشت مودال
   ============================================ */
.SettingsOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1198;
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.SettingsOverlay.show {
    display: block;
    opacity: 1;
}

/* ============================================
   مودال تنظیمات - وسط صفحه
   ============================================ */
.SettingsPanel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1199;
    width: 420px;
    max-width: calc(100vw - 2rem);
    max-height: 85vh;
    display: none;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
    color: var(--text-dark, #222);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.25),
        0 20px 60px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.SettingsPanel.show {
    display: flex;
}

html.theme-dark .SettingsPanel {
    background: #1a2530;
    color: #e8edf3;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        0 20px 60px rgba(0, 0, 0, 0.6);
}

/* ============================================
   محتوای درون مودال
   ============================================ */
.SettingsPanel .settings-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
}

/* ============================================
   هدر مودال
   ============================================ */
.SettingsPanel .settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.25rem 1rem;
    background: linear-gradient(135deg, #1a2a3a 0%, #2a3d50 100%);
    color: #ffffff;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

html.theme-dark .SettingsPanel .settings-header {
    background: linear-gradient(135deg, #0a0f15 0%, #16202b 100%);
}

.SettingsPanel .settings-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
}

.SettingsPanel .settings-title-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.SettingsPanel .settings-close {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    font-size: 1.2rem;
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, transform 0.2s ease;
}

.SettingsPanel .settings-close:hover {
    background: rgba(228, 64, 95, 0.5);
    transform: rotate(90deg);
}

.SettingsPanel .settings-close:focus-visible {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

/* ============================================
   بدنه مودال - قابل اسکرول
   ============================================ */
.SettingsPanel .settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    -webkit-overflow-scrolling: touch;
}

.SettingsPanel .setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.SettingsPanel .setting-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark, #222);
    margin: 0;
}

html.theme-dark .SettingsPanel .setting-label {
    color: #e8edf3;
}

.SettingsPanel .setting-label-icon {
    font-size: 1.15rem;
    line-height: 1;
}

/* ============================================
   دکمه‌های گزینه (۳ ستون)
   ============================================ */
.SettingsPanel .setting-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.SettingsPanel .setting-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem;
    background: #f5f7fa;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark, #222);
    text-align: center;
    line-height: 1.3;
    min-height: 70px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, border-color 0.2s ease,
                color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.SettingsPanel .setting-option:hover {
    background: #e8edf3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.SettingsPanel .setting-option:active {
    transform: translateY(0);
}

.SettingsPanel .setting-option .option-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.SettingsPanel .setting-option .option-text {
    font-size: 0.8rem;
    font-weight: 600;
}

.SettingsPanel .setting-option.active {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.15), rgba(74, 144, 226, 0.08));
    border-color: #4A90E2;
    color: #4A90E2;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.2);
}

html.theme-dark .SettingsPanel .setting-option {
    background: #22303d;
    color: #e8edf3;
}

html.theme-dark .SettingsPanel .setting-option:hover {
    background: #2a3a48;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

html.theme-dark .SettingsPanel .setting-option.active {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.25), rgba(74, 144, 226, 0.15));
    border-color: #4A90E2;
    color: #8cc5ff;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

/* ============================================
   فوتر مودال
   ============================================ */
.SettingsPanel .settings-footer {
    padding: 0.9rem 1.25rem 1.1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    background: #fafbfc;
}

html.theme-dark .SettingsPanel .settings-footer {
    border-top-color: rgba(255, 255, 255, 0.06);
    background: #16202b;
}

.SettingsPanel .reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.7rem 1rem;
    background: #fff5f5;
    border: 2px solid #f5b5b5;
    border-radius: 12px;
    color: #b91c1c;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, border-color 0.2s ease,
                transform 0.2s ease, box-shadow 0.2s ease;
}

.SettingsPanel .reset-btn:hover {
    background: #fde8e8;
    border-color: #b91c1c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(185, 28, 28, 0.2);
}

.SettingsPanel .reset-btn:active {
    transform: translateY(0);
}

.SettingsPanel .reset-btn .reset-icon {
    font-size: 1.1rem;
}

html.theme-dark .SettingsPanel .reset-btn {
    background: rgba(185, 28, 28, 0.15);
    border-color: rgba(185, 28, 28, 0.4);
    color: #ff8a8a;
}

html.theme-dark .SettingsPanel .reset-btn:hover {
    background: rgba(185, 28, 28, 0.25);
    border-color: #ff8a8a;
}

/* ============================================
   پیام بازنشانی
   ============================================ */
.SettingsPanel .reset-message {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    margin-top: 0.75rem;
    background: #e6f5ed;
    border: 1px solid #a8d5b8;
    border-radius: 8px;
    color: #1a7a42;
    font-size: 0.8rem;
    font-weight: 600;
}

.SettingsPanel .reset-message.show {
    display: flex;
}

html.theme-dark .SettingsPanel .reset-message {
    background: rgba(26, 122, 66, 0.2);
    border-color: rgba(26, 122, 66, 0.4);
    color: #7ee0a3;
}

/* ============================================
   جلوگیری از اسکرول body
   ============================================ */
body.settings-open {
    overflow: hidden;
}

/* ============================================
   واکنش‌گرایی
   ============================================ */

/* ===== موبایل ===== */
@media (max-width: 767px) {
    .SettingsPanel {
        width: calc(100vw - 2rem);
        max-width: 380px;
        max-height: 80vh;
    }

    .SettingsPanel .settings-content {
        max-height: 80vh;
    }

    .SettingsPanel .settings-header {
        padding: 1rem 1rem 0.85rem;
    }

    .SettingsPanel .settings-title {
        font-size: 1rem;
    }

    .SettingsPanel .settings-body {
        padding: 1rem;
        gap: 1rem;
    }

    .SettingsPanel .setting-option {
        padding: 0.6rem 0.4rem;
        min-height: 62px;
    }

    .SettingsPanel .setting-option .option-icon {
        font-size: 1.15rem;
    }

    .SettingsPanel .setting-option .option-text {
        font-size: 0.72rem;
    }

    .SettingsPanel .settings-footer {
        padding: 0.8rem 1rem 1rem;
    }
}

/* ===== تبلت ===== */
@media (min-width: 768px) and (max-width: 1023px) {
    .SettingsPanel {
        width: 440px;
        max-height: 82vh;
    }
}

/* ===== دسکتاپ ===== */
@media (min-width: 1024px) {
    .SettingsPanel {
        width: 460px;
        max-height: 80vh;
    }
}

/* ===== کاهش انیمیشن ===== */
@media (prefers-reduced-motion: reduce) {
    .SettingsOverlay,
    .SettingsPanel .settings-close,
    .SettingsPanel .setting-option,
    .SettingsPanel .reset-btn,
    .TopIcons .settings-btn img {
        transition: none;
    }
}