/* basic reset to remove default browser margins and paddings */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* main styles for the page body */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #2C3E50;
    line-height: 1.6;
    min-height: 100vh;
}

/* main container to center the content */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* header styles */
.header {
    background: #FFFFFF;
    border-radius: 0 0 2rem 2rem;
    margin: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: sticky;
    top: 1.5rem;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #FF6B9D;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo img {
    width: auto;
    height: 3em;   
}

/* main button in the header (shared with .btn-primary) */
.add-book-btn, .btn-primary {
    background: linear-gradient(45deg, #FF6B9D, #E91E63);
    color: #FFFFFF;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.add-book-btn img, .btn-primary img {
    width: auto;
    height: 2em;   
}

.add-book-btn:hover, .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

/* main content styles */
main {
    padding: 2rem 1.5rem;
}

/* statistics section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: #FFFFFF;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #FF6B9D;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 1.25rem;
    font-weight: 600;
    color: #BDC3C7;
}

.stat-icon img {
    width: auto;
    height: 3em;
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
}

/* filters section */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
    justify-content: center;
    flex-wrap: wrap;
}

.filter-btn {
    background: linear-gradient(45deg, #FF6B9D, #E91E63);
    color: #FFFFFF;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.filter-btn:hover, .filter-btn.active {
    transform: translateY(-4px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.filter-btn img {
    width: auto;
    height: 2em;
}

/* book library styles */
/* library header */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: #FFFFFF;
    padding: 1.5rem 2rem;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.library-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2C3E50;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    background: linear-gradient(45deg, #FF6B9D, #E91E63);
    border: none;
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.view-btn:hover,
.view-btn.active {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.view-btn img {
    width: auto;
    height: 2em;
}

/* books container */
.books-container {
    min-height: 400px;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.books-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* individual book card */
.book-card {
    background: #FFFFFF;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.book-card:hover {
    transform: translate(-4px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.book-cover-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-cover {
    width: 50%;
    height: 200px;
    padding: 1rem;
}

.book-info {
    padding: 1.5rem;
}

.book-info h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.book-description {
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-genre {
    display: inline-block;
    background: linear-gradient(45deg, #3498DB, #9C27B0);
    color: #FFFFFF;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

/* action buttons inside the card (read, edit, delete) */
.book-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.book-actions button {
    flex: 1;
    min-width: 80px;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    font-size: 0.75rem;
    font-weight: 500;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.book-actions button img {
    width: auto;
    height: 2em;
}

.btn-read {
    background: #2ECC71;
    color: #FFFFFF
}

.btn-unread {
    background: #FF9500;
    color: #FFFFFF
}

.btn-edit {
    background: #3498DB;
    color: #FFFFFF;
}

.btn-delete {
    background: #E74C3C;
    color: #FFFFFF;
}

.book-actions button:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

/* specific styles for list view */
.books-list .book-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 1.5rem;
}

.books-list .book-cover {
    width: 200px;
    height: 200px;
    margin-right: 1.5rem;
    flex-shrink: 0;
}

.books-list .book-actions {
    min-width: 100px;
}

.books-list .book-info {
    flex: 1;
    padding: 0;
}

/*empty state (when there are no books) */
.empty-state {
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center; 
    text-align: center;
    padding: 3rem;
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    margin-bottom: 1.5rem;
}

.empty-icon img {
    width: auto;
    height: 10em;
}

.empty-state h3 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 1.2rem;
    margin-bottom: 3rem;
}

/* modal style */
/* base styles for the <dialog> element */
dialog {
    padding: 0;
    border: none;
    background: transparent;
}

dialog:not([open]) {
    display: none;
}

dialog[open] {
    padding: 0;
    border: none;
    background: transparent;
    display: block; 
    position: fixed; 
    width: 100%;
    height: 100%;
}

/* darkened background behind the modal */
dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1.5rem;
    background: #FFFFFF;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0; 
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
}

.modal-header h2 img {
    width: auto;
    height: 1em;
}

.header-left img {
    width: auto;
    height: 2em;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #FF6B9D, #E91E63);
}

/* search section inside modal */
.search-box {
    display: flex;
    margin-bottom: 1.5rem;
}

.search-box input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 8px;
    border: 2px solid #FF6B9D;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-box input:focus {
    outline: none;
    border-color: #E91E63;
}

.search-btn {
    background-color: #FF6B9D;
    color: #FFFFFF;
    border: none;
    padding: 1rem 1.5rem;
    margin-left: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-btn img {
    width: auto;
    height: 1rem;
}

.search-btn:hover {
    background: #E91E63;
}

/* search results section */
.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-result {
    display: flex;
    padding: 1.5rem;
    border: 1px solid #FF6B9D;
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.search-result:hover {
    border-color: #E91E63
}

.search-result img {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 1.5rem;
}

.search-result-info {
    flex: 1;
}

.search-result-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.search-result-author, .search-result-description {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.search-result-description {
    display: -webkit-box;
    -webkit-line-clamp: 5; 
    line-clamp: 5; 
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis; 
}

.add-result-btn {
    display: flex;
    align-items: center;
    justify-content: center; 
    padding: 0.5rem;
    cursor: pointer;
    width: 30px;
    margin-left: 1rem;
}

.add-result-btn img {
    width: auto;
    height: 2rem;
    margin-right: 0;
}

/* generic button styles */
.btn-secondary {
    background: #FFFFFF;
    color: #7F8C8D;
    border: 1px solid #7F8C8D;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    transform: translateY(-1px);
}

.btn-danger {
    background: #E74C3C;
    color: #FFFFFF;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

/* form styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 500;
    align-items: center;
    gap: 0.75rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid #FF6B9D;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #E91E63;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.form-actions img {
    width: auto;
    height: 1.5em;
}

/* animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}