/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body { 
    font-family: 'Khmer OS', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background-color: #f4f7f6;
    color: #333;
    padding: 20px; 
    line-height: 1.6; 
    height: 100vh;
    overflow: hidden; /* Prevent full body scroll, let individual containers scroll */
    display: flex;
    flex-direction: column;
}

/* Accessibility: Enhanced Focus States for Keyboard Users */
*:focus-visible {
    outline: 2px solid #3498db !important;
    outline-offset: 2px !important;
    border-radius: 4px;
}

.hidden {
    display: none !important;
}

#header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0; /* Prevents header from being squished */
    flex-wrap: wrap; /* Allows wrapping on very small screens */
    gap: 15px;
}

.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

h1 {
    color: #2c3e50;
    margin-bottom: 0;
    font-size: 2em;
}

#global-search {
    padding: 10px 15px;
    font-size: 1.1em;
    border: 1px solid #ccc;
    border-radius: 20px;
    width: 350px;
    max-width: 100%; /* Prevents the search bar from breaking small windows */
    outline: none;
    transition: border-color 0.3s;
}
#global-search:focus {
    border-color: #3498db;
}

/* Generic Button Style (Matching Global Search) */
button {
    padding: 10px 15px;
    font-size: 1em;
    border: 1px solid #ccc;
    border-radius: 20px;
    background-color: #fff;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s, background-color 0.3s, color 0.3s;
}
button:hover:not(:disabled) {
    border-color: #3498db;
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Layout */
#bible-container { 
    max-width: 1200px; 
    margin: 0 auto; 
    display: flex; 
    gap: 20px; 
    flex: 1; /* Automatically fills all remaining vertical space */
    min-height: 0; /* Crucial for scrolling inside flex children */
    width: 100%;
}

/* Sidebar (Book & Chapter List) */
#sidebar { 
    width: 300px; 
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    padding: 15px; 
    overflow-y: auto; 
}

#sidebar h3 {
    margin-bottom: 15px;
    color: #34495e;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 8px;
}

.book-link { 
    display: block; 
    padding: 10px 12px; 
    cursor: pointer; 
    color: #2980b9; 
    text-decoration: none; 
    border-radius: 6px; 
    transition: background-color 0.2s, color 0.2s;
    margin-bottom: 2px;
}

.book-link:hover { 
    background-color: #ebf5fb; 
}

.book-link.active { 
    font-weight: bold; 
    background-color: #3498db; 
    color: #fff; 
}

.chapter-list { 
    display: none; 
    padding: 10px; 
    background-color: #fdfdfd; 
    border-radius: 6px;
    border: 1px solid #ecf0f1; 
    flex-wrap: wrap; 
    gap: 8px; 
    margin: 5px 0 10px 15px;
}

.chapter-list.expanded {
    display: flex;
}

.chapter-link { 
    display: flex; 
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    cursor: pointer; 
    color: #2c3e50; 
    text-decoration: none; 
    border-radius: 4px; 
    border: 1px solid #bdc3c7; 
    background-color: #fff; 
    font-size: 0.9em;
    transition: all 0.2s;
}

.chapter-link:hover { 
    background-color: #ecf0f1; 
    border-color: #95a5a6;
}

.chapter-link.active { 
    font-weight: bold; 
    background-color: #2980b9; 
    color: #fff; 
    border-color: #2980b9; 
}

/* Main Content (Reading Pane) */
#main-content { 
    flex: 1; 
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    padding: 30px; 
    overflow-y: auto; 
}

.book-title { 
    border-bottom: 2px solid #3498db; 
    padding-bottom: 10px; 
    color: #2c3e50; 
    font-size: 1.8em;
    margin-bottom: 20px;
}

.chapter-title { 
    color: #34495e; 
    margin-top: 25px;
    margin-bottom: 10px;
    font-size: 1.4em;
}

.chapter-subtitle { 
    color: #7f8c8d; 
    margin-top: -5px; 
    margin-bottom: 20px; 
    font-style: italic; 
}

.verse { 
    margin-bottom: 12px; 
    padding-left: 10px;
}

.verse-num { 
    font-weight: bold; 
    margin-right: 8px; 
    color: #e74c3c; 
    font-size: 0.85em; 
    vertical-align: super;
    user-select: none; /* Prevent accidentally highlighting verse numbers */
}

.verse-text { 
    font-size: 1.15em; 
    color: #2b2b2b;
}

/* Chapter Navigation Buttons */
#chapter-nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ecf0f1;
}

.nav-btn {
    padding: 10px 20px;
    font-family: 'Khmer OS', 'Segoe UI', Tahoma, sans-serif;
    font-size: 1.1em;
}

.nav-btn:disabled {
    background-color: #f9f9f9;
    color: #bdc3c7;
    border-color: #ecf0f1;
}

