/* ========================================
   IFTA SEARCH — v2.0 с inline-результатами
   ======================================== */

/* ── Секция поиска (стиль, аналогичный Хадисам) ── */
.ifta-search-section {
    padding: 20px 24px 0;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 50;
}

/* ── Обёртка поля (flex-контейнер с бордером) ── */
.ifta-search-container {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1.5px solid var(--border-gray);
    border-radius: 12px;
    padding: 0 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}

.ifta-search-container:focus-within {
    border-color: var(--emerald);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 10%, transparent);
}

/* Когда результаты открыты — скругление только сверху */
.ifta-search-container.search-active {
    border-radius: 12px 12px 0 0;
    border-bottom-color: transparent;
}

/* ── Поле поиска ── */
.ifta-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 14px 12px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    background: transparent;
    color: #1f2937;
    box-sizing: border-box;
}

.ifta-search-input::placeholder {
    color: #9ca3af;
}

/* ── Иконка лупы (левая) ── */
.ifta-search-icon {
    color: #9ca3af;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.ifta-search-container:focus-within .ifta-search-icon {
    color: var(--emerald);
}

/* ── Правые элементы: счётчик + кнопка очистки ── */
.ifta-search-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ifta-search-count {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.ifta-search-count.visible {
    opacity: 1;
}

.ifta-search-clear {
    width: 24px;
    height: 24px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: background 0.15s;
}

.ifta-search-clear.visible {
    display: flex;
}

.ifta-search-clear:hover {
    background: #e5e7eb;
    color: #374151;
}

/* ── Подсказка под полем ── */
.ifta-search-hint {
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 8px;
    transition: opacity 0.2s ease;
}

.ifta-search-hint.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ========================================
   БЛОК РЕЗУЛЬТАТОВ ПОИСКА (inline)
   ======================================== */

.ifta-search-results {
    position: absolute;
    top: calc(100% - 1px); /* прилипает к контейнеру */
    left: -1.5px;
    right: -1.5px;
    background: var(--white);
    border: 1.5px solid var(--emerald);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 16px 50px color-mix(in srgb, var(--emerald) 18%, transparent);
    max-height: 500px;
    overflow-y: auto;
    z-index: 200;

    /* Анимация появления */
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ifta-search-results.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

/* Скроллбар внутри результатов */
.ifta-search-results::-webkit-scrollbar { width: 4px; }
.ifta-search-results::-webkit-scrollbar-track { background: transparent; }
.ifta-search-results::-webkit-scrollbar-thumb { background: var(--border-gray); border-radius: 4px; }

/* ── Заголовок раздела внутри результатов ── */
.search-results-header {
    padding: 12px 20px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--medium-gray);
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-results-header .search-tag {
    background: var(--emerald-50);
    color: var(--emerald-dark);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

/* ── Один результат — фетва ── */
.search-result-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 20px;
    cursor: pointer;
    border-bottom: 1px solid var(--light-gray);
    transition: background 0.15s ease;
    text-decoration: none;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--emerald-50);
}

.search-result-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--emerald-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-top: 1px;
    transition: background 0.15s ease;
}

.search-result-item:hover .search-result-icon {
    background: var(--emerald);
}

.search-result-icon svg {
    width: 16px;
    height: 16px;
    color: var(--emerald-dark);
    transition: color 0.15s ease;
}

.search-result-item:hover .search-result-icon svg {
    color: white;
}

.search-result-body {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s ease;
}

.search-result-item:hover .search-result-title {
    color: var(--emerald-dark);
}

.search-result-excerpt {
    font-size: 12px;
    color: var(--medium-gray);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-path {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    font-size: 11px;
    color: var(--medium-gray);
    opacity: 0.7;
}

.search-result-path svg {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

.search-result-path span + span::before {
    content: '›';
    margin-inline-end: 4px;
    color: var(--border-gray);
}

/* ── Подсветка найденного слова ── */
mark.search-highlight {
    background: none;
    color: var(--emerald);
    font-weight: 700;
}

/* ── Результат-книга (тема) ── */
.search-result-item.result-topic .search-result-icon {
    background: #eff6ff;
}

.search-result-item.result-topic:hover .search-result-icon {
    background: #3b82f6;
}

.search-result-item.result-topic .search-result-icon svg {
    color: #3b82f6;
}

.search-result-item.result-topic:hover .search-result-icon svg {
    color: white;
}

/* ── Пустое состояние ── */
.search-empty {
    padding: 36px 24px;
    text-align: center;
}

.search-empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.search-empty-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 6px;
}

.search-empty-sub {
    font-size: 13px;
    color: var(--medium-gray);
    line-height: 1.6;
}

.search-empty-cta {
    display: inline-block;
    margin-top: 14px;
    padding: 8px 18px;
    background: var(--emerald);
    color: white;
    font-size: 13px;
    font-weight: 500;
    border-radius: 20px;
    cursor: pointer;
    border: none;
    transition: background 0.2s ease;
}

.search-empty-cta:hover {
    background: var(--emerald-dark);
}

/* ── Нижний бар результатов ── */
.search-results-footer {
    padding: 10px 20px;
    background: var(--light-gray);
    border-top: 1px solid var(--border-gray);
    font-size: 11px;
    color: var(--medium-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 12px 12px;
}

.search-results-footer kbd {
    background: white;
    border: 1px solid var(--border-gray);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10px;
    font-family: monospace;
}


/* ========================================
   КАРТОЧКИ КНИГ — переход при поиске
   ======================================== */

.ifta-topics-section {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ifta-topics-section.search-hidden {
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* ========================================
   INLINE РЕЗУЛЬТАТЫ НА СТРАНИЦЕ
   (когда нет фокуса — раскрываются ниже)
   ======================================== */

.ifta-inline-results {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.ifta-inline-results-inner {
    background: var(--white);
    border: 2px solid var(--border-gray);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: resultsAppear 0.25s ease both;
}

@keyframes resultsAppear {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* ── SVG-иконка пустого поиска (вместо emoji) ── */
.search-empty-icon svg {
    vertical-align: -0.125em;
}
