:root {
    --primary-purple: #7B2CBF;
    --secondary-purple: #9D4EDD;
    --dark-purple: #6A1B9A;
    --very-dark-purple: #4A148C;
    --light-purple: #C77DFF;
    --bg-color: #FAFAFA;
    --card-bg: #FFFFFF;
    --text-primary: #2D2D2D;
    --text-secondary: #6B6B6B;
    --border-color: rgba(157, 78, 221, 0.2);
    --shadow: rgba(123, 44, 191, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.library-wrapper {
    max-width: 1200px;
    margin: 40px auto;
    padding: 2rem;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* Tab Navigation - Always Horizontal */
.tab-navigation {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    margin-bottom: 2rem;
    padding: 0.5rem;
    background: #F5F0FF;
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--secondary-purple) transparent;
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for webkit browsers */
.tab-navigation::-webkit-scrollbar {
    height: 4px;
}

.tab-navigation::-webkit-scrollbar-track {
    background: transparent;
}

.tab-navigation::-webkit-scrollbar-thumb {
    background: var(--secondary-purple);
    border-radius: 2px;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

.tab-btn:hover {
    background: rgba(157, 78, 221, 0.1);
    color: var(--primary-purple);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary-purple), var(--secondary-purple));
    color: white;
    box-shadow: 0 4px 12px rgba(123, 44, 191, 0.25);
}

.tab-btn i {
    font-size: 1rem;
    flex-shrink: 0;
}

.tab-btn span {
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Content Sections */
.content-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.content-section.active-section {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Compact Book Cards */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.25rem;
}

.compact-book-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow);
    padding: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.compact-book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(123, 44, 191, 0.15);
    border-color: var(--secondary-purple);
}

.card-content {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Compact Cover Image */
.book-cover-compact {
    position: relative;
    width: 70px;
    height: 100px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: linear-gradient(135deg, #F5F0FF, #E9D5FF);
}

.book-cover-compact img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.progress-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    padding: 0.25rem;
    text-align: center;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
}

.purchased-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    box-shadow: 0 2px 6px rgba(255, 215, 0, 0.4);
    z-index: 1;
}

.liked-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: linear-gradient(135deg, #FF1744, #F50057);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    box-shadow: 0 2px 6px rgba(255, 23, 68, 0.4);
    z-index: 1;
    animation: heartBeat 1.5s ease-in-out infinite;
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    10%, 30% { transform: scale(1.1); }
    20% { transform: scale(1.15); }
}

.coins-text {
    color: #FFA500;
    font-weight: 700;
}

/* Book Details */
.book-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.book-title-gradient {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    background: linear-gradient(135deg, var(--primary-purple), var(--secondary-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.detail-row i {
    color: var(--secondary-purple);
    font-size: 0.75rem;
}

.detail-text {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-text-small {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Progress Bar */
.progress-container {
    height: 6px;
    background: rgba(157, 78, 221, 0.15);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar-modern {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-purple), var(--secondary-purple));
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* Card Footer */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.status-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: rgba(157, 78, 221, 0.1);
    border: 1px solid rgba(157, 78, 221, 0.25);
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-purple);
}

.status-chip i {
    font-size: 0.75rem;
}

.status-chip-gold {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 165, 0, 0.3);
    color: #FF8C00;
}

.status-chip-gold i {
    color: #FFD700;
}

.status-chip-pink {
    background: rgba(255, 23, 68, 0.1);
    border-color: rgba(245, 0, 87, 0.3);
    color: #F50057;
}

.status-chip-pink i {
    color: #FF1744;
}

.continue-button {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--primary-purple), var(--secondary-purple));
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(123, 44, 191, 0.2);
}

.continue-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(123, 44, 191, 0.35);
}

.continue-button i {
    font-size: 1rem;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    color: var(--secondary-purple);
    margin-bottom: 1.5rem;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 768px) {
    .library-wrapper {
        margin: 20px;
        padding: 1.5rem;
    }

    .book-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .tab-navigation {
        gap: 0.4rem;
        padding: 0.4rem;
    }

    .tab-btn {
        padding: 0.6rem 0.9rem;
        font-size: 0.85rem;
        flex: 1 1 0;
        min-width: max-content;
    }

    .tab-btn span {
        font-size: 0.85rem;
    }

    .tab-btn i {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .library-wrapper {
        margin: 10px;
        padding: 1rem;
    }

    .tab-navigation {
        gap: 0.3rem;
        padding: 0.3rem;
    }

    .tab-btn {
        padding: 0.55rem 0.7rem;
        font-size: 0.8rem;
        flex: 1 1 0;
        min-width: max-content;
    }

    .tab-btn span {
        font-size: 0.8rem;
    }

    .tab-btn i {
        font-size: 0.85rem;
    }

    .book-cover-compact {
        width: 60px;
        height: 85px;
    }

    .book-title-gradient {
        font-size: 0.9rem;
    }

    .card-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .status-chip,
    .continue-button {
        width: 100%;
        justify-content: center;
    }
}

/* Very small screens - still show text but more compact */
@media (max-width: 360px) {
    .tab-btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
        gap: 0.3rem;
        flex: 1 1 0;
        min-width: max-content;
    }

    .tab-btn span {
        font-size: 0.75rem;
    }

    .tab-btn i {
        font-size: 0.8rem;
    }
}

/* Animation for cards */
.compact-book-card {
    animation: slideUp 0.5s ease forwards;
    opacity: 0;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.compact-book-card:nth-child(1) { animation-delay: 0.05s; }
.compact-book-card:nth-child(2) { animation-delay: 0.1s; }
.compact-book-card:nth-child(3) { animation-delay: 0.15s; }
.compact-book-card:nth-child(4) { animation-delay: 0.2s; }
.compact-book-card:nth-child(5) { animation-delay: 0.25s; }
.compact-book-card:nth-child(6) { animation-delay: 0.3s; }