.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ecf0f1;
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99;
    font-size: 1.5em;
    border: none;
    outline: none;
    background-color: #3498db;
    color: white;
    cursor: pointer;
    padding: 12px 18px;
    border-radius: 50px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: opacity 0.3s, background-color 0.3s;
}
#back-to-top:hover {
    background-color: #2980b9;
}

/* Custom Scrollbar for Webkit (Electron uses Chromium) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #bdc3c7; 
    border-radius: 10px;
}
body ::-webkit-scrollbar-thumb:hover {
    background: #3498db; 
}

/* Skeleton Loader */
.skeleton {
    background: #e0e0e0;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-title { width: 60%; height: 36px; margin-bottom: 25px; }
.skeleton-text { width: 100%; height: 24px; margin-bottom: 15px; }
.skeleton-text.short { width: 80%; }
.skeleton-sidebar { width: 90%; height: 20px; margin-bottom: 12px; }

/* Verse Notes */
.verse-note {
    font-size: 0.9em;
    color: #7f8c8d;
    background-color: #f9f9f9;
    padding: 8px 12px;
    margin-top: 5px;
    margin-left: 20px;
    border-left: 3px solid #3498db;
    border-radius: 0 4px 4px 0;
    display: inline-block;
}

/* Animated Splash Screen */
#splash-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #f4f7f6;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}
#splash-screen.hidden-splash {
    opacity: 0;
    visibility: hidden;
}
.splash-logo {
    width: 160px;
    height: 160px;
    border-radius: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    animation: pulse-logo 2s infinite ease-in-out;
}
.splash-text {
    margin-top: 25px;
    color: #2c3e50;
    font-size: 2em;
    font-weight: bold;
    text-align: center;
    letter-spacing: 1.5px;
}
.splash-spinner {
    margin-top: 30px;
    width: 50px;
    height: 50px;
    border: 4px solid rgba(52, 152, 219, 0.2);
    border-top-color: #3498db;
    border-bottom-color: #3498db;
    border-radius: 50%;
    animation: spin-loader 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
@keyframes pulse-logo { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes spin-loader { to { transform: rotate(360deg); } }

/* Dark Mode & Dynamic Elements Styles */
body { transition: background-color 0.3s, color 0.3s; }
#search-container { 
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 10px;
    border-bottom: 1px solid #ccc;
    background-color: #fff; 
}
#search-container input {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
}

