/* Общие стили страницы */
body, html {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background:
        radial-gradient(circle at top, rgba(124, 58, 237, 0.10), transparent 25%),
        linear-gradient(135deg, #07111f 0%, #0f172a 45%, #111827 100%);
    color: #e5eefb;
    min-height: 100vh;
}

* { box-sizing: border-box; }

.books-page {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 40px 20px;
}

/* Поиск */
.search-section {
    margin-bottom: 32px;
}

.search-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-form input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.7);
    color: #eff6ff;
    font-size: 15px;
}

.search-btn {
    padding: 12px 24px;
    cursor: pointer;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-radius: 14px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.search-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* Сетка: строго 3 колонки по горизонтали */
.books-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    margin-bottom: 40px;
}

/* Карточка книги */
.book-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 35px rgba(124, 58, 237, 0.15);
}

/* Обертка для фото, чтобы контролировать пропорции и hover эффект */
.book-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4; /* Пропорция книжной обложки */
    overflow: hidden;
    background: #090d16;
}

.book-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.book-card:hover .book-image-wrap img {
    transform: scale(1.04);
}

/* Всплывающее окно с описанием при наведении на КАРТОЧКУ */
.book-hover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.6) 0%, rgba(7, 11, 22, 0.98) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 5;
}

.book-card:hover .book-hover-overlay {
    opacity: 1;
    visibility: visible;
}

.book-tile-desc {
    font-size: 0.92rem;
    line-height: 1.5;
    color: #e5eefb;
    margin: 0 0 16px 0;
}

.read-btn {
    padding: 10px 20px;
    border: 1px solid rgba(196, 181, 253, 0.4);
    border-radius: 10px;
    background: rgba(124, 58, 237, 0.25);
    color: #ddd6fe;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.read-btn:hover {
    background: rgba(124, 58, 237, 0.4);
    border-color: rgba(196, 181, 253, 0.8);
}

/* Блок информации СНИЗУ фотографии (всегда виден) */
.book-info-block {
    padding: 18px;
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid rgba(148, 163, 184, 0.08);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.book-tile-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: #fff;
    line-height: 1.3;
    /* Если название книги слишком длинное, оно аккуратно перенесется, но не сломает верстку */
    display: -webkit-box;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-tile-author {
    font-size: 0.9rem;
    margin: 0;
    color: #a78bfa; /* Красивый фиолетовый оттенок для автора */
}

/* Пагинация */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.page-link {
    padding: 10px 16px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.6);
    color: #eff6ff;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.page-link:hover {
    border-color: rgba(129, 140, 248, 0.6);
    background: rgba(124, 58, 237, 0.2);
}

/* Адаптивность для планшетов и мобилок */
@media (max-width: 900px) {
    .books-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .books-grid { grid-template-columns: 1fr; }
    .search-form { flex-direction: column; align-items: stretch; }
}

/* Обновленный контейнер хедера */
.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    padding: 12px 40px; /* Увеличили боковые отступы */
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
    display: flex;
    justify-content: space-between; /* Разносит навигацию и авторизацию по краям */
    align-items: center;
    z-index: 1000;
}

/* Группы элементов внутри хедера */
.nav-group, 
.auth-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Сброс обертки формы, чтобы кнопка не ломала flex-ряд */
.auth-group form {
    margin: 0;
    display: inline-flex;
}

/* Стиль для имени пользователя (ссылка на профиль) */
.user-profile-link {
    color: #c4b5fd !important;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(196, 181, 253, 0.2);
    transition: all 0.2s ease;
}

.user-profile-link:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(196, 181, 253, 0.4);
}

/* Красивая кнопка "Выйти" */
.logout-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    transform: translateY(-1px);
}

/* Стиль для кнопки "Войти" (когда пользователь не авторизован) */
.login-btn {
    color: #eff6ff;
    text-decoration: none;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(30, 41, 59, 0.95);
    border-radius: 999px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.18s ease;
}

.login-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(129, 140, 248, 0.8);
    background: #1e293b;
}

