/* ========================================
   MODAL (fade only — no translate)
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    will-change: opacity;
}
.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayFade 360ms ease both;
}
@keyframes overlayFade { from { opacity:0; } to { opacity:1; } }

.modal-content {
    background: #f7f4ef;
    padding: 0;
    border-radius: 16px;
    max-width: 960px;
    width: 94%;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.28);
    will-change: opacity;
    transform: none !important;
    animation: contentFade 360ms ease both;
    outline: none;
}

/* Sticky modal header (breadcrumb + close) */
.modal-sticky-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f7f4ef;
    border-bottom: 1px solid color-mix(in srgb, var(--emerald) 12%, transparent);
    padding: 14px 36px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* When modal is in fatwa-view mode, wrap header+body */
.modal-fatwa-wrap {
    padding: 0 36px 48px;
}

/* Для нефетвового контента (форма вопроса, списки) — классический паддинг */
#question-modal .modal-content {
    max-width: 600px;
    padding: 36px;
    background: #f4f7f5;
}
#question-modal .modal-sticky-header { display: none; }
@keyframes contentFade { from { opacity:0; } to { opacity:1; } }

.modal-close {
    position: relative;
    top: auto; right: auto;
    font-size: 20px;
    font-weight: 700;
    color: #666;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.12s ease;
    line-height: 1;
    background: rgba(0,0,0,0.06);
    border: none;
    padding: 6px 10px;
    border-radius: 8px;
    flex-shrink: 0;
}
.modal-close:hover { color: #1a472a; background: color-mix(in srgb, var(--emerald) 12%, transparent); transform: translateY(-1px); }

.modal-title {
    font-size: 1.5rem;
    color: #133a26;
    margin-bottom: 6px;
    font-weight: 700;
    line-height: 1.3;
}
.modal-description {
    color: #556068;
    margin-bottom: 22px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.modal.hiding { animation: overlayFadeRev 300ms ease both; }
.modal.hiding .modal-content { animation: contentFadeRev 300ms ease both; }
@keyframes overlayFadeRev { from { opacity:1; } to { opacity:0; } }
@keyframes contentFadeRev { from { opacity:1; } to { opacity:0; } }

.modal-content::-webkit-scrollbar { width: 10px; }
.modal-content::-webkit-scrollbar-track { background: transparent; }
.modal-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 10px; }

body.modal-open { overflow: hidden; }

/* ========================================
   MODAL INNER: BACK BTN + SEARCH + LIST
   ======================================== */
.modal-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--emerald);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 0 14px;
    transition: color var(--transition-fast);
    font-family: var(--font-primary);
}
.modal-back-btn:hover { color: var(--emerald-dark); }
.modal-back-btn svg { width: 14px; height: 14px; }

/* Breadcrumb trail */
.modal-breadcrumb {
    font-size: 12px;
    color: var(--medium-gray);
    margin-bottom: 4px;
    padding: 0 2px;
}
.modal-breadcrumb span { cursor: pointer; transition: color var(--transition-fast); }
.modal-breadcrumb span:hover { color: var(--emerald); }
.modal-breadcrumb .sep { margin: 0 5px; color: #ccc; cursor: default; }

/* Internal modal search bar */
.modal-search-wrap {
    position: relative;
    margin-bottom: 20px;
    margin-top: 4px;
}
.modal-search-input {
    width: 100%;
    padding: 11px 42px 11px 16px;
    border: 1.5px solid #dde2e0;
    border-radius: 10px;
    font-size: 14px;
    font-family: var(--font-primary);
    background: #fff;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.modal-search-input:focus {
    border-color: var(--emerald);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 12%, transparent);
}
.modal-search-input::placeholder { color: #9ca3af; }
.modal-search-icon {
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--emerald);
    font-size: 16px;
    pointer-events: none;
}

/* Filterable list */
.modal-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.modal-list li {
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.22s ease;
    font-size: 15px;
    color: var(--dark-gray);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: listItemIn 0.3s ease both;
}
.modal-list li:hover {
    border-color: var(--emerald);
    background: #eef7f3;
    color: var(--emerald-dark);
}
.modal-list li .li-arrow {
    color: var(--emerald);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.2s, transform 0.2s;
}
.modal-list li:hover .li-arrow { opacity: 1; transform: translateX(0); }

@keyframes listItemIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-empty {
    text-align: center;
    color: var(--medium-gray);
    font-size: 14px;
    padding: 30px 0;
}

