/* ============================================
   BOOKS PANEL CSS
   ============================================
   
   Features:
   - Books panel that slides in from left
   - Sidebar slides away when books panel is active
   - Main content shifts to accommodate books panel
   - Matches notes panel styling exactly
   - Dark theme support
*/

/* ==========================================
   HIDE THE OLD BOOKS MODAL (DEPRECATED)
   ========================================== */

.books-modal-overlay,
#books-modal-overlay {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

/* ==========================================
   BOOKS PANEL CONTAINER
   ========================================== */

.books-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background: linear-gradient(to bottom right, rgba(250, 249, 246, 1), rgba(248, 246, 255, 0.8));
    border-right: 1px solid rgba(248, 246, 255, 0.5);
    z-index: 1200; /* Higher than sidebar (1100) to prevent overlap */
    transform: translateX(-100%); /* Hidden by default */
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
}

/* Dark theme */
[data-theme="dark"] .books-panel {
    background: #1a1a1a;
    border-right: 1px solid #2d2d2d;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
}

/* Active state - panel visible */
.books-panel.active {
    transform: translateX(0);
}

/* ==========================================
   BOOKS PANEL HEADER
   ========================================== */

.books-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(248, 246, 255, 0.6);
    background: linear-gradient(to right, rgba(250, 249, 246, 0.9), rgba(248, 246, 255, 0.7));
    flex-shrink: 0;
}

[data-theme="dark"] .books-panel-header {
    background: #0f0f0f;
    border-bottom: 1px solid #2d2d2d;
}

.books-search-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    margin-right: 12px;
}

.books-search-icon {
    position: absolute;
    left: 12px;
    color: #9d8fc9;
    pointer-events: none;
    z-index: 1;
}

.books-search-input {
    width: 100%;
    padding: 10px 36px 10px 40px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(157, 143, 201, 0.2);
    border-radius: 8px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    color: #1f1f1f;
    outline: none;
    transition: all 0.2s ease;
}

.books-search-input::placeholder {
    color: rgba(31, 31, 31, 0.5);
}

.books-search-input:focus {
    background: rgba(255, 255, 255, 0.9);
    border-color: #9d8fc9;
    box-shadow: 0 0 0 3px rgba(157, 143, 201, 0.1);
}

[data-theme="dark"] .books-search-input {
    background: rgba(45, 45, 45, 0.6);
    border-color: rgba(157, 143, 201, 0.3);
    color: #e5e5e5;
}

[data-theme="dark"] .books-search-input::placeholder {
    color: rgba(229, 229, 229, 0.4);
}

[data-theme="dark"] .books-search-input:focus {
    background: rgba(45, 45, 45, 0.9);
    border-color: #9d8fc9;
    box-shadow: 0 0 0 3px rgba(157, 143, 201, 0.15);
}

.books-search-clear {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(31, 31, 31, 0.6);
    transition: all 0.2s ease;
}

.books-search-clear:hover {
    background: rgba(157, 143, 201, 0.1);
    color: #1f1f1f;
}

[data-theme="dark"] .books-search-clear {
    color: rgba(229, 229, 229, 0.5);
}

[data-theme="dark"] .books-search-clear:hover {
    background: rgba(157, 143, 201, 0.2);
    color: #e5e5e5;
}

.books-panel-close {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9d8fc9;
    transition: all 0.2s ease;
}

.books-panel-close:hover {
    background: rgba(248, 246, 255, 0.8);
    color: #7c3aed;
}

[data-theme="dark"] .books-panel-close {
    color: #999;
}

[data-theme="dark"] .books-panel-close:hover {
    background: #2d2d2d;
    color: #fff;
}

/* ==========================================
   SORTING TABS - HIDDEN
   ========================================== */

.books-panel-tabs {
    display: none !important;
}

/* ==========================================
   BOOKS LIST CONTAINER
   ========================================== */

.books-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    background: linear-gradient(to bottom right, rgba(250, 249, 246, 1), rgba(248, 246, 255, 0.8));
}

[data-theme="dark"] .books-panel-content {
    background: #1a1a1a;
}
}

/* Scrollbar styling */
.books-panel-content::-webkit-scrollbar {
    width: 6px;
}

.books-panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.books-panel-content::-webkit-scrollbar-thumb {
    background: rgba(157, 143, 201, 0.3);
    border-radius: 3px;
}

.books-panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(157, 143, 201, 0.5);
}

[data-theme="dark"] .books-panel-content::-webkit-scrollbar-thumb {
    background: #444;
}

[data-theme="dark"] .books-panel-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ==========================================
   BOOK ITEMS
   ========================================== */

.books-panel-list {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    list-style: none;
}

.books-panel-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: none;
}

.books-panel-item:hover {
    background: rgba(248, 246, 255, 0.8);
}

[data-theme="dark"] .books-panel-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.books-panel-item:active {
    background: rgba(124, 58, 237, 0.1);
}

[data-theme="dark"] .books-panel-item:active {
    background: rgba(255, 255, 255, 0.08);
}

.books-panel-item.expanded {
    background: rgba(248, 246, 255, 0.8);
}