body.dark-mode { background-color: #121212; color: #e0e0e0; }
body.dark-mode #splash-screen { background-color: #121212; }
body.dark-mode .splash-text { color: #e0e0e0; }
body.dark-mode #main-content, body.dark-mode #sidebar { background-color: #1e1e1e; }
body.dark-mode #sidebar { border-right: 1px solid #333; }
body.dark-mode #sidebar h3 { color: #e0e0e0; border-bottom-color: #444; }
body.dark-mode h1 { color: #e0e0e0; }
body.dark-mode .book-link { color: #e0e0e0; }
body.dark-mode .book-link:hover { background-color: #2a2a2a; }
body.dark-mode .chapter-link { background-color: #333; border-color: #555; color: #e0e0e0; }
body.dark-mode .chapter-link:hover { background-color: #444; }
body.dark-mode .chapter-link.active { background-color: #005A9E; border-color: #005A9E; color: #fff; }
body.dark-mode input { background-color: #333; color: #e0e0e0; border: 1px solid #555; }
body.dark-mode #search-container { background-color: #1e1e1e; border-bottom: 1px solid #333; }
body.dark-mode #chapter-nav-buttons { border-top: 1px solid #333; }
body.dark-mode button { background-color: #333; color: #e0e0e0; border: 1px solid #555; }
body.dark-mode button:hover:not(:disabled) { background-color: #444; border-color: #3498db; }
body.dark-mode .book-title, body.dark-mode .chapter-title, body.dark-mode .chapter-subtitle { color: #e0e0e0; }
body.dark-mode .verse-num { color: #ff7675; }
body.dark-mode .verse-text { color: #e0e0e0; }
body.dark-mode ::-webkit-scrollbar-thumb { background: #555; }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: #3498db; }
body.dark-mode .skeleton {
    background: #333;
    background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    background-size: 200% 100%;
}
body.dark-mode .verse-note {
    color: #bdc3c7;
    background-color: #2a2a2a;
    border-left-color: #2980b9;
}
.verse { padding: 4px 8px; border-radius: 4px; transition: background-color 0.2s; }
.verse-actions { display: inline-flex; align-items: center; gap: 8px; margin-left: 10px; vertical-align: middle; }
.verse .bookmark-toggle, .verse .save-image-btn, .verse .note-verse-btn, .verse .read-verse-btn { opacity: 0; cursor: pointer; transition: opacity 0.2s ease-in-out; }
.verse:hover .bookmark-toggle, .verse:hover .save-image-btn, .verse:hover .note-verse-btn, .verse:hover .read-verse-btn { opacity: 1; }
.read-verse-btn.playing { 
    opacity: 1 !important; 
    color: #3498db; 
    animation: pulse-play 1.5s infinite; 
}
@keyframes pulse-play {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
body.dark-mode .read-verse-btn.playing { color: #4fa3e3; }

.verse.bookmarked .bookmark-toggle { opacity: 1; }
.verse.bookmarked { background-color: #fff3cd; border-left: 3px solid #ffc107; padding-left: 5px; }
.verse.bookmarked .bookmark-toggle svg { fill: currentColor; }
.dark-mode .verse.bookmarked { background-color: #3b3520; border-left: 3px solid #d39e00; }
.bookmark-toggle, .save-image-btn, .note-verse-btn, .read-verse-btn { user-select: none; transition: opacity 0.2s; }
.search-result { border: 1px solid #eee; border-radius: 4px; padding: 10px; margin-bottom: 15px; cursor: pointer; transition: background-color 0.2s; }
.search-result:hover { background-color: #f9f9f9; }
body.dark-mode .search-result { border-color: #333; }
body.dark-mode .search-result:hover { background-color: #2a2a2a; }
body.dark-mode .search-result strong { color: #e0e0e0; }
.testament-divider { padding: 15px 10px 5px 10px; font-weight: bold; color: #888; font-size: 0.9em; }
body.dark-mode .testament-divider { color: #aaa; }
body.dark-mode .search-result-title { color: #4fa3e3; } /* Lighter blue for dark mode visibility */
body.dark-mode .search-highlight { background-color: #f1c40f; color: #121212; }
.highlight-and-fade {
    animation: fade-out-highlight 3s ease-out forwards;
}
@keyframes fade-out-highlight {
    from { background-color: #fff9c4; }
    to { background-color: transparent; }
}
body.dark-mode .highlight-and-fade {
    animation-name: dark-fade-out-highlight;
}
@keyframes dark-fade-out-highlight {
    from { background-color: #4b4700; }
    to { background-color: transparent; }
}
body.dark-mode .pagination-controls { border-top-color: #333; }
body.dark-mode *:focus-visible { outline-color: #4fa3e3; }
body.dark-mode #back-to-top { background-color: #005A9E; color: #fff; }
body.dark-mode #back-to-top:hover { background-color: #4fa3e3; }

/* Verse of the Day Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    padding: 40px 30px;
    border-radius: 16px;
    max-width: 550px;
    width: 90%;
    text-align: center;
    position: relative;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    color: #2c3e50; /* Dark text suitable for bright pastel gradients */
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.show .modal-content {
    transform: scale(1);
}
.modal-close-btn {
    position: absolute;
    top: 15px; right: 15px;
    background: rgba(0,0,0,0.1);
    border: none;
    font-size: 1.5em;
    color: #2c3e50;
    cursor: pointer;
    border-radius: 50%;
    width: 32px; height: 32px;
    display: flex; justify-content: center; align-items: center;
    transition: background 0.3s;
    line-height: 1;
}
.modal-close-btn:hover {
    background: rgba(0,0,0,0.2);
}
.modal-title {
    font-size: 1.3em;
    letter-spacing: 1px;
    margin-bottom: 20px;
    opacity: 0.8;
    font-weight: bold;
}
.modal-ref {
    font-size: 1.1em;
    font-style: italic;
    opacity: 0.8;
    font-weight: bold;
}
.modal-colors {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.color-swatch {
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); transition: transform 0.2s;
    border: 2px solid transparent;
}
#votd-text, #export-text { /* The main verse text */
    font-size: 1.6em;
    line-height: 1.6;
    margin-bottom: 20px;
    font-weight: bold;
}
.modal-content .nav-btn:hover {
    background: rgba(0,0,0,0.2);
}
body.dark-mode .modal-overlay { background: rgba(0, 0, 0, 0.7); }

.page-header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #3498db; margin-bottom: 20px; padding-bottom: 10px; }
.page-header .book-title { border: none; margin-bottom: 0; padding-bottom: 0; }
body.dark-mode .page-header { border-bottom-color: #005A9E; }

/* Toast Notification */
#copy-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
    white-space: nowrap; /* Prevent text wrapping */
}

body.dark-mode #copy-toast {
    background-color: rgba(255, 255, 255, 0.9);
    color: #121212;
    font-weight: 500;
}

/* View Transitions */
@keyframes slideFadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.view-transition {
    animation: slideFadeIn 0.3s ease-out forwards;
}