/* Filter pills */
.modal-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
    -webkit-mask-image: linear-gradient(to right, transparent 0px, black 12px, black calc(100% - 40px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0px, black 12px, black calc(100% - 40px), transparent 100%);
}
.modal-filters::-webkit-scrollbar {
    display: none;
}
.filter-pill {
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid #dde2e0;
    background: #fff;
    font-size: 12px;
    font-weight: 600;
    color: var(--medium-gray);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-primary);
    flex-shrink: 0;
    white-space: nowrap;
}
.filter-pill:hover, .filter-pill.active {
    background: var(--emerald);
    color: #fff;
    border-color: var(--emerald);
}

/* ========================================
   FATWA CONTENT VIEW
   ======================================== */

/* Bismillah заголовок */
.fatwa-bismillah {
    text-align: center;
    font-size: 1.35rem;
    color: #059669;
    margin-bottom: 1.8rem;
    font-family: var(--font-arabic-display, 'Amiri', serif);
    font-weight: 700;
}

/* Блок вопроса */
.fatwa-question-block {
    background: rgba(108,117,125,0.07);
    padding: 1.25rem 1.5rem;
    border-radius: 0 10px 10px 0;
    margin-bottom: 1.5rem;
    border-inline-start: 4px solid #059669;
}

.fatwa-question-label {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.fatwa-question-text {
    margin: 0;
    color: #495057;
    line-height: 1.7;
    font-size: 1rem;
}

/* Заголовок ответа (арабский) */
.fatwa-answer-title {
    text-align: center;
    font-size: 1.3rem;
    color: #059669;
    margin: 1.5rem 0 1.2rem;
    font-family: var(--font-arabic-display, 'Amiri', serif);
    font-weight: 700;
}

/* Метаданные фетвы */
.fatwa-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.fatwa-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: color-mix(in srgb, var(--emerald) 10%, transparent);
    color: var(--emerald-dark);
}

/* Основной текст фетвы */
.fatwa-body {
    font-size: 15px;
    line-height: 1.85;
    color: #2d3748;
    white-space: normal;
    max-width: 700px;
    margin-inline-start: auto;
    margin-inline-end: auto;
}

.fatwa-body .fatwa-section-title {
    font-weight: 700;
    color: #133a26;
    margin: 18px 0 6px;
    font-size: 16px;
}

.fatwa-body p {
    margin: 0 0 0.9em !important;
}

.fatwa-body h1,
.fatwa-body h2,
.fatwa-body h3 {
    margin: 1.1em 0 0.45em !important;
    line-height: 1.25;
    color: #133a26;
}

.fatwa-body ul,
.fatwa-body ol {
    margin: 0.2em 0 0.9em 1.2em !important;
    padding: 0;
}

.fatwa-body li {
    margin: 0.25em 0;
}

/* Блок рекомендаций */
.fatwa-recommendation-block {
    background: #fff3cd;
    padding: 1.5rem;
    border-radius: 12px;
    border-inline-start: 4px solid #ffc107;
    margin: 1.5rem 0;
}

.fatwa-recommendation-label {
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    color: #856404;
    font-size: 1rem;
}

.fatwa-recommendation-text {
    margin: 0;
    color: #856404;
    line-height: 1.7;
}

/* Блок дополнительной информации */
.fatwa-info-block {
    background: #e7f5ff;
    padding: 1.5rem;
    border-radius: 12px;
    border-inline-start: 4px solid #3b82f6;
    margin: 1.5rem 0;
}

.fatwa-info-label {
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    color: #0c5460;
    font-size: 1rem;
}

.fatwa-info-content {
    margin: 0.5rem 0 0 0;
    color: #0c5460;
}

.fatwa-info-content ul {
    margin: 0.5rem 0 0 1.5rem;
    color: #0c5460;
}

.fatwa-info-content li {
    margin: 0.3rem 0;
}

/* ========================================
   БЛОК ИСТОЧНИКОВ ИЗ КНИГ (НОВЫЙ)
   ======================================== */
.fatwa-sources-block {
    background: #fefcf3;
    padding: 1.5rem;
    border-radius: 12px;
    border-inline-start: 4px solid #d4af37;
    margin: 2rem 0 1.5rem;
}

.fatwa-sources-title {
    margin: 0 0 1rem 0;
    font-weight: 700;
    color: #7c6a3a;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fatwa-source-item {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e8e4d9;
}

.fatwa-source-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Арабский текст из книги */
.fatwa-arabic-text {
    font-family: 'Scheherazade New', 'Amiri', serif !important;
    font-size: 1.15rem;
    line-height: 2;
    color: #0d5f3a;
    text-align: end;
    direction: rtl;
    margin-bottom: 0.8rem;
    padding: 0.8rem;
    background: rgba(212, 175, 55, 0.08);
    border-radius: 8px;
}