[data-theme="dark"] .books-panel-item.expanded {
    background: rgba(255, 255, 255, 0.05);
}

.book-panel-name {
    font-size: 15px;
    font-weight: 500;
    color: #1f1f1f;
    letter-spacing: -0.1px;
}

[data-theme="dark"] .book-panel-name {
    color: #e5e5e5;
}

.book-panel-chevron {
    color: #9d8fc9;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.books-panel-item.expanded .book-panel-chevron {
    transform: rotate(180deg);
}

[data-theme="dark"] .book-panel-chevron {
    color: #666;
}

/* ==========================================
   CHAPTERS DROPDOWN
   ========================================== */

.book-chapters-dropdown {
    display: none;
    background: rgba(248, 246, 255, 0.5);
    padding: 12px 24px 16px 24px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.1);
}

.book-chapters-dropdown.visible {
    display: block;
}

[data-theme="dark"] .book-chapters-dropdown {
    background: #151515;
    border-bottom: 1px solid #2d2d2d;
}

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 8px;
}

.chapter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(157, 143, 201, 0.3);
    border-radius: 8px;
    background: #fff;
    color: #1f1f1f;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chapter-btn:hover {
    background: rgba(124, 58, 237, 0.1);
    border-color: #9d8fc9;
    color: #7c3aed;
}

.chapter-btn:active {
    background: #9d8fc9;
    border-color: #9d8fc9;
    color: #fff;
}

[data-theme="dark"] .chapter-btn {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #e5e5e5;
}

[data-theme="dark"] .chapter-btn:hover {
    background: #2d2d2d;
    border-color: #9d8fc9;
    color: #fff;
}

[data-theme="dark"] .chapter-btn:active {
    background: #9d8fc9;
    border-color: #9d8fc9;
    color: #fff;
}

/* ==========================================
   LOADING STATE - Use bibliatech-loading class
   ========================================== */

.books-panel-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #9d8fc9;
}

/* Legacy loading spinner - Use bibliatech-loading class instead */
/* See loading-animation.css for the new loading styles */

/* ==========================================
   BODY STATE ADJUSTMENTS
   ========================================== */

/* When books panel is active, slide sidebar away using same approach as notes mode */
body.books-panel-active .sidebar,
body.books-panel-active #sidebar {
    left: -250px;
    transform: none;
    pointer-events: none;
}

body.books-panel-active .sidebar.collapsed,
body.books-panel-active #sidebar.collapsed {
    left: -60px;
}

/* Shift main content when books panel is active */
body.books-panel-active .main-wrapper,
body.books-panel-active #main-wrapper {
    margin-left: 320px !important;
    transition: margin-left 0.3s ease;
}

/* When books panel is active AND notes mode was active,
   override notes mode margin with books panel margin */
body.books-panel-active.notes-mode-active .main-wrapper,
body.books-panel-active.notes-mode-active #main-wrapper,
body.books-panel-active.notes-mode-books-override .main-wrapper,
body.books-panel-active.notes-mode-books-override #main-wrapper {
    margin-left: 320px !important;
}

/* Hide notes panel when books panel is active */
body.books-panel-active .notes-panel {
    transform: translateX(-100%);
    visibility: hidden;
}

/* Keep sidebar hidden when in notes mode with books override */
body.notes-mode-active.notes-mode-books-override .sidebar,
body.notes-mode-active.books-panel-active .sidebar {
    left: -250px;
    pointer-events: none;
}

/* Ensure smooth transitions */
#sidebar,
.sidebar {
    transition: left 0.3s ease, transform 0.3s ease;
}

.main-wrapper,
#main-wrapper {
    transition: margin-left 0.3s ease;
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
    .books-panel {
        width: 100%;
        z-index: 1100;
    }
    
    body.books-panel-active .main-wrapper,
    body.books-panel-active #main-wrapper {
        margin-left: 0;
    }
    
    .books-panel-item {
        padding: 16px 20px;
    }
    
    .book-panel-name {
        font-size: 16px;
    }
    
    .chapter-btn {
        width: 48px;
        height: 48px;
        font-size: 15px;
    }
    
    .chapters-grid {
        gap: 10px;
    }
}

/* ==========================================
   TESTAMENT DIVIDERS
   ========================================== */

.testament-divider {
    padding: 16px 24px 8px 24px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #9d8fc9;
}

[data-theme="dark"] .testament-divider {
    color: #666;
}

/* ==========================================
   OVERLAY - HIDDEN (No dark overlay needed)
   ========================================== */

.books-panel-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 1199; /* Just below books-panel (1200) */
    pointer-events: none;
}

/* ==========================================
   FORCED SELECTION MODE
   When book is not available in translation
   ========================================== */

.books-panel-overlay.forced-selection {
    display: block !important;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

[data-theme="dark"] .books-panel-overlay.forced-selection {
    background: rgba(0, 0, 0, 0.7);
}

/* Add visual indicator on books panel during forced selection */
.books-panel.forced-selection::before {
    content: 'Select an available book';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    z-index: 10;
}

[data-theme="dark"] .books-panel.forced-selection::before {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

/* Shift header down during forced selection */
.books-panel.forced-selection .books-panel-header {
    margin-top: 32px;
}
