/* ========================================
   MUJAM — Сарф: Split-panel layout
   6 кнопок сарф сагир + динамический кабир
   ======================================== */

/* ═══ SPLIT LAYOUT ═══ */
.sarf-split {
    display: flex;
    gap: 0;
    height: calc(100vh - 200px);
    min-height: 500px;
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--white);
}

/* ═══ ЛЕВАЯ ПАНЕЛЬ: Список ═══ */
.sarf-list-panel {
    width: 340px;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    border-inline-end: 1px solid var(--border-gray);
    background: #fafbfc;
}

.sarf-list-panel .mujam-search-bar {
    padding: 12px;
    border-bottom: 1px solid var(--border-gray);
    flex-shrink: 0;
}

.sarf-list-panel .mujam-alphabet {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-gray);
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
}
.sarf-list-panel .mujam-alpha-btn {
    padding: 2px 5px;
    font-size: 13px;
    min-width: 26px;
}

/* Список глаголов (скролл) */
.sarf-verb-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

/* Карточка глагола в списке */
.sarf-verb-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    border: 1px solid transparent;
}
.sarf-verb-card:hover {
    background: var(--emerald-50);
}
.sarf-verb-card.active {
    background: var(--emerald-50);
    border-color: var(--emerald);
}

.sarf-verb-card-ar {
    font-family: var(--font-arabic);
    font-size: 19px;
    direction: rtl;
    color: var(--dark-gray);
    flex-shrink: 0;
}
.sarf-verb-card-forms {
    font-size: 11px;
    color: var(--medium-gray);
    margin-inline-start: auto;
}
.sarf-verb-card-type {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--emerald-50);
    color: var(--emerald);
    font-weight: 600;
    white-space: nowrap;
}

/* Пагинация */
.sarf-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--border-gray);
    flex-shrink: 0;
}
.sarf-pagination button {
    padding: 4px 12px;
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-sm);
    background: var(--white);
    cursor: pointer;
    font-size: 13px;
    color: var(--medium-gray);
    transition: all var(--transition-fast);
}
.sarf-pagination button:hover:not(:disabled) {
    border-color: var(--emerald);
    color: var(--emerald);
}
.sarf-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.sarf-pagination .sarf-page-info {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--medium-gray);
}

/* ═══ ПРАВАЯ ПАНЕЛЬ: Детали ═══ */
.sarf-detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px 24px;
    position: relative;
}

/* Кнопка закрытия (только мобиль) */
.sarf-detail-close {
    display: none;
    position: absolute;
    top: 12px;
    left: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--light-gray);
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    color: var(--medium-gray);
    z-index: 10;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}
.sarf-detail-close:hover { background: var(--border-gray); }

/* Заголовок глагола */
.sarf-detail-header {
    text-align: center;
    margin-bottom: 20px;
}
.sarf-detail-verb {
    font-family: var(--font-arabic);
    font-size: 36px;
    color: var(--dark-gray);
    line-height: 1.4;
}
.sarf-detail-meaning {
    font-size: 14px;
    color: var(--medium-gray);
    margin-top: 4px;
}
.sarf-saghir-meta {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.sarf-meta-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 20px;
    background: var(--light-gray);
    color: var(--medium-gray);
}
.sarf-meta-badge:empty { display: none; }

/* ═══ Селектор породы (формы) ═══ */
.sarf-form-selector {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--light-gray);
}
.sarf-form-chip {
    padding: 4px 12px;
    border: 1px solid var(--border-gray);
    border-radius: var(--radius-full);
    background: var(--white);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--medium-gray);
    transition: all var(--transition-fast);
}
.sarf-form-chip:hover {
    border-color: var(--emerald);
    color: var(--emerald);
}
.sarf-form-chip.active {
    background: var(--emerald);
    border-color: var(--emerald);
    color: var(--on-primary);
}

/* ═══ 6 КНОПОК САРФ САГИР ═══ */
.sarf-saghir-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.sarf-saghir-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: 2px solid var(--border-gray);
    border-radius: var(--radius-md);
    background: var(--white);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}
.sarf-saghir-btn:hover {
    border-color: var(--emerald);
    box-shadow: var(--shadow-sm);
}
.sarf-saghir-btn.active {
    border-color: var(--emerald);
    background: var(--emerald-50);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 15%, transparent);
}

.sarf-saghir-btn-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--medium-gray);
    font-family: var(--font-arabic);
}
.sarf-saghir-btn-value {
    font-family: var(--font-arabic);
    font-size: 20px;
    color: var(--dark-gray);
    min-height: 28px;
    display: flex;
    align-items: center;
}
.sarf-saghir-btn.active .sarf-saghir-btn-label {
    color: var(--emerald);
}