/* Адаптивность для мобильных экранов */
@media (max-width: 640px) {
    .fixed-header {
        flex-direction: column;
        gap: 12px;
        padding: 14px;
        position: static; /* Отключаем фиксацию на мобилках, чтобы не занимать экран */
    }
    .empty-content {
        padding-top: 20px; /* Убираем гигантский отступ, так как хедер больше не фиксирован */
    }
}
/* Стили для основных кнопок меню */
.menu-btn {
    background: rgba(30, 41, 59, 0.6); /* Полупрозрачный фон под стать бэкдроп-фильтру */
    color: #eff6ff;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 999px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Эффект при наведении на кнопку меню */
.menu-btn:hover {
    transform: translateY(-1px);
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(129, 140, 248, 0.7); /* Приятное индиго-свечение */
    box-shadow: 0 4px 15px rgba(129, 140, 248, 0.15);
    color: #fff;
}

/* Эффект при клике (кнопка слегка утапливается) */
.menu-btn:active {
    transform: translateY(1px);
    box-shadow: none;
}
/* Основной контейнер для контента */
.empty-content {
    /* ПУШ-эффект сверху: 64px (высота меню) + 24px (красивый зазор) = 88px */
    padding-top: 88px; 
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 48px;
    color: #dbe8ff;
}

/* Обновляем мобильный медиа-запрос, который мы писали ранее */
@media (max-width: 640px) {
    .fixed-header {
        position: static; /* На мобилках меню становится обычным (не фиксированным) */
        flex-direction: column;
        gap: 12px;
        padding: 14px;
    }
    
    .empty-content {
        /* Так как на мобильных меню больше не фиксировано и само расталкивает контент, 
           гигантский отступ сверху не нужен — уменьшаем его до аккуратных 24px */
        padding-top: 24px; 
    }
}
/* Контейнер страницы книги */
.book-detail-container {
    display: grid;
    grid-template-columns: 320px 1fr; /* Левая колонка фиксированная, правая занимает всё место */
    gap: 48px;
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 20px;
    align-items: start;
}

/* Левая колонка */
.book-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 100px; /* Обложка будет красиво "залипать" при скролле длинного описания */
}

/* Рамка для обложки */
.book-detail-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    background: #090d16;
}

.book-detail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #64748b;
    font-size: 16px;
}

/* Кнопка скачивания */
.download-large-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-radius: 14px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.2);
}

.download-large-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.4);
}

.download-large-btn:active {
    transform: translateY(0);
}

/* Правая колонка */
.book-detail-main {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 28px;
    padding: 40px;
    backdrop-filter: blur(8px);
}

/* Заголовок H1 */
.book-detail-title {
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 800;
    color: #fff;
    margin: 0 0 12px 0;
    line-height: 1.15;
}

/* Автор */
.book-detail-author {
    font-size: 1.1rem;
    color: #cbd5e1;
    margin: 0 0 24px 0;
}

.book-detail-author span {
    color: #c4b5fd; /* Выделяем автора фиолетовым */
    font-weight: 600;
}

/* Разделительная линия */
.book-detail-divider {
    height: 1px;
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.2) 0%, transparent 100%);
    margin-bottom: 28px;
}

/* Блок описания (включая стилизацию возможных HTML-тегов) */
.book-detail-description {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #e2e8f0;
}

/* Стили на случай, если внутри описания из админки прилетят теги */
.book-detail-description p {
    margin: 0 0 16px 0;
}

.book-detail-description strong, 
.book-detail-description b {
    color: #fff;
    font-weight: 600;
}

.book-detail-description ul, 
.book-detail-description ol {
    padding-left: 20px;
    margin: 0 0 16px 0;
}

/* Адаптивность для планшетов и мобильных телефонов */
@media (max-width: 850px) {
    .book-detail-container {
        grid-template-columns: 1fr; /* Перестраиваем в одну колонку */
        gap: 32px;
    }

    .book-detail-sidebar {
        position: static; /* Отключаем залипание обложки */
        max-width: 280px;
        margin: 0 auto;
        width: 100%;
    }

    .book-detail-main {
        padding: 24px;
    }
}
/* Стили для ссылок-жанров */
.book-detail-genre-link {
    display: inline-flex;
    text-decoration: none;
    margin-top: 24px; /* Отступ группы жанров от текста описания */
    margin-right: 10px; /* Зазор между тегами по горизонтали */
    margin-bottom: 8px; /* Зазор на случай, если теги перенесутся на вторую строку */
    transition: transform 0.2s ease;
}

/* Сама плашка жанра */
/* Стили для ссылок-жанров */
.book-detail-genre-link {
    display: inline-flex;
    text-decoration: none;
    margin-top: 24px; /* Отступ группы жанров от текста описания */
    margin-right: 10px; /* Зазор между тегами по горизонтали */
    margin-bottom: 8px; /* Зазор на случай, если теги перенесутся на вторую строку */
    transition: transform 0.2s ease;
}

