/* ========================================
   MUJAM MODALS
   ======================================== */

/* ── Оверлей ── */
.mujam-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-overlay, 500);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: mujamOverlayIn 0.2s ease;
}
.mujam-modal-overlay.open { display: flex; }

@keyframes mujamOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Окно модалки ── */
.mujam-modal {
    background: var(--white, #fff);
    border-radius: var(--radius-lg, 16px);
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-modal, 0 25px 80px rgba(0, 0, 0, 0.25));
    z-index: var(--z-modal, 600);
    animation: mujamModalIn 0.25s ease;
    display: flex;
    flex-direction: column;
    contain: layout style;
    will-change: transform;
}
@keyframes mujamModalIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Шапка модалки ── */
.mujam-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    position: sticky;
    top: 0;
    background: var(--white, #fff);
    z-index: 1;
    border-radius: var(--radius-lg, 16px) var(--radius-lg, 16px) 0 0;
}

.mujam-modal-title {
    font-family: 'Scheherazade New', 'Amiri', serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--emerald);
    direction: rtl;
}

.mujam-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background var(--transition-fast, 0.15s), color var(--transition-fast, 0.15s);
}
.mujam-modal-close:hover { background: #f3f4f6; color: #374151; }

/* ── Контент модалки ── */
.mujam-modal-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ── Загрузка ── */
.mujam-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    color: #6b7280;
    font-size: 14px;
    gap: 10px;
}
.mujam-modal-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--emerald);
    border-radius: 50%;
    animation: mujam-spin 0.7s linear infinite;
}


/* ========================================
   БЛОКИ КОНТЕНТА (правила, примеры и т.д.)
   ======================================== */

/* ── Блок правила (арабский/русский текст с левой полоской) ── */
.modal-rule-block {
    border-inline-start: 3px solid var(--emerald);
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--emerald-50, #ecfdf5);
    border-radius: 0 var(--radius-sm, 8px) var(--radius-sm, 8px) 0;
    transition: background var(--transition-fast, 0.15s);
}
.modal-rule-block:hover {
    background: var(--emerald-100, #d1fae5);
}
.modal-rule-block .rule-ar {
    font-family: var(--font-arabic, 'Scheherazade New', 'Amiri', serif);
    font-size: var(--arabic-font-size, 1.3rem);
    line-height: var(--arabic-line-height, 2.0);
    direction: rtl;
    text-align: end;
    color: #1f2937;
    margin-bottom: 8px;
}
.modal-rule-block .rule-ru {
    font-size: 14px;
    line-height: 1.7;
    color: #374151;
}

[dir="rtl"] .modal-rule-block {
    border-inline-start: none;
    border-inline-end: 3px solid var(--emerald);
    border-radius: var(--radius-sm, 8px) 0 0 var(--radius-sm, 8px);
}

/* ── Условия (маркированный список) ── */
.modal-conditions {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}
.modal-conditions li {
    position: relative;
    padding: 6px 0 6px 20px;
    font-size: 14px;
    line-height: 1.7;
    color: #374151;
}
.modal-conditions li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 14px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--emerald);
}

[dir="rtl"] .modal-conditions li {
    padding: 6px 20px 6px 0;
}
[dir="rtl"] .modal-conditions li::before {
    left: auto;
    right: 0;
}

/* ── Примеры с разбором ── */
.modal-examples {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}
.modal-examples li {
    padding: 10px 14px;
    margin-bottom: 8px;
    background: #f9fafb;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid #f3f4f6;
    transition: border-color var(--transition-fast, 0.15s), box-shadow var(--transition-fast, 0.15s);
}
.modal-examples li:hover {
    border-color: var(--border-gray);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.04));
}
.modal-examples .example-ar {
    font-family: var(--font-arabic, 'Scheherazade New', 'Amiri', serif);
    font-size: var(--arabic-font-size, 1.3rem);
    line-height: var(--arabic-line-height, 2.0);
    direction: rtl;
    text-align: end;
    color: #1f2937;
    margin-bottom: 4px;
}
.modal-examples .example-ru {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.6;
}

/* ── Разбор (и'раб) — инлайн-аннотации ── */
.modal-parsing {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    direction: rtl;
    margin-bottom: 12px;
}
.modal-parsing .parse-unit {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.modal-parsing .parse-word {
    font-family: var(--font-arabic, 'Scheherazade New', 'Amiri', serif);
    font-size: 1.1rem;
    color: #1f2937;
    line-height: 1.4;
}
.modal-parsing .parse-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--emerald);
    background: var(--emerald-50, #ecfdf5);
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

/* ── Связанные темы (бейджи-ссылки) ── */
.modal-related-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}
.modal-related-topics .topic-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-full, 9999px);
    font-size: 13px;
    color: var(--emerald);
    cursor: pointer;
    transition: all var(--transition-fast, 0.15s);
    text-decoration: none;
}
.modal-related-topics .topic-badge:hover {
    background: var(--emerald-50, #ecfdf5);
    border-color: var(--emerald);
    color: var(--emerald-dark);
}
.modal-related-topics .topic-badge .topic-icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
}

/* ── Источники (ссылки на книги) ── */
.modal-sources {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.modal-sources li {
    font-family: var(--font-arabic, 'Scheherazade New', 'Amiri', serif);
    font-size: 13px;
    color: #6b7280;
    padding: 4px 12px;
    background: #f9fafb;
    border-radius: var(--radius-full, 9999px);
    border: 1px solid #f3f4f6;
    direction: rtl;
    transition: all var(--transition-fast, 0.15s);
}
.modal-sources li:hover {
    border-color: var(--border-gray);
    background: #f3f4f6;
    color: #374151;
}

/* ── Таблица производных форм (масдар, причастия и т.д.) ── */
.modal-derivatives-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 14px;
}
.modal-derivatives-table th {
    text-align: start;
    padding: 8px 12px;
    font-weight: 600;
    color: #6b7280;
    border-bottom: 2px solid #f3f4f6;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #f9fafb;
}
.modal-derivatives-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f9fafb;
    color: #374151;
    vertical-align: top;
    transition: background var(--transition-fast, 0.15s);
}
.modal-derivatives-table tr:hover td {
    background: #fafbfc;
}
.modal-derivatives-table tr:last-child td { border-bottom: none; }

.modal-derivatives-table .deriv-ar {
    font-family: var(--font-arabic, 'Scheherazade New', 'Amiri', serif);
    font-size: 1.15rem;
    color: #1f2937;
    direction: rtl;
    text-align: end;
    line-height: 1.6;
}
.modal-derivatives-table .deriv-ru {
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}
.modal-derivatives-table .deriv-type {
    font-size: 11px;
    font-weight: 600;
    color: var(--emerald);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

[dir="rtl"] .modal-derivatives-table th { text-align: end; }

/* ── Секция заголовок внутри модалки ── */
.mujam-modal-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    margin-bottom: 10px;
    margin-top: 20px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f3f4f6;
}
.mujam-modal-section-title:first-child {
    margin-top: 0;
}
