/* ========================================
   HADITH COLLECTIONS — сайдбар + контент
   ======================================== */
.hadith-collections-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 0;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    padding: 24px 24px;
    align-items: start;
}

/* ── САЙДБАР ── */
.hadith-sidebar {
    position: sticky;
    top: 20px;
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border-gray);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

.hadith-sidebar-title {
    padding: 14px 16px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    border-bottom: 1px solid #f3f4f6;
}

.hadith-collection-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}

.hadith-collection-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f9fafb;
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.hadith-collection-item:last-child { border-bottom: none; }
.hadith-collection-item:hover { background: var(--emerald-50, #f0fdf4); }
.hadith-collection-item.active { background: var(--emerald-50, #ecfdf5); border-inline-start: 3px solid var(--emerald, #059669); }

.collection-name-ru {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
}
.collection-name-ar {
    font-family: 'Scheherazade New', 'Amiri', serif;
    font-size: 13px;
    color: #6b7280;
    direction: rtl;
    text-align: end;
}
.collection-count {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
    margin-top: 2px;
}

/* ── КОНТЕНТНАЯ ОБЛАСТЬ ── */
.hadith-content-area {
    padding-inline-start: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* ── Intro блок сборника ── */
.collection-intro {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border-gray);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.collection-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 0 12px;
}
.collection-title-ar {
    font-family: 'Scheherazade New', 'Amiri', serif;
    font-size: 22px;
    color: #1f2937;
    direction: rtl;
    text-align: end;
    display: block;
}
.collection-title-ru {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.collection-author {
    font-size: 14px;
    color: #374151;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.narrator-link {
    color: var(--emerald);
    text-decoration: underline dotted;
    cursor: pointer;
    font-family: 'Scheherazade New', 'Amiri', serif;
    font-size: 15px;
    direction: rtl;
    background: none;
    border: none;
    padding: 0;
}
.narrator-link:hover { color: var(--emerald-dark); }
.author-dates { color: #6b7280; font-size: 13px; }

.collection-desc {
    font-size: 14px;
    color: #374151;
    line-height: 1.7;
    margin: 0 0 12px;
}

.collection-meta {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: #6b7280;
    flex-wrap: wrap;
}
.collection-meta span:not(:last-child)::after { content: '·'; margin-inline-start: 10px; }

/* ── Каскадные dropdown (sticky при прокрутке) ── */
.hadith-nav-selectors {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border-gray);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    /* Sticky при прокрутке */
    position: sticky;
    top: 0;
    z-index: 50;
    transition: box-shadow 0.25s, border-radius 0.25s;
}
/* Визуальное выделение при прилипании */
.hadith-nav-selectors.stuck {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-radius: 0 0 12px 12px;
    border-top-color: transparent;
}

.hadith-select-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hadith-select-group label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.hadith-select-group select {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border: 1.5px solid var(--border-gray);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: #1f2937;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-inline-end: 32px;
    /* Усекаем длинный текст выбранного пункта */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hadith-select-group select:focus {
    outline: none;
    border-color: var(--emerald);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 10%, transparent);
}
.hadith-select-group select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Полное название выбранного пункта (показывается когда текст усечён) */
.hadith-select-fullname {
    display: none;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
    padding: 4px 2px 0;
}
.hadith-select-fullname.visible { display: block; }

/* Глобальные контролы (показать перевод / параллельный режим) */
.hadith-global-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 0 4px;
    flex-wrap: wrap;
}
.hadith-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
    user-select: none;
}
.hadith-toggle input[type="checkbox"] {
    accent-color: var(--emerald);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* ── Мукаддима (прозаическое введение имама Муслима) ── */
.muqaddima-block {
    background: var(--white);
    border: 1px solid var(--border-gray);
    border-radius: 12px;
    padding: 28px 32px;
}
.muqaddima-label {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-green, #2d6a4f);
    margin-bottom: 24px;
    text-align: center;
    letter-spacing: 0.01em;
}
.muqaddima-text {
    display: flex;
    flex-direction: column;
    gap: 0;
}
/* Контейнер одного абзаца: арабский + русский */
.muqaddima-para {
    border-bottom: 1px solid var(--border-gray, #e8e8e8);
    padding: 20px 0;
}
.muqaddima-para:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.muqaddima-para:first-child {
    padding-top: 0;
}
/* Арабский абзац — те же параметры что и у .hadith-matn,
   чтобы мукаддима/текст баба не выбивались по размеру */
.muqaddima-paragraph.muqaddima-ar {
    font-family: 'Scheherazade New', 'Amiri', 'Traditional Arabic', serif;
    font-size: 19px;
    line-height: 2.2;
    color: #1f2937;
    direction: rtl;
    text-align: end;
    text-indent: 2em;
    margin: 0 0 12px 0;
}
/* Русский перевод */
.muqaddima-paragraph.muqaddima-ru {
    font-family: var(--font-main, 'Inter', sans-serif);
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--text-muted, #555);
    direction: ltr;
    text-align: start;
    text-indent: 1.5em;
    margin: 0;
    padding: 8px 12px;
    background: var(--bg-light, #f8f9fa);
    border-radius: 6px;
    border-inline-start: 3px solid var(--primary-green, #2d6a4f);
}

/* ── Плашка результатов поиска ── */
.search-results-banner {
    background: var(--emerald-50, #ecfdf5);
    border: 1px solid var(--emerald, #059669);
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 16px;
}
.search-banner-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-dark, #1a1a1a);
}
.search-banner-icon { font-size: 1.1rem; }
.search-banner-icon svg { display: block; }
.search-banner-scope {
    color: var(--text-muted, #6b7280);
    font-size: 0.88rem;
}

/* ── Список хадисов ── */
.hadith-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Текст перед хадисом (комментарий автора / фасль) ── */
.hadith-pre-text {
    margin-bottom: 16px;
    padding: 16px 20px;
    background: var(--bg-light, #f8faf9);
    border-radius: 8px;
    border-inline-end: 3px solid var(--primary, #0d7c66);
    line-height: 2;
}
.pre-text-body {
    font-family: var(--font-arabic, 'Amiri', serif);
    font-size: 1.05rem;
    color: var(--text-dark, #333);
    margin: 0 0 8px 0;
}
.pre-text-fasl-title {
    font-family: var(--font-arabic, 'Amiri', serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary, #0d7c66);
    text-align: center;
    margin: 12px 0;
}

/* ── Заголовок секции (فصل) перед хадисом ── */
.hadith-section-title {
    font-family: var(--font-arabic, 'Amiri', serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary, #0d7c66);
    text-align: center;
    padding: 10px 20px;
    margin: 0 0 14px 0;
    background: var(--bg-light, #f8faf9);
    border-radius: 8px;
}

/* ── Карточка хадиса ── */
.hadith-card {
    background: var(--white);
    border: 1px solid var(--border-gray);
    border-radius: 12px;
    padding: 24px;
    transition: box-shadow 0.2s;
}
.hadith-card:hover { box-shadow: var(--shadow-md); }

.hadith-divider {
    border: none;
    border-top: 1px solid var(--border-gray);
    margin: 0;
}

/* Номер хадиса */
.hadith-number {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.hadith-num-label {
    font-family: 'Scheherazade New', 'Amiri', serif;
    font-size: 13px;
    color: #9ca3af;
    direction: rtl;
}
.hadith-num-value {
    font-family: 'Scheherazade New', 'Amiri', serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--emerald);
    direction: rtl;
}

/* Матн (включает иснад — единый блок) */
.hadith-matn {
    font-family: 'Scheherazade New', 'Amiri', serif;
    font-size: 19px;
    line-height: 2.2;
    color: #1f2937;
    margin-bottom: 16px;
    direction: rtl;
    white-space: pre-line;
    text-align: end;
}

/* Иснад приглушён — матн остаётся визуальным фокусом */
.hadith-isnad {
    color: var(--medium-gray);
    font-size: 0.85em;
}

/* Кнопка перевода */
.hadith-translation-toggle {
    background: none;
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--emerald);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    margin-bottom: 10px;
}
.hadith-translation-toggle:hover {
    background: var(--emerald-50, #ecfdf5);
    border-color: var(--emerald);
}

.hadith-translation {
    font-size: 15px;
    line-height: 1.8;
    color: #374151;
    padding: 14px 16px;
    background: #f9fafb;
    border-radius: 8px;
    border-inline-start: 3px solid var(--emerald);
    margin-bottom: 14px;
    font-family: 'Noto Serif', serif;
}
[dir="rtl"] .hadith-translation { border-inline-start: none; border-inline-end: 3px solid var(--emerald); }

/* Бейдж степени */
.hadith-grade-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 14px;
    font-family: 'Inter', sans-serif;
}
.hadith-grade-badge.sahih          { background: #d1fae5; color: #059669; }
.hadith-grade-badge.sahih_li_ghayrihi { background: #d1fae5; color: #10b981; }
.hadith-grade-badge.hasan          { background: #fef3c7; color: #c5a059; }
.hadith-grade-badge.hasan_li_ghayrihi { background: #fef3c7; color: #d4b96a; }
.hadith-grade-badge.daif           { background: #fef3c7; color: #f59e0b; }
.hadith-grade-badge.daif_jiddan    { background: #fee2e2; color: #ef4444; }
.hadith-grade-badge.mawdu          { background: #fee2e2; color: #991b1b; }

/* Суб-вкладки под хадисом */
.hadith-sub-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.hadith-sub-tab {
    padding: 5px 12px;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    background: white;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Inter', sans-serif;
}
.hadith-sub-tab:hover { background: var(--emerald-50, #f0fdf4); border-color: var(--emerald); color: var(--emerald); }
.hadith-sub-tab.active { background: var(--emerald); color: white; border-color: var(--emerald); }

.hadith-sub-content {
    padding: 14px 0;
    font-size: 14px;
    line-height: 1.7;
    color: #374151;
}

/* Кнопки действий */
.hadith-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
}
.hadith-action-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.15s;
}
.hadith-action-btn:hover { background: var(--emerald-50, #ecfdf5); border-color: var(--emerald); color: var(--emerald); }

/* Loading / empty states */
.hadith-loading {
    text-align: center;
    padding: 48px 24px;
    color: #6b7280;
    font-size: 15px;
}
.hadith-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--emerald);
    border-radius: 50%;
    animation: hadith-spin 0.7s linear infinite;
    vertical-align: middle;
    margin-inline-start: 8px;
}
@keyframes hadith-spin { to { transform: rotate(360deg); } }

.hadith-empty {
    text-align: center;
    padding: 64px 24px;
    color: #9ca3af;
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border-gray);
}
.hadith-empty-icon { font-size: 40px; margin-bottom: 12px; }
.hadith-empty-title { font-size: 16px; font-weight: 700; color: #374151; margin-bottom: 6px; }
.hadith-empty-sub { font-size: 13px; color: #9ca3af; }

/* Параллельный режим */
.hadith-parallel-layout .hadith-matn-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}
.hadith-parallel-layout .hadith-translation { display: block !important; margin-bottom: 0; }

/* ── Мобильный select вместо сайдбара ── */
.hadith-collection-select-mobile {
    display: none;
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-gray);
    border-radius: 10px;
    font-size: 14px;
    background: white;
    color: #1f2937;
    font-family: 'Inter', sans-serif;
    margin-bottom: 16px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-inline-end: 32px;
}