/* Сама плашка жанра */
.book-detail-genre {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(124, 58, 237, 0.12); /* Полупрозрачный фиолетовый фон */
    border: 1px solid rgba(196, 181, 253, 0.2);
    border-radius: 999px; /* Круглые края (форма пилюли) */
    color: #ddd6fe; /* Светлый неон-текст */
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

/* Эффект при наведении на жанр */
.book-detail-genre-link:hover {
    transform: translateY(-2px); /* Легкое приподнятие */
}

.book-detail-genre-link:hover .book-detail-genre {
    background: rgba(124, 58, 237, 0.25); /* Фон становится ярче */
    border-color: rgba(167, 139, 250, 0.6); /* Подсветка границ */
    color: #fff; /* Текст становится чисто белым */
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25); /* Неоновое свечение */
}

/* Эффект при нажатии */
.book-detail-genre-link:active {
    transform: translateY(0);
}

/* Эффект при наведении на жанр */
.book-detail-genre-link:hover {
    transform: translateY(-2px); /* Легкое приподнятие */
}

.book-detail-genre-link:hover .book-detail-genre {
    background: rgba(124, 58, 237, 0.25); /* Фон становится ярче */
    border-color: rgba(167, 139, 250, 0.6); /* Подсветка границ */
    color: #fff; /* Текст становится чисто белым */
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25); /* Неоновое свечение */
}

/* Эффект при нажатии */
.book-detail-genre-link:active {
    transform: translateY(0);
}
/* Контейнер страницы */
.form-page-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 20px;
}

/* Карточка формы в стиле Glassmorphism */
.form-card {
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 20px;
    padding: 40px;
    width: min(650px, 100%);
    backdrop-filter: blur(12px);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
}

/* Заголовок формы */
.form-page-title {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin-top: 0;
    margin-bottom: 32px;
    text-align: center;
    letter-spacing: -0.02em;
}

/* Блок одного поля */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

/* Стили лейблов */
.form-label {
    font-size: 14px;
    font-weight: 600;
    color: #94a3b8;
}

.required-star {
    color: #ef4444;
    margin-left: 4px;
}

/* Универсальные стили для всех типов полей Django (ввод текста, чисел) */
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(9, 13, 22, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px; /* Скругленные прямоугольники как для жанров */
    color: #fff;
    font-size: 15px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

/* Фокус на полях ввода */
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #8b5cf6; /* Фиолетовое неоновое свечение */
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
    background: rgba(9, 13, 22, 0.8);
}

/* Специфика для текстового поля (Описание) */
.form-group textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

/* Поле выбора жанров (выпадающий список / select multiple) */
.form-group select[multiple] {
    min-height: 100px;
    padding: 8px;
}

.form-group select option {
    background: #0f172a;
    color: #cbd5e1;
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 2px;
}

.form-group select option:checked {
    background: #6366f1 !important;
    color: #fff;
}

/* Кастомизация полей загрузки файлов и аватарок */
.form-group input[type="file"] {
    color: #94a3b8;
    font-size: 14px;
    padding: 10px 0;
}

/* Стилизация системной кнопки выбора файла */
.form-group input[type="file"]::-webkit-file-upload-button {
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 6px;
    color: #ddd6fe;
    padding: 6px 12px;
    margin-right: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.form-group input[type="file"]::-webkit-file-upload-button:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(167, 139, 250, 0.5);
    color: #fff;
}

/* Сообщения об ошибках валидации */
.form-error-msg {
    color: #fca5a5;
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
}

.form-group.has-error input,
.form-group.has-error textarea,
.form-group.has-error select {
    border-color: rgba(239, 68, 68, 0.6) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* Главная кнопка отправки формы */
.submit-form-btn {
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.25);
}

.submit-form-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.45);
}

.submit-form-btn:active {
    transform: translateY(0);
}

/* Адаптивность для мобилок */
@media (max-width: 640px) {
    .form-card {
        padding: 24px 16px;
    }
}

/* Контейнер для сетки жанров */
.genre-selection-grid {
    display: flex;
    flex-wrap: wrap; /* Чтобы теги аккуратно переносились на новую строку */
    gap: 10px;
    padding: 6px 0;
}

/* Обертка-лейбл (делает всю область тега кликабельной) */
.genre-selectable-tag {
    cursor: pointer;
    user-select: none;
}