/* ═══ САРФ КАБИР: СЕКЦИЯ ═══ */
.sarf-kabir-section {
    border-top: 1px solid var(--light-gray);
    padding-top: 12px;
    animation: sarfKabirSlide 0.25s ease-out;
}

@keyframes sarfKabirSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Горизонтальные табы кабира */
.sarf-kabir-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 2px solid var(--border-gray);
    margin-bottom: 12px;
}
.sarf-kabir-tabs::-webkit-scrollbar { display: none; }

.sarf-kabir-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--medium-gray);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition: color 0.2s;
    flex-shrink: 0;
    font-family: var(--font-arabic);
}
.sarf-kabir-tab::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--emerald);
    transform: scaleX(0);
    transition: transform 0.2s;
}
.sarf-kabir-tab:hover { color: var(--emerald-dark); }
.sarf-kabir-tab.active { color: var(--emerald); }
.sarf-kabir-tab.active::after { transform: scaleX(1); }

/* Таблица спряжения */
.sarf-conjugation-table-wrap { overflow-x: auto; }
.sarf-conjugation-table { width: 100%; border-collapse: collapse; }
.sarf-conjugation-table th {
    background: var(--emerald-50);
    color: var(--emerald-dark);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    text-align: start;
    border-bottom: 2px solid var(--border-gray);
}
.sarf-conjugation-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--light-gray);
    font-size: 14px;
}
.sarf-conjugation-table tr:hover { background: #fafbfa; }

/* Колонка лица */
.sarf-conjugation-table td:first-child {
    color: var(--medium-gray);
    font-size: 13px;
    white-space: nowrap;
}
/* Колонка местоимения */
.sarf-conjugation-table td:nth-child(2) {
    font-family: var(--font-arabic);
    font-size: 17px;
    direction: rtl;
    text-align: end;
    color: var(--gold);
}
/* Колонка формы */
.sarf-conjugation-table td:last-child {
    font-family: var(--font-arabic);
    font-size: 20px;
    direction: rtl;
    text-align: end;
    color: var(--dark-gray);
}

/* Подсветка корневых букв */
.sarf-root-letter { color: var(--emerald); font-weight: 700; }

/* Заголовок группы */
.sarf-conj-group-header td {
    background: #f9fafb;
    font-size: 12px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
}

/* Для мсадр/фаиль/мафуль — показ слова вместо таблицы */
.sarf-word-display {
    text-align: center;
    padding: 32px 20px;
    font-family: var(--font-arabic);
    font-size: 36px;
    color: var(--dark-gray);
    direction: rtl;
}
.sarf-word-display-label {
    font-size: 14px;
    color: var(--medium-gray);
    margin-bottom: 8px;
    font-family: var(--font-primary);
}

/* Пустое состояние в детали */
.sarf-detail-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--medium-gray);
    font-size: 14px;
    text-align: center;
    padding: 40px;
}

/* Пустое состояние (глагол не выбран) — стиль скрытой правой панели */
.sarf-detail-panel:not(.open) .sarf-detail-header,
.sarf-detail-panel:not(.open) .sarf-saghir-buttons,
.sarf-detail-panel:not(.open) .sarf-kabir-section,
.sarf-detail-panel:not(.open) .sarf-form-selector {
    display: none;
}
.sarf-detail-panel.open .sarf-detail-empty {
    display: none;
}

/* Глобальное пустое состояние (ничего не загружено) */
#sarf-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--medium-gray);
}
#sarf-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* ═══ МОБИЛЬНАЯ АДАПТАЦИЯ ═══ */
@media (max-width: 768px) {
    .sarf-split {
        flex-direction: column;
        height: auto;
        min-height: auto;
    }

    .sarf-list-panel {
        width: 100%;
        max-width: none;
        min-width: auto;
        border-inline-end: none;
        border-bottom: 1px solid var(--border-gray);
        max-height: 50vh;
    }

    .sarf-detail-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 85vh;
        background: var(--white);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: var(--shadow-modal);
        z-index: 100;
        transform: translateY(100%);
        transition: transform var(--transition-normal);
        padding: 16px;
    }
    .sarf-detail-panel.open {
        transform: translateY(0);
    }

    .sarf-detail-close {
        display: flex;
    }

    .sarf-saghir-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .sarf-detail-verb { font-size: 28px; }
    .sarf-saghir-btn-value { font-size: 18px; }

    /* Drag-handle для bottom sheet */
    .sarf-detail-panel::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border-gray);
        border-radius: 2px;
        margin: 0 auto 12px;
    }
}

@media (max-width: 480px) {
    .sarf-saghir-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    .sarf-saghir-btn {
        padding: 10px 6px;
    }
    .sarf-saghir-btn-value { font-size: 16px; }

    .sarf-form-selector {
        gap: 3px;
    }
    .sarf-form-chip {
        padding: 3px 8px;
        font-size: 11px;
    }
}
