/* CSS Variables for Design System */
:root {
    /* Colors - HSL format */
    --background: hsl(0, 0%, 100%);
    --foreground: hsl(220, 10%, 15%);
    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(220, 10%, 15%);
    --primary: hsl(25, 95%, 53%);
    --primary-foreground: hsl(0, 0%, 100%);
    --primary-glow: hsl(35, 100%, 65%);
    --secondary: hsl(220, 14%, 96%);
    --secondary-foreground: hsl(220, 10%, 15%);
    --muted: hsl(220, 14%, 96%);
    --muted-foreground: hsl(220, 8%, 46%);
    --accent: hsl(45, 93%, 47%);
    --accent-foreground: hsl(0, 0%, 100%);
    --spiritual: hsl(260, 60%, 45%);
    --spiritual-foreground: hsl(0, 0%, 100%);
    --spiritual-light: hsl(260, 45%, 85%);
    --success: hsl(142, 76%, 36%);
    --success-foreground: hsl(0, 0%, 100%);
    --soft-green: hsl(145, 60%, 85%);
    --soft-green-hover: hsl(145, 65%, 80%);
    --border: hsl(220, 13%, 91%);
    --input: hsl(220, 13%, 91%);
    --ring: hsl(25, 95%, 53%);
    
    /* Gradients and Shadows */
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-glow));
    --gradient-spiritual: linear-gradient(135deg, var(--spiritual), var(--spiritual-light));
    --shadow-soft: 0 4px 24px -2px hsl(25, 95%, 53%, 0.1);
    --shadow-book: 0 8px 32px -4px hsl(260, 60%, 45%, 0.15);
    
    /* Border radius */
    --radius: 0.5rem;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --background: hsl(222, 84%, 5%);
        --foreground: hsl(210, 40%, 98%);
        --card: hsl(222, 84%, 5%);
        --card-foreground: hsl(210, 40%, 98%);
        --primary: hsl(210, 40%, 98%);
        --primary-foreground: hsl(222, 47%, 11%);
        --secondary: hsl(217, 33%, 18%);
        --secondary-foreground: hsl(210, 40%, 98%);
        --muted: hsl(217, 33%, 18%);
        --muted-foreground: hsl(215, 20%, 65%);
        --accent: hsl(217, 33%, 18%);
        --accent-foreground: hsl(210, 40%, 98%);
        --border: hsl(217, 33%, 18%);
        --input: hsl(217, 33%, 18%);
        --ring: hsl(213, 27%, 84%);
    }
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Utility Classes */
.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Navigation */
.navbar {
    width: 100%;
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 28rem;
    margin: 0 auto;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn.spiritual {
    background: var(--gradient-spiritual);
    color: var(--spiritual-foreground);
}

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

.nav-btn.ghost {
    background: transparent;
    color: var(--foreground);
}

.nav-btn.ghost:hover {
    background-color: var(--muted);
}

/* Main Container */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px; /* Space for footer */
}