/* Полностью прячем стандартный уродливый чекбокс браузера */
.genre-selectable-tag input[type="checkbox"] {
    display: none;
}

/* Внешний вид невыбранного жанра (прямоугольник со скругленными краями) */
.genre-tag-box {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 6px; /* Прямоугольник со скруглением */
    color: #94a3b8;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

/* Эффект легкого подсвечивания при наведении на невыбранный тег */
.genre-selectable-tag:hover .genre-tag-box {
    border-color: rgba(167, 139, 250, 0.4);
    color: #cbd5e1;
    background: rgba(30, 41, 59, 0.7);
}

/* МАГИЯ: Стили для жанра, когда чекбокс ВЫБРАН (активное состояние) */
.genre-selectable-tag input[type="checkbox"]:checked + .genre-tag-box {
    background: rgba(124, 58, 237, 0.2); /* Фиолетовое неоновое свечение */
    border-color: #8b5cf6;
    color: #fff;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}

/* Эффект легкого нажатия */
.genre-selectable-tag:active .genre-tag-box {
    transform: scale(0.96);
}
/* --- СТИЛИЗАЦИЯ ОШИБОК ФОРМЫ --- */

/* Плашка глобальных ошибок (сверху формы) */
.form-alert-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(239, 68, 68, 0.1); /* Полупрозрачный красный */
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 28px;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.15);
}

.alert-icon {
    font-size: 20px;
    animation: pulse 2s infinite;
}

.alert-text-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.global-error-msg {
    margin: 0;
    color: #fca5a5;
    font-size: 14px;
    font-weight: 500;
}

/* Блок с ошибками под конкретным полем */
.field-errors-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

/* Текст ошибки под полем */
.form-error-msg {
    color: #f87171; /* Мягкий кораллово-красный */
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    animation: fadeIn 0.25s ease;
}

.error-bullet {
    color: #ef4444;
}

/* ХОТ-ФИКС ДЛЯ ПОЛЕЙ С ОШИБКАМИ (Класс .has-error навешивается через Django-шаблон) */
.form-group.has-error input[type="text"],
.form-group.has-error input[type="number"],
.form-group.has-error input[type="url"],
.form-group.has-error textarea,
.form-group.has-error select {
    border-color: rgba(239, 68, 68, 0.5) !important;
    background: rgba(239, 68, 68, 0.03) !important;
}

/* Фокус на поле, в котором допущена ошибка */
.form-group.has-error input:focus,
.form-group.has-error textarea:focus,
.form-group.has-error select:focus {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
}

/* Если ошибка в жанрах, подсветим рамки невыбранных карточек */
.form-group.has-error .genre-tag-box {
    border-color: rgba(239, 68, 68, 0.25);
}

/* Анимации для плавности */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Основной контейнер страницы авторов */
.authors-page-container {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 20px;
}

/* Сетка карточек: автоматически подстраивается под экраны (от мобилок до ПК) */
.authors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

/* Карточка автора (Прямоугольник со скругленными краями) */
.author-card {
    background: rgba(15, 23, 42, 0.45); /* Полупрозрачный темный фон */
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 14px; /* Скругление краев */
    padding: 24px;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center; /* Центрируем контент внутри */
    text-align: center;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Эффект при наведении на карточку */
.author-card:hover {
    transform: translateY(-4px); /* Легкое приподнятие */
    border-color: rgba(139, 92, 246, 0.4); /* Фиолетовое окаймление */
    box-shadow: 0 15px 35px rgba(139, 92, 246, 0.15); /* Мягкое свечение */
}

/* Имя автора */
.author-card-name {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 16px 0;
    letter-spacing: -0.01em;
}

/* Кастомная разделительная полоса (градиент растворяется по бокам) */
.author-card-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(148, 163, 184, 0.2) 50%, transparent 100%);
    margin-bottom: 20px;
}

/* Кнопка «Читать» */
.author-read-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%; /* Кнопка растягивается по ширине контента карточки */
    padding: 10px 20px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(196, 181, 253, 0.15);
    border-radius: 8px; /* Скругленные края для кнопки */
    color: #ddd6fe;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

/* Эффект при наведении на кнопку */
.author-read-btn:hover {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* Эффект клика */
.author-read-btn:active {
    transform: scale(0.98);
}


/* Сброс стандартного оформления кнопки */
.add-to-favorites-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;        /* убирает лишнее пространство вокруг картинки */
}

