/* ========== СТРАНИЦА ПОИСКА РАССКАЗОВ ========== */

/* Основной контейнер */
.search-page-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    height: 100vh;
    overflow: hidden;
}

/* Кнопка фильтров в мобильной шапке */
.mobile-filters-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--light-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.mobile-filters-toggle:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Кнопка фильтров для планшетов (769-1024px) */
.tablet-filters-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--light-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-left: 12px;
}

.tablet-filters-toggle:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Левая панель с фильтрами */
.search-filters-sidebar {
    background: var(--card-bg);
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.search-filters-sidebar::-webkit-scrollbar {
    width: 6px;
}

.search-filters-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.search-filters-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

/* Заголовок фильтров */
.filters-header {
    margin-bottom: 0;
}

.filters-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.filters-header h3 i {
    color: var(--primary);
}

/* Секция фильтра */
.filter-section {
    margin-bottom: 0;
}

.filter-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.filter-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.selected-count {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--light-bg);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

/* Кнопки сортировки */
.sort-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sort-btn {
    padding: 10px 16px;
    background: var(--light-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.sort-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.sort-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Поиск категорий */
.categories-search {
    position: relative;
    margin-bottom: 12px;
}

.categories-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 14px;
}

.categories-search input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background: var(--light-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.categories-search input:focus {
    background: var(--card-bg);
    border-color: var(--primary);
}

/* Список категорий */
.categories-list {
    max-height: 300px;
    overflow-y: auto;
}

.categories-list::-webkit-scrollbar {
    width: 4px;
}

.categories-list::-webkit-scrollbar-track {
    background: transparent;
}

.categories-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: var(--transition-fast);
    border-radius: var(--radius-md);
}

.category-item:hover {
    background: var(--primary-light);
}

.category-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.category-checkbox.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.category-checkbox.checked::after {
    content: '✓';
    color: var(--white);
    font-size: 10px;
    font-weight: bold;
}

.category-label {
    font-size: 14px;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-count {
    font-size: 12px;
    color: var(--text-tertiary);
    background: var(--light-bg);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

/* Кнопка очистки */
.clear-filters-btn {
    padding: 12px 16px;
    background: var(--light-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
}

.clear-filters-btn:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Правая часть с рассказами */
.search-results-main {
    overflow-y: auto;
    padding: 24px;
    background: var(--light-bg);
}

.search-results-main::-webkit-scrollbar {
    width: 8px;
}

.search-results-main::-webkit-scrollbar-track {
    background: transparent;
}

.search-results-main::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

/* Заголовок страницы */
.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-family: 'Playfair Display', serif;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 600px;
}

/* Шапка с результатами - ИСПРАВЛЕНО */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.results-count {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.results-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.active-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-tag {
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-tag i {
    font-size: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-tag i:hover {
    color: var(--primary-dark);
}

/* Список рассказов */
.stories-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Элемент рассказа */
.story-item {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.story-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Заголовок рассказа */
.story-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.story-title-container {
    flex: 1;
    min-width: 0;
}

.story-title {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-family: 'Playfair Display', serif;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    transition: var(--transition-fast);
}

.story-title:hover {
    color: var(--primary);
}

.story-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.meta-item i {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ========== СТИЛИ ДЛЯ БЕЙДЖЕЙ ========== */
.story-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

/* Бейдж аудио */
.audio-badge {
    flex-shrink: 0;
    padding: 6px 12px;
    background: var(--accent);
    color: var(--white);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: pulse 2s infinite;
    white-space: nowrap;
}

/* НОВЫЙ: Бейдж с фото */
.photo-badge {
    flex-shrink: 0;
    padding: 6px 12px;
    background: rgba(139, 92, 246, 0.1);
    color: rgb(139, 92, 246);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: var(--transition-fast);
}

.photo-badge:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateY(-1px);
}

.photo-badge i {
    font-size: 11px;
}

/* Описание рассказа */
.story-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Категории рассказа */
.story-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.story-category {
    padding: 6px 12px;
    background: var(--light-bg);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-light);
}

/* Футер рассказа - ИСПРАВЛЕНО: дата слева, кнопки справа */
.story-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.story-date {
    font-size: 13px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Кнопки действий справа - Читать и Закладка рядом */
.story-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.story-btn {
    padding: 8px 16px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--white);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    text-decoration: none;
}

.story-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    color: var(--white);
}

/* Кнопка закладки */
.bookmark-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--light-bg);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.bookmark-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(156, 39, 176, 0.1);
}

.bookmark-btn.bookmarked {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.bookmark-btn.bookmarked:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    padding: 20px;
}

.pagination-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.pagination-btn:hover:not(.disabled):not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.pagination-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-dots {
    color: var(--text-tertiary);
    font-size: 14px;
    padding: 0 4px;
}

/* Мобильная панель фильтров */
.mobile-filters-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.mobile-filters-content {
    background: var(--card-bg);
    width: 100%;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

.mobile-filters-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.mobile-filters-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-filters-header h3 i {
    color: var(--primary);
}

.mobile-filters-close {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--light-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.mobile-filters-close:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.mobile-filters-content .filter-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.mobile-filters-content .filter-section:last-child {
    border-bottom: none;
}

.mobile-filters-content .categories-list {
    max-height: 300px;
    flex: 1;
}

.mobile-filters-footer {
    padding: 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    margin-top: auto;
}

.mobile-clear-btn {
    flex: 1;
    padding: 14px;
    background: var(--light-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mobile-clear-btn:hover {
    background: var(--card-hover);
}

.mobile-apply-btn {
    flex: 1;
    padding: 14px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--white);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mobile-apply-btn:hover {
    background: var(--primary-dark);
}

/* Анимация пульсации для бейджа аудио */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(156, 39, 176, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(156, 39, 176, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(156, 39, 176, 0);
    }
}

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

/* Адаптивность */
@media (max-width: 1024px) {
    .search-page-container {
        grid-template-columns: 1fr;
    }

    .search-filters-sidebar {
        display: none;
    }

    .mobile-filters-toggle {
        display: flex;
    }

    .search-results-main {
        padding: 20px 16px;
    }

    .page-title {
        font-size: 28px;
    }

    .page-subtitle {
        font-size: 15px;
    }

    .results-header {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }

    .results-controls {
        margin-top: 0;
    }

    .story-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .story-badges {
        align-self: flex-start;
    }

    /* ИСПРАВЛЕНО: футер рассказа для планшетов - ВСЕ ТАК ЖЕ КАК НА ДЕСКТОПЕ */
    .story-footer {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .story-date {
        justify-content: flex-start;
    }

    .story-actions {
        justify-content: flex-end;
    }
}

@media (max-width: 768px) {
    .story-title {
        font-size: 18px;
    }

    .story-meta {
        flex-wrap: wrap;
        gap: 12px;
    }

    .story-description {
        -webkit-line-clamp: 2;
    }

    .story-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* ИСПРАВЛЕНО: на мобильных тоже дата слева, кнопки справа */
    .story-footer {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .story-date {
        font-size: 12px;
    }

    .story-actions {
        gap: 6px;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 6px;
        padding: 16px;
    }

    .pagination-btn {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    .mobile-filters-content .filter-section {
        padding: 16px;
    }

    .mobile-filters-header {
        padding: 16px;
    }

    .mobile-filters-footer {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .story-item {
        padding: 16px;
    }

    .story-title {
        font-size: 17px;
    }

    .story-btn {
        padding: 8px 12px;
        font-size: 12px;
        min-width: auto;
    }

    /* ИСПРАВЛЕНО: на самых маленьких экранах */
    .story-footer {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .story-date {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 40%;
    }

    .story-actions {
        gap: 4px;
        flex-shrink: 0;
    }

    .mobile-filters-content {
        max-height: 100vh;
    }
}

/* Для экранов 769px - 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
    .mobile-filters-toggle {
        display: flex;
    }

    .tablet-filters-toggle {
        display: flex;
    }

    .search-filters-sidebar {
        display: none;
    }

    /* ИСПРАВЛЕНО: на планшетах все элементы остаются на своих местах */
    .story-footer {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .story-date {
        justify-content: flex-start;
    }

    .story-actions {
        justify-content: flex-end;
    }
}

@media (min-width: 1025px) {
    .tablet-filters-toggle {
        display: none !important;
    }
}