/* Views */
.view {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Home View */
.home-content {
    max-width: 28rem;
    margin: 0 auto;
    padding: 2rem 1rem;
    text-align: center;
}

.welcome-text {
    margin-bottom: 2rem;
}

.welcome-text h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.welcome-text p {
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

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

.book-card {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.book-card:hover {
    box-shadow: var(--shadow-book);
}

.book-card.open {
    border-color: var(--primary);
    background: linear-gradient(to bottom right, var(--background), hsl(25, 95%, 53%, 0.05));
}

.book-card.open:hover {
    border-color: var(--primary-glow);
    background: var(--soft-green-hover);
}

.book-card.locked {
    border-color: var(--muted);
    background: hsl(220, 14%, 96%, 0.3);
    color: var(--muted-foreground);
}

.book-icon {
    font-size: 1.5rem;
    padding: 0.75rem;
    border-radius: 50%;
    background: hsl(25, 95%, 53%, 0.1);
}

.book-card.locked .book-icon {
    background: var(--muted);
}

.book-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.3;
}

.book-card p {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.donate-btn {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.donate-btn:hover {
    background: var(--muted);
}

/* Book Detail View */
.book-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.header-btn {
    padding: 0.5rem;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--foreground);
    font-size: x-large;
}

.header-btn:hover {
    background: var(--muted);
}

#bookTitle {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* Search */
.search-container {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

#searchInput {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
    font-size: 0.875rem;
}

#searchInput:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 2px hsl(25, 95%, 53%, 0.2);
}

/* Content Area */
.content-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--background);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.sidebar.open {
    transform: translateX(0);
}

.songs-list {
    padding: 1rem 0;
}

.song-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.song-item:hover {
    background: var(--muted);
}

.song-item.active {
    background: hsl(25, 95%, 53%, 0.1);
    border-left: 3px solid var(--primary);
}

.song-title {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.song-meta {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.no-song-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--muted-foreground);
    text-align: center;
}

.lyrics-content {
    max-width: 600px;
    margin: 0 auto;
}

.lyrics-header {
    margin-bottom: 2rem;
    text-align: center;
}

.lyrics-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.lyrics-meta {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.lyrics-body {
    line-height: 1.8;
    font-size: 1rem;
    white-space: pre-line;
}

.lyrics-body.highlight {
    background: linear-gradient(90deg, 
        transparent 0%, 
        hsl(45, 93%, 47%, 0.1) 25%, 
        hsl(45, 93%, 47%, 0.1) 75%, 
        transparent 100%);
}

/* Audio Player */
.audio-player {
    position: fixed;
    bottom: 45px; /* Above footer */
    left: 0;
    right: 0;
    background: var(--background);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    box-shadow: 0 -2px 10px hsl(0, 0%, 0%, 0.1);
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

#playPauseBtn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

#playPauseBtn:hover {
    background: var(--primary-glow);
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--muted);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.progress {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s ease;
}

#volumeSlider {
    width: 80px;
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--background);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    z-index: 1000;
}

.footer-content {
    text-align: center;
    max-width: 28rem;
    margin: 0 auto;
}

.footer-content p {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin: 0;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: hsl(0, 0%, 0%, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--background);
    border-radius: var(--radius);
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px hsl(0, 0%, 0%, 0.3);
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--muted-foreground);
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--muted);
    color: var(--foreground);
}

.modal-body {
    padding: 1rem;
}

.features-list {
    margin: 1rem 0;
}

.features-list h4 {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.features-list ul {
    list-style: none;
    padding-left: 1rem;
}

.features-list li {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-bottom: 0.25rem;
}

.payment-info {
    background: hsl(220, 14%, 96%, 0.5);
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    text-align: center;
}

.payment-code {
    font-family: monospace;
    font-size: 1.125rem;
    font-weight: bold;
    background: var(--background);
    padding: 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin: 0.5rem 0;
}

.thank-you {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 1rem;
}

/* Settings */
.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group h4 {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--foreground);
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    gap: 1rem;
}

.setting-item label {
    font-size: 0.875rem;
    color: var(--foreground);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.setting-item select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .content-area {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        top: 60px;
        left: 0;
        bottom: 60px;
        width: 280px;
        z-index: 100;
        box-shadow: 2px 0 10px hsl(0, 0%, 0%, 0.1);
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .book-card {
        padding: 1rem;
    }
    
    .nav-container {
        max-width: 100%;
    }
    
    .header-controls {
        gap: 0.125rem;
    }
    
    .audio-player {
        padding: 0.75rem;
    }
    
    .player-controls {
        gap: 0.5rem;
    }
    
    #volumeSlider {
        width: 60px;
    }
}

@media (max-width: 480px) {
    .books-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .welcome-text h1 {
        font-size: 1.25rem;
    }
    
    .home-content {
        padding: 1rem;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .header-actions {
        gap: 0.25rem;
    }
    
    #bookTitle {
        font-size: 0.875rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.view {
    animation: fadeIn 0.3s ease-out;
}

.sidebar.open {
    animation: slideIn 0.3s ease-out;
}

/* Text Size Settings */
body.text-small .lyrics-body { font-size: 0.875rem; }
body.text-medium .lyrics-body { font-size: 1rem; }
body.text-large .lyrics-body { font-size: 1.125rem; }