/* Размер иконки – подберите под ваш PNG (например, 36px) */
.heart-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;   /* сохраняет пропорции, если PNG не квадратный */
    display: block;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Лёгкий эффект при наведении */
.add-to-favorites-btn:hover .heart-icon {
    transform: scale(1.12);
    opacity: 0.9;
}

/* Если нужно, можно добавить отступы вокруг кнопки, не трогая саму иконку */
/*
.add-to-favorites-btn {
    margin-left: 10px;
}
*/

.favorites-actions {
    display: flex;
    gap: 15px;          /* расстояние между кнопками */
    align-items: center;
    margin: 10px 0;
}

/* Если кнопки-формы имеют фиксированную ширину или высоту, можно убрать лишние отступы */
.add-to-favorites-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
/* Контейнер профиля */
.profile-container {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 20px;
}

/* Заголовок профиля */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 48px;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(196, 181, 253, 0.4);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.3);
    background: #090d16;
    margin-bottom: 20px;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #64748b;
    font-size: 16px;
}

.profile-username {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
    margin: 0 0 8px 0;
    letter-spacing: -0.02em;
}

.profile-bio {
    font-size: 1.1rem;
    color: #94a3b8;
    max-width: 600px;
    line-height: 1.6;
    margin: 0;
}

/* Заголовки секций */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #c4b5fd;
    margin: 0 0 20px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #8b5cf6, #6366f1);
    border-radius: 3px;
}

.profile-books-section {
    margin-bottom: 48px;
}

/* Ссылка-обёртка карточки, чтобы вся карточка была кликабельной и не нарушала стили */
.book-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* Пустое сообщение */
.empty-message {
    color: #64748b;
    font-style: italic;
    text-align: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 12px;
    border: 1px dashed rgba(148, 163, 184, 0.2);
}

/* ----- Двухколоночный макет для списков книг ----- */
.profile-books-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;  /* две равные колонки */
  gap: 40px;                       /* расстояние между колонками */
  margin-top: 20px;
}

/* Адаптация сетки книг внутри колонок – можно использовать 2 колонки вместо трёх,
   чтобы карточки не становились слишком мелкими */
.profile-books-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* На мобильных устройствах колонки перестраиваются одна под другой */
@media (max-width: 768px) {
  .profile-books-columns {
    grid-template-columns: 1fr;   /* одна колонка */
    gap: 30px;
  }

  .profile-books-grid {
    grid-template-columns: 1fr;   /* карточки в одну колонку */
  }
}