/* Название книги */
.fatwa-book-title {
    font-size: 0.9rem;
    color: #7c6a3a;
    font-style: normal;
    margin: 0;
    text-align: end;
    direction: rtl;
    font-family: 'Scheherazade New', 'Amiri', serif;
}

/* Inline арабские термины в тексте */
.arabic-term {
    font-family: 'Scheherazade New', 'Amiri', serif !important;
    font-size: 1.05em;
    color: var(--emerald-dark, #047857);
    font-weight: 500;
}

/* Переводы арабских текстов */
.arabic-translation {
    background: #f0f9f4 !important;
    padding: 12px 18px !important;
    border-inline-start: 3px solid #059669 !important;
    margin: 12px 0 !important;
    font-style: italic !important;
    color: #374151 !important;
    border-radius: 6px !important;
    font-size: 0.96em !important;
    line-height: 1.7 !important;
}

/* ========================================
   ФИНАЛЬНАЯ ФРАЗА "АЛЛАХ ЗНАЕТ ЛУЧШЕ"
   ======================================== */
.fatwa-closing {
    margin-top: 2.5rem;
    text-align: center;
    padding-top: 1.5rem;
    border-top: 2px solid #e5e7eb;
}

.fatwa-closing-arabic {
    font-family: 'Scheherazade New', 'Amiri', serif;
    font-size: 1.15rem;
    color: #059669;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.fatwa-closing-russian {
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
    margin: 0;
}

/* ========================================
   СТАРЫЙ БЛОК SOURCE (оставлен для совместимости)
   ======================================== */
.fatwa-source {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid #e0e4e2;
    font-size: 12px;
    color: var(--medium-gray);
}

/* Пустые блоки */
.fatwa-body p:empty,
.fatwa-body div:empty {
    display: none !important;
}

/* ========================================
   АРАБСКАЯ ВКЛАДКА — крупный шрифт
   ======================================== */
.fatwa-lang-panel[data-lang="ar"] .fatwa-question-text,
.fatwa-lang-panel[data-lang="ar"] .fatwa-body,
.fatwa-lang-panel[data-lang="ar"] .fatwa-body p,
.fatwa-lang-panel[data-lang="ar"] .fatwa-question-body,
.fatwa-lang-panel[data-lang="ar"] .fatwa-question-body p,
.fatwa-lang-panel[data-lang="ar"] .fatwa-answer-body,
.fatwa-lang-panel[data-lang="ar"] .fatwa-answer-body p {
    font-family: 'Scheherazade New', 'Amiri', serif !important;
    font-size: 1.35rem !important;
    line-height: 2.2 !important;
}

.fatwa-lang-panel[data-lang="ar"] .fatwa-recommendation-text,
.fatwa-lang-panel[data-lang="ar"] .fatwa-recommendation-text p,
.fatwa-lang-panel[data-lang="ar"] .fatwa-advice-text,
.fatwa-lang-panel[data-lang="ar"] .fatwa-advice-text p {
    font-family: 'Scheherazade New', 'Amiri', serif !important;
    font-size: 1.25rem !important;
    line-height: 2.1 !important;
}

/* ========================================
   STICKY HEADER LEFT COLUMN
   ======================================== */
.modal-sticky-left {
    flex: 1;
    min-width: 0;
}
.modal-sticky-left .modal-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.1rem;
    margin-bottom: 0;
    color: #1a3a28;
}

/* ========================================
   FATWA-CONTAINER INSIDE MODAL — RESET
   Strip the white card look; content sits directly on modal bg
   ======================================== */
#nav-modal .fatwa-container {
    max-width: 100%;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 24px 0 0;
    margin: 0;
}

/* Recommendation, info, sources blocks — adjust to warm tone */
#nav-modal .fatwa-recommendation-block { background: rgba(255,195,0,0.1); }
#nav-modal .fatwa-info-block           { background: rgba(59,130,246,0.08); }
#nav-modal .fatwa-sources-block        { background: rgba(212,175,55,0.08); }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 680px) {
    .modal-content { width: 100%; max-height: 100dvh; border-radius: 16px 16px 0 0; }
    .modal.show { align-items: flex-end; }
    .modal-sticky-header { padding: 12px 20px 10px; }
    .modal-fatwa-wrap { padding: 0 20px 36px; }
    #question-modal .modal-content { border-radius: 16px 16px 0 0; }
}