/* 1. ГЛОБАЛЬНІ НАЛАШТУВАННЯ ТА ЗМІННІ */
:root {
    --primary-color: #8b5a2b;
    --primary-dark: #6d4520;
    --bg-color: #fdfbf7;
    --text-color: #333;
    --light-text: #666;
    --border-color: #eee;
    --accent-bg: #f4e4bc;
    --white: #ffffff;
}

* { box-sizing: border-box; }

body {
    font-family: 'Open Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 2. ШАПКА ТА НАВІГАЦІЯ (STICKY) */
.site-header {
    background: var(--white);
    border-bottom: 3px solid var(--primary-color);
    padding: 12px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.logo {
    text-decoration: none;
    color: var(--primary-color);
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-grow: 1;
    justify-content: flex-end;
}

.main-nav ul {
    list-style: none;
    display: flex;
    gap: 15px;
    padding: 0;
    margin: 0;
}

.main-nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    transition: color 0.2s;
    white-space: nowrap;
}

.main-nav a:hover { color: var(--primary-color); }

/* ПОШУК У ШАПЦІ */
.header-search {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
}

.header-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.8rem;
    width: 90px;
    transition: width 0.3s;
}

.header-search input:focus { width: 150px; }

.header-search button {
    background: none; border: none; cursor: pointer;
    color: var(--primary-color); display: flex; align-items: center;
    padding: 0; margin-left: 5px;
}

/* 3. КОНТЕНТ ТА ХЛІБНІ КРИХТИ */
.main-container { flex: 1; padding: 40px 0; }