/* Форма комментария */
/* --- КОММЕНТАРИИ: единый стиль с тёмной темой + авто-высота --- */
.comment-form {
    width: 100%;
    box-sizing: border-box;
    margin-top: 40px;
    padding: 24px;
    background: rgba(15, 23, 42, 0.5);   /* тёмный полупрозрачный, как у карточек */
    backdrop-filter: blur(8px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 20px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-form:hover {
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.1);
}

.comment-field {
    margin-bottom: 18px;
}

.comment-textarea {
    width: 100%;
    padding: 14px 18px;
    font-size: 15px;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: rgba(9, 13, 22, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 16px;
    color: #e2e8f0;
    resize: none;               /* запрещаем ручное изменение размера */
    overflow-y: hidden;         /* скрываем стандартный скролл, высота будет автоматической */
    transition: all 0.2s ease;
    line-height: 1.5;
    box-sizing: border-box;
}

.comment-textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    background: rgba(9, 13, 22, 0.9);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.submit-comment-btn {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: none;
    padding: 12px 28px;
    border-radius: 40px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.submit-comment-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
    background: linear-gradient(135deg, #9b6cff, #7274f5);
}

.submit-comment-btn:active {
    transform: translateY(0);
}

.error-message {
    color: #f87171;
    font-size: 13px;
    margin-top: 8px;
    margin-left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}



/* ===== БЛОК КОММЕНТАРИЕВ ===== */
.comments-section {
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.comments-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #c4b5fd;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.comments-count {
    font-size: 0.9rem;
    background: rgba(124, 58, 237, 0.2);
    padding: 4px 10px;
    border-radius: 20px;
    color: #a78bfa;
    font-weight: 500;
}

/* Карточка одного комментария */
.comment-card {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 20px;
    padding: 18px 24px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.comment-card:hover {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateX(4px);
}

/* Имя автора */
.comment-author {
    font-weight: 700;
    color: #c4b5fd;      /* фиолетовый акцент */
    font-size: 0.9rem;
    margin-bottom: 8px;
    display: inline-block;
    padding: 4px 12px;
    background: rgba(124, 58, 237, 0.15);
    border-radius: 30px;
    letter-spacing: 0.3px;
}

/* Текст комментария */
.comment-text {
    font-size: 1rem;
    line-height: 1.5;
    color: #e2e8f0;
    margin: 8px 0 0 0;
    word-break: break-word;
}

/* Пустое состояние */
.empty-comments {
    text-align: center;
    padding: 32px;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 20px;
    color: #94a3b8;
    font-style: italic;
    border: 1px dashed rgba(148, 163, 184, 0.2);
}

/* Адаптация для мобилок */
@media (max-width: 600px) {
    .comment-card {
        padding: 14px 18px;
    }
    .comment-author {
        font-size: 0.85rem;
    }
    .comment-text {
        font-size: 0.9rem;
    }
}
.comment-author a {
    color: inherit;          /* наследует цвет от родительского .comment-author */
    text-decoration: none;   /* убирает подчёркивание */
    font-weight: inherit;    /* наследует жирность */
    background: inherit;     /* если у родителя был фон, ссылка его унаследует */
}

/* Опционально: при наведении оставить тот же цвет, но добавить лёгкое подчёркивание или свечение (по желанию) */
.comment-author a:hover {
    text-decoration: underline; /* или none, если не нужно */
    color: #a78bfa;            /* можно сделать чуть ярче при наведении, но не обязательно */
}
.form-help-text {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
    display: block;
}

/* Добавить поддержку email и password */
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    background: rgba(9, 13, 22, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
    background: rgba(9, 13, 22, 0.8);
}

/* ===== СТИЛИ ДЛЯ СТРАНИЦЫ АДМИНИСТРАТОРА (модерация книг) ===== */

/* 1. Описание книги в карточке (всегда видимое, с ограничением строк) */
.admin-book-desc {
    font-size: 0.85rem;
    line-height: 1.4;
    color: #cbd5e1;
    margin: 8px 0 16px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;      /* максимум 3 строки */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 2. Группа кнопок действий (одобрить / удалить) */
.admin-action-buttons {
    display: flex;
    gap: 12px;
    margin-top: auto;           /* прижимаем к низу карточки */
    flex-wrap: wrap;
}

/* Общий стиль для кнопок форм внутри карточки */
.admin-action-buttons form {
    margin: 0;
    flex: 1;
}

/* Кнопка "Одобрить книгу" */
.approve-btn {
    width: 100%;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.35);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #bbf7d0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.approve-btn:hover {
    background: rgba(34, 197, 94, 0.3);
    border-color: #4ade80;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
}

/* Кнопка "Удалить книгу" */
.delete-btn {
    width: 100%;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fecaca;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #f87171;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* 3. Жанры на карточке (пилюли) */
.admin-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0 16px;
}

.genre-pill {
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(196, 181, 253, 0.2);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #c4b5fd;
    letter-spacing: 0.02em;
}

/* 4. Заголовок страницы админа (опционально) */
.admin-page-header {
    margin-bottom: 32px;
    text-align: center;
}

.admin-page-header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 8px;
}

.admin-page-header p {
    color: #94a3b8;
}

/* 5. Адаптив для кнопок на мобилках */
@media (max-width: 640px) {
    .admin-action-buttons {
        flex-direction: column;
        gap: 8px;
    }
}

/* Стили для disabled-полей */
.disabled-field {
    background: rgba(30, 41, 59, 0.4) !important;
    border-color: rgba(148, 163, 184, 0.15) !important;
    color: #94a3b8 !important;
    cursor: not-allowed;
    opacity: 0.8;
}

/* Стиль для textarea в форме (если ещё не определён) */
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(9, 13, 22, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 15px;
    transition: all 0.2s ease;
    font-family: inherit;
    resize: none;       
}

.form-textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
    background: rgba(9, 13, 22, 0.8);
}

/* Кнопка редактирования профиля */
.edit-profile-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 28px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(99, 102, 241, 0.1));
    border: 1px solid rgba(196, 181, 253, 0.3);
    border-radius: 40px;
    color: #c4b5fd;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s ease;
    backdrop-filter: blur(4px);
}

.edit-profile-btn:hover {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(99, 102, 241, 0.2));
    border-color: #8b5cf6;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(124, 58, 237, 0.25);
}

.edit-profile-btn:active {
    transform: translateY(0);
}