* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
    padding: 20px;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    overflow: hidden;
}

#header {
    background: linear-gradient(135deg, #2c3e50 0%, #4a6491 100%);
    color: white;
    padding: 20px 30px;
}

#app-title {
    font-size: 2.5rem;
    margin-bottom: 15px;
    text-align: center;
}

#nav-list {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 0;
}

.nav-item button,
.nav-link {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.nav-item button:hover,
.nav-link:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.page-section {
    display: none;
    padding: 30px;
}

.page-section.active {
    display: block;
}

.section-title {
    color: #2c3e50;
    margin-bottom: 25px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4a6491;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    max-width: 400px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4a6491;
    box-shadow: 0 0 0 2px rgba(74, 100, 145, 0.2);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

button {
    padding: 12px 24px;
    background: #4a6491;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

button:hover {
    background: #2c3e50;
}

#library-table-container {
    overflow-x: auto;
    margin: 25px 0;
}

#books-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#books-table th {
    background-color: #4a6491;
    color: white;
    padding: 15px;
    text-align: left;
}

#books-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

#books-table tbody tr:hover {
    background-color: #f5f9ff;
}

#stats-list,
#results-list {
    list-style: none;
    padding: 0;
}

#stats-list li,
#results-list li {
    background: #f8f9fa;
    padding: 15px;
    margin-bottom: 10px;
    border-left: 4px solid #4a6491;
    border-radius: 0 5px 5px 0;
}

#app-footer {
    text-align: center;
    padding: 25px 30px;
    background: #f8f9fa;
    border-top: 2px solid #eee;
    color: #666;
}

#footer-content {
    max-width: 600px;
    margin: 0 auto;
}

#footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
}

#footer-links a {
    color: #4a6491;
    text-decoration: none;
    transition: color 0.3s;
}

#footer-links a:hover {
    color: #2c3e50;
    text-decoration: underline;
}

@media (max-width: 768px) {
    #nav-list {
        flex-direction: column;
        align-items: center;
    }
    
    .nav-item {
        width: 100%;
    }
    
    .nav-item button,
    .nav-link {
        width: 100%;
        text-align: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    #footer-links {
        flex-direction: column;
        gap: 10px;
    }
    
    .page-section {
        padding: 20px;
    }
}




/* Додати після #app-title */
#burger-menu {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

@media (max-width: 768px) {
    #burger-menu {
        display: block;
    }
    
    #main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        height: 100vh;
        background: #2c3e50;
        z-index: 999;
        transition: right 0.3s ease-in-out;
        padding-top: 80px;
        box-shadow: -5px 0 15px rgba(0,0,0,0.2);
    }
    
    #main-nav.active {
        right: 0;
    }
    
    #nav-list {
        flex-direction: column;
        align-items: stretch;
        padding: 0 20px;
    }
    
    .nav-item {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .nav-item button,
    .nav-link {
        width: 100%;
        text-align: left;
        padding: 15px;
        border: none;
        background: rgba(255,255,255,0.05);
    }
    
    #header {
        position: relative;
        padding-bottom: 15px;
    }
}




.view-toggle-container {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #eee;
}

.view-toggle-btn {
    background: #4a6491;
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(74, 100, 145, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.view-toggle-btn:hover {
    background: #2c3e50;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(74, 100, 145, 0.3);
}

.view-toggle-btn:active {
    transform: translateY(-1px);
}

/* Адаптивна grid-сітка */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin: 30px 0;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.5s ease;
}

.books-grid.active {
    opacity: 1;
    max-height: 5000px;
}

/* Стилі для картки книги */
.book-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 2px solid transparent;
    position: relative;
    animation: cardAppear 0.5s ease backwards;
}

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

.book-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
    border-color: #4a6491;
}

.book-card-header {
    background: linear-gradient(135deg, #4a6491 0%, #2c3e50 100%);
    color: white;
    padding: 25px 20px 20px 20px;
    position: relative;
}

.book-id {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.book-card-title {
    font-size: 1.4rem;
    margin: 0 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.book-card-author {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.book-card-author::before {
    content: "👤";
    font-size: 0.9em;
}

.book-card-content {
    padding: 20px;
}

.book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.book-genre {
    background: #eef2f7;
    color: #4a6491;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.book-genre::before {
    content: "🏷️";
}

.book-year {
    color: #666;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.book-year::before {
    content: "📅";
}

.book-description {
    color: #555;
    line-height: 1.6;
    font-size: 1rem;
    margin-bottom: 20px;
    min-height: 4.8em;
    display: -webkit-box;
    /* -webkit-line-clamp: 3; */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.book-action-btn {
    flex: 1;
    padding: 10px 15px;
    background: #f5f7fa;
    border: 2px solid #e0e5ec;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
}

.book-action-btn:hover {
    background: #4a6491;
    color: white;
    border-color: #4a6491;
    transform: translateY(-2px);
}

.book-action-btn:first-child {
    background: #4a6491;
    color: white;
    border-color: #4a6491;
}

.book-action-btn:first-child:hover {
    background: #2c3e50;
    border-color: #2c3e50;
}

/* Анімація появи карток по черзі */
.book-card:nth-child(1) { animation-delay: 0.1s; }
.book-card:nth-child(2) { animation-delay: 0.2s; }
.book-card:nth-child(3) { animation-delay: 0.3s; }
.book-card:nth-child(4) { animation-delay: 0.4s; }
.book-card:nth-child(5) { animation-delay: 0.5s; }
.book-card:nth-child(6) { animation-delay: 0.6s; }

/* Адаптивність */
@media (max-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 992px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 18px;
    }
    
    .book-card-header {
        padding: 20px 15px 15px 15px;
    }
    
    .book-card-content {
        padding: 18px;
    }
    
    .book-card-title {
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    .books-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .view-toggle-btn {
        width: 100%;
        justify-content: center;
        padding: 16px;
    }
    
    .book-actions {
        flex-direction: column;
    }
}

/* Приховуємо grid за замовчуванням */
#books-grid-container:not(.active) {
    display: none;
}