:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --accent-color: #e74c3c;
    --background-color: #f5f7fa;
    --text-color: #2c3e50;
    --header-background-color: #34495e;
    --header-text-color: #ffffff;
    --card-background-color: #ffffff;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --card-hover-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --transition: all 0.3s ease;
    --font-family: 'Segoe UI', Arial, sans-serif;
    --font-size-small: 14px;
    --font-size-medium: 16px;
    --font-size-large: 18px;
    --font-size-xlarge: 24px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    line-height: 1.6;
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--header-background-color);
    color: var(--header-text-color);
    padding: var(--spacing-md) var(--spacing-xl);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header h1 {
    font-size: var(--font-size-xlarge);
    font-weight: 700;
    margin: 0;
}

header nav ul {
    list-style: none;
    display: flex;
    gap: var(--spacing-lg);
}

header nav ul li a {
    color: var(--header-text-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
}

header nav ul li a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg);
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Search Section */
.search {
    margin-bottom: var(--spacing-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.search h2 {
    margin-bottom: var(--spacing-md);
    color: var(--text-color);
    font-weight: 600;
}

.search-input {
    display: flex;
    width: 100%;
    max-width: 600px;
    margin-bottom: var(--spacing-lg);
}

.search-input input {
    flex: 1;
    padding: var(--spacing-md);
    border: 1px solid #ddd;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    font-size: var(--font-size-medium);
    outline: none;
    transition: var(--transition);
}

.search-input input:focus {
    border-color: var(--primary-color);
}

.search-input button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.search-input button:hover {
    background-color: #2980b9;
}

.search-results {
    width: 100%;
    max-width: 600px;
}

.search-results-header {
    margin-bottom: var(--spacing-md);
    font-weight: 600;
}

.search-result-item {
    background-color: var(--card-background-color);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.search-result-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.search-result-item h3 {
    margin-bottom: var(--spacing-xs);
    font-weight: 600;
}

/* Book Details Section */
.book-details {
    display: flex;
    flex-direction: column;
}

.book-details h2 {
    margin-bottom: var(--spacing-lg);
    text-align: center;
    font-weight: 600;
}

#book-details-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#add-book {
    margin-bottom: var(--spacing-xl);
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: var(--font-size-medium);
    font-weight: 500;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#add-book:hover {
    background-color: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#library-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    width: 100%;
}

.empty-library-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--spacing-xl);
    color: #7f8c8d;
    font-style: italic;
}

/* Card Styles */
.card {
    background-color: var(--card-background-color);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card:hover {
    box-shadow: var(--card-hover-shadow);
    transform: translateY(-5px);
}

.card-header {
    padding: var(--spacing-md);
    background-color: var(--primary-color);
    color: white;
}

.card-title {
    font-size: var(--font-size-large);
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-body {
    padding: var(--spacing-md);
    flex: 1;
}

.card-text {
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-medium);
}

.card-text:last-child {
    margin-bottom: 0;
}

.card-footer {
    padding: var(--spacing-md);
    background-color: #f8f9fa;
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    flex: 1;
}

.mark-read {
    background-color: #f1c40f;
    color: #34495e;
}

.mark-read.read {
    background-color: var(--secondary-color);
    color: white;
}

.mark-read.not-read {
    background-color: #f1c40f;
    color: #34495e;
}

.mark-read:hover {
    opacity: 0.9;
}

.btn-danger {
    background-color: var(--accent-color);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Dialog */
dialog {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 0;
    max-width: 500px;
    width: 100%;
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

dialog form {
    display: flex;
    flex-direction: column;
}

dialog h2 {
    background-color: var(--primary-color);
    color: white;
    margin: 0;
    padding: var(--spacing-md);
    font-size: var(--font-size-large);
}

.details {
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.details>div {
    display: flex;
    flex-direction: column;
}

.details label {
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
}

.details input,
.details textarea {
    padding: var(--spacing-sm);
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: var(--font-size-medium);
    transition: var(--transition);
}

.details input:focus,
.details textarea:focus {
    border-color: var(--primary-color);
    outline: none;
}

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

.form-buttons {
    padding: var(--spacing-md);
    background-color: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
}

.form-buttons button {
    padding: var(--spacing-sm) var(--spacing-xl);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

#save {
    background-color: var(--secondary-color);
    color: white;
}

#save:hover {
    background-color: #27ae60;
}

#cancel {
    background-color: #95a5a6;
    color: white;
}

#cancel:hover {
    background-color: #7f8c8d;
}

/* Footer */
footer {
    background-color: var(--header-background-color);
    color: var(--header-text-color);
    text-align: center;
    padding: var(--spacing-md);
    margin-top: auto;
}

footer p {
    margin-bottom: var(--spacing-sm);
}

footer p:last-child {
    margin-bottom: 0;
}

footer a {
    color: var(--header-text-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

footer a:hover {
    text-decoration: underline;
    color: var(--secondary-color);
}

/* Animation for highlighting searched book */
@keyframes highlight {

    0%,
    100% {
        transform: translateY(0);
        box-shadow: var(--card-shadow);
    }

    50% {
        transform: translateY(-10px);
        box-shadow: 0 15px 20px rgba(0, 0, 0, 0.2);
        border: 2px solid var(--secondary-color);
    }
}

.highlight {
    animation: highlight 1s ease;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: var(--spacing-sm);
    }

    header h1 {
        margin-bottom: var(--spacing-sm);
    }

    header nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--spacing-sm);
    }

    #library-container {
        grid-template-columns: 1fr;
    }

    .search-input {
        flex-direction: column;
    }

    .search-input input {
        border-radius: var(--border-radius) var(--border-radius) 0 0;
    }

    .search-input button {
        border-radius: 0 0 var(--border-radius) var(--border-radius);
    }
}