/* === CSS Variablen === */
:root {
    --bg-primary: #faf9f6;
    --bg-secondary: #f0eee6;
    --bg-card: #ffffff;
    --accent-rose: #e8c4c4;
    --accent-lavender: #c4c7e8;
    --accent-mint: #b8e0d2;
    --accent-peach: #f5d0c5;
    --accent-sky: #c4dfe6;
    --text-primary: #4a4a4a;
    --text-secondary: #8a8a8a;
    --text-light: #b0b0b0;
    --border: #e0ddd5;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

/* === Reset & Basis === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* === Header === */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--accent-lavender) 0%, var(--accent-rose) 100%);
    color: white;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* === Statistik-Dashboard === */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1.5rem;
    max-width: 800px;
    margin: -1.5rem auto 0;
    position: relative;
    z-index: 1;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-reading .stat-number { color: #7c7eb8; }
.stat-read .stat-number { color: #6baa92; }
.stat-want .stat-number { color: #c48a8a; }

/* === Filter-Sektion === */
.filter-section {
    max-width: 900px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.filter-btn:hover {
    border-color: var(--accent-lavender);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-lavender);
    border-color: var(--accent-lavender);
    color: white;
}

.filter-btn.active[data-filter="read"] {
    background: var(--accent-mint);
    border-color: var(--accent-mint);
}

.filter-btn.active[data-filter="want_to_read"] {
    background: var(--accent-rose);
    border-color: var(--accent-rose);
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

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

/* === Bücher-Grid === */
.books-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem 6rem;
}

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

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state p:first-child {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.empty-hint {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* === BookCard === */
.book-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

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

.book-card-header {
    padding: 1rem;
    display: flex;
    gap: 1rem;
    flex: 1;
}

.book-cover {
    width: 80px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.book-cover-placeholder {
    width: 80px;
    height: 120px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

.book-info {
    flex: 1;
    min-width: 0;
}

.book-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-author {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.book-rating {
    color: #f0c040;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.book-dates {
    font-size: 0.75rem;
    color: var(--text-light);
}

.book-card-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.read {
    background: var(--accent-mint);
    color: #4a7a66;
}

.status-badge.reading {
    background: var(--accent-lavender);
    color: #5c5e8a;
}

.status-badge.want_to_read {
    background: var(--accent-rose);
    color: #8a5c5c;
}

.book-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: var(--transition);
}

.btn-icon:hover {
    opacity: 1;
}

/* === FAB (Floating Action Button) === */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-lavender), var(--accent-rose));
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: var(--transition);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-small {
    max-width: 380px;
    padding: 1.5rem;
}

.modal-small p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* === Formular === */
.book-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    background: var(--bg-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-lavender);
}

.isbn-search-row {
    display: flex;
    gap: 0.5rem;
}

.isbn-search-row input {
    flex: 1;
}

.form-divider {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    margin: 1.25rem 0;
    position: relative;
}

.form-divider::before,
.form-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}

.form-divider::before { left: 0; }
.form-divider::after { right: 0; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.rating-input {
    display: flex;
    gap: 0.25rem;
}

.rating-input .star {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--border);
    transition: var(--transition);
}

.rating-input .star.active,
.rating-input .star:hover {
    color: #f0c040;
}

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

/* === Buttons === */
.btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-lavender), var(--accent-rose));
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: #e8a0a0;
    color: white;
}

.btn-danger:hover {
    background: #d88a8a;
}

/* === Suchergebnisse === */
.search-results {
    margin-top: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.search-result-item {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-result-item:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-lavender);
}

.search-result-cover {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

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

.search-result-title {
    font-size: 0.9rem;
    font-weight: 500;
}

.search-result-author {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* === Toolbar === */
.toolbar {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    display: flex;
    gap: 0.5rem;
    z-index: 100;
}

.btn-icon-toolbar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.btn-icon-toolbar:hover {
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

/* === Responsive === */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .stats-dashboard {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
        padding: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .books-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }

    .search-input {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .stats-dashboard {
        grid-template-columns: 1fr;
        margin-top: -1rem;
    }

    .fab {
        bottom: 1.5rem;
        right: 1.5rem;
    }

    .toolbar {
        bottom: 1.5rem;
        left: 1.5rem;
    }
}

/* === Header Top (Sync & Auth) === */
.header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
}

.sync-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.sync-indicator {
    font-size: 0.9rem;
}

.sync-label {
    font-size: 0.8rem;
    opacity: 0.9;
}

.btn-sync {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem;
    opacity: 0.7;
    transition: var(--transition);
}

.btn-sync:hover {
    opacity: 1;
    transform: rotate(180deg);
}

/* === Auth Section === */
#auth-section {
    display: none;
}

#auth-section.logged-in {
    display: block;
}

.auth-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    max-width: 900px;
    margin: -0.5rem auto 0.5rem;
    padding: 0.25rem 1.5rem;
    font-size: 0.85rem;
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: var(--transition);
    font-family: inherit;
}

.btn-logout:hover {
    background: var(--accent-rose);
    border-color: var(--accent-rose);
    color: white;
}

/* === Login Button (not logged in) === */
.auth-bar-login {
    display: none;
    text-align: center;
    padding: 0.5rem 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}

/* === Responsive Header === */
@media (max-width: 600px) {
    .header-top {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .sync-section {
        font-size: 0.75rem;
    }

    .auth-bar {
        justify-content: center;
        padding: 0.25rem 1rem;
    }
}