.breadcrumbs { margin-bottom: 30px; color: var(--light-text); font-size: 0.85rem; }
.breadcrumbs a { color: var(--light-text); text-decoration: none; }
.breadcrumbs .sep { margin: 0 8px; color: #ccc; }
.breadcrumbs .current { color: var(--text-color); font-weight: 600; }

/* 4. БІБЛІОТЕКА: ХАБ (ВІТРИНА) */
.layout-hub { text-align: center; }
.hub-wrapper { max-width: 1000px; margin: 0 auto; }
.hub-title { font-family: 'Merriweather', serif; color: var(--primary-color); font-size: 2.2rem; margin-bottom: 10px; }
.hub-subtitle { color: var(--light-text); margin-bottom: 40px; }

.hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 25px; }
.hub-card {
    display: flex; align-items: center; background: var(--white);
    border: 1px solid #ddd; border-radius: 10px; padding: 25px;
    text-decoration: none; transition: all 0.3s ease; text-align: left;
}
.hub-card:hover { border-color: var(--primary-color); transform: translateY(-5px); box-shadow: 0 12px 25px rgba(139, 90, 43, 0.1); }
.hub-card-icon {
    background: var(--accent-bg); color: var(--primary-color);
    width: 60px; height: 60px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; margin-right: 20px; flex-shrink: 0;
}
.hub-card-content h3 { margin: 0 0 5px 0; color: #333; font-size: 1.2rem; }
.hub-link { color: var(--primary-color); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; }

/* 5. БІБЛІОТЕКА: КАТАЛОГ (САЙДБАР + СПИСОК) */
.library-layout { display: grid; grid-template-columns: 260px 1fr; gap: 40px; align-items: start; }
.library-sidebar { background: var(--white); padding: 20px; border: 1px solid var(--border-color); border-radius: 5px; }
.sidebar-title { font-size: 1.1rem; color: var(--primary-color); border-bottom: 2px solid var(--accent-bg); padding-bottom: 10px; margin-bottom: 15px; font-family: 'Merriweather', serif; }
.sidebar-menu { list-style: none; padding: 0; margin: 0; }
.sidebar-menu li { margin-bottom: 8px; border-bottom: 1px solid #f9f9f9; padding-bottom: 8px; }
.sidebar-menu a { text-decoration: none; color: #444; font-size: 0.9rem; display: block; transition: 0.2s; }
.sidebar-menu a:hover { color: var(--primary-color); padding-left: 5px; }
.active-cat { color: var(--primary-color) !important; font-weight: 700 !important; border-left: 3px solid var(--primary-color); padding-left: 8px !important; }

/* 6. КАРТКА КНИГИ */
.book-item { display: flex; gap: 30px; margin-bottom: 40px; padding-bottom: 40px; border-bottom: 1px solid var(--border-color); }
.book-item:last-child { border-bottom: none; }
.book-item:target { background-color: #fffdf5; border-color: var(--primary-color); box-shadow: 0 0 15px rgba(139, 90, 43, 0.1); padding: 20px; border-radius: 8px; }

.book-cover { flex-shrink: 0; width: 180px; }
.book-cover img { width: 100%; height: auto; box-shadow: 0 5px 15px rgba(0,0,0,0.15); border-radius: 2px; }
.no-cover { width: 100%; height: 250px; background: var(--accent-bg); display: flex; align-items: center; justify-content: center; text-align: center; color: var(--primary-color); font-weight: bold; }

.book-title { margin: 0 0 10px 0; color: var(--primary-color); font-size: 1.5rem; font-family: 'Merriweather', serif; line-height: 1.2; font-weight: 700; }
.book-author { color: #2c3e50; font-size: 1.05rem; margin-bottom: 18px; font-weight: 600; font-variant: small-caps; letter-spacing: 0.5px; display: block; }
.book-year { color: var(--light-text); font-size: 0.9rem; margin-bottom: 15px; font-style: italic; }
.book-desc { color: #444; margin-bottom: 25px; text-align: justify; }

.btn-view { display: inline-block; background: var(--primary-color); color: var(--white); padding: 10px 25px; text-decoration: none; font-weight: 600; border-radius: 4px; transition: background 0.2s; font-size: 0.9rem; }
.btn-view:hover { background: var(--primary-dark); }

/* 7. ІМЕННИЙ ПОКАЖЧИК (АВТОРИ) */
.letters-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 40px; padding: 20px; background: var(--white); border: 1px solid var(--border-color); border-radius: 5px; }
.letters-nav a { text-decoration: none; color: var(--primary-color); font-weight: bold; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 4px; transition: 0.2s; }
.letters-nav a:hover { background: var(--primary-color); color: var(--white); }
.letter-block { margin-bottom: 40px; }
.letter-title { color: #2c3e50; border-bottom: 2px solid var(--primary-color); display: inline-block; padding-right: 20px; margin-bottom: 15px; }
.authors-links { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.authors-links a { text-decoration: none; color: #444; }
.authors-links a:hover { color: var(--primary-color); text-decoration: underline; }

/* 8. ПОШУК ТА СТАТИЧНІ БЛОКИ */
.search-group { margin-bottom: 45px; }
.search-group-title { font-size: 1.15rem; background: var(--accent-bg); color: var(--primary-dark); padding: 10px 20px; border-radius: 5px; margin-bottom: 20px; font-family: 'Merriweather', serif; }
.author-result-link { background: var(--white); border: 1px solid #ddd; padding: 6px 18px; text-decoration: none; color: #333; border-radius: 20px; font-weight: 600; }
.alert-box { padding: 20px; margin-bottom: 25px; border-radius: 5px; border: 1px solid transparent; }
.alert-blue { background: #e7f3ff; color: #004085; border-color: #d1e7ff; }
.alert-yellow { background: #fff9e6; color: #856404; border-color: #ffecb5; }

/* 9. ПЛАВАЮЧЕ ОГОЛОШЕННЯ */
.side-alert-box {
    position: fixed; right: 20px; bottom: 20px; width: 320px; background: var(--white);
    border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 20px; z-index: 9999; display: none; animation: slideInRight 0.5s ease-out;
}
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.side-alert-box.alert-blue { border-left: 5px solid #0056b3; background: #f0f7ff; }
.close-alert { position: absolute; top: 5px; right: 10px; background: none; border: none; font-size: 1.5rem; color: #999; cursor: pointer; }

/* 10. ФУТЕР */
.site-footer { background: #2c2c2c; color: #bbb; padding: 30px 0; text-align: center; margin-top: auto; }

/* 11. АДАПТИВНІСТЬ */
@media (max-width: 1100px) {
    .logo { font-size: 1.1rem; }
    .main-nav a { font-size: 0.7rem; gap: 8px; }
}

@media (max-width: 900px) {
    .header-content { flex-direction: column; text-align: center; }
    .header-right { width: 100%; justify-content: center; flex-direction: column; gap: 15px; }
    .main-nav ul { justify-content: center; flex-wrap: wrap; }
    .library-layout { grid-template-columns: 1fr; }
    .library-sidebar { margin-bottom: 30px; order: -1; }
}

@media (max-width: 600px) {
    .main-nav a { font-size: 0.65rem; }
    .header-search { width: 100%; }
    .header-search input { width: 100% !important; }
    .book-item { flex-direction: column; align-items: center; text-align: center; }
    .book-cover { width: 150px; }
    .side-alert-box { right: 0; left: 0; bottom: 0; width: 100%; border-radius: 15px 15px 0 0; }
}