/* public/css/book-show.css (Updated) */
.book-player-container {
    max-width: 100%; /* Wider container for two panels */
    margin: 30px auto;
    padding: 25px;
    background-color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    display: flex; /* Use flexbox for layout */
    min-height: 70vh; /* Ensure minimum height for the player area */
    position: relative; /* For absolute positioning of alerts */
}

/* Alert messages (optional, keep if needed) */
.alert {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    position: absolute; /* Position relative to .book-player-container */
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    z-index: 1000; /* Ensure it's on top */
    max-width: 600px;
    text-align: center;
}
.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Main Grid for Two Panels */
.player-grid {
    display: grid;
    grid-template-columns: 1fr 2.5fr; /* Left panel: 1 part, Right panel: 2.5 parts */
    gap: 25px;
    width: 100%; /* Fill the container width */
}

/* Left Panel Styling */
.left-panel {
    background-color: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    overflow-y: auto; /* Enable scrolling for long lists */
    border: 1px solid #e9ecef;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05); /* subtle inner shadow */
}

.book-info-compact {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px dashed #dee2e6;
}
.book-info-compact img {
    width: 120px;
    height: 160px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}
.book-info-compact h3 {
    font-size: 1.5rem;
    color: #2c3e50;
    margin-bottom: 5px;
}
.book-info-compact p {
    font-size: 0.95rem;
    color: #6c757d;
}

.content-navigation .nav-section {
    margin-bottom: 15px; /* Slightly less margin for collapsible sections */
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden; /* To hide content during collapse */
}

.content-navigation .nav-section h4.collapsible-header {
    font-size: 1.2rem;
    color: #495057;
    margin: 0; /* Remove default margin */
    padding: 15px 20px;
    background-color: #e9ecef;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0; /* Separator for header */
    transition: background-color 0.2s ease;
}

.content-navigation .nav-section h4.collapsible-header:hover {
    background-color: #dee2e6;
}

.content-navigation .nav-section h4.collapsible-header .arrow {
    border: solid #495057;
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
    transition: transform 0.3s ease;
}

.content-navigation .nav-section h4.collapsible-header.active .arrow {
    transform: rotate(-135deg);
}
.content-navigation .nav-section h4.collapsible-header .arrow.rotated { /* Ensure consistent rotation */
    transform: rotate(-135deg);
}


.nav-list.collapsible-content {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #f8f9fa;
    max-height: 0; /* Starts collapsed by default */
    overflow: hidden; /* Hide overflow when collapsed */
    transition: max-height 0.3s ease-out; /* Smooth transition for collapsing/expanding */
}


.nav-item {
    font-weight: bold;
    color: #343a40;
    padding: 8px 15px; /* Added horizontal padding */
    cursor: pointer;
    border-bottom: 1px dotted #e9ecef;
    margin-bottom: 0; /* No margin-bottom for nav-item with new structure */
}
.nav-item:last-child {
    border-bottom: none;
}

.nav-parts {
    list-style: none;
    padding-left: 15px; /* Indent parts */
    margin-top: 5px;
    padding-bottom: 5px; /* Little padding at the bottom of parts list */
}

.nav-part-item {
    font-weight: normal;
    color: #007bff; /* Primary color for clickable parts */
    padding: 6px 15px; /* Maintain consistent padding */
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-radius: 4px;
}

.nav-part-item:hover {
    background-color: #e9f5ff;
    color: #0056b3;
}

.nav-part-item.active {
    background-color: #007bff;
    color: #fff;
    font-weight: 600;
    padding-left: 20px; /* Slight indent for active */
}

.no-content-message {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 10px 0;
}

/* Right Panel Styling */
.right-panel {
    background-color: #ffffff;
    border-radius: 10px;
    padding: 25px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    display: flex; /* Flex container for content */
    flex-direction: column; /* Stack content vertically */
    min-height: 500px; /* Ensure a minimum height for the content area */
}

.mobile-only-header {
    display: none; /* Hidden by default, shown on mobile */
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.mobile-only-header h2 {
    font-size: 1.5rem;
    color: #2c3e50;
    margin: 0; /* Override default h2 margin */
}

.mobile-toggle-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #667eea; /* A nice highlight color */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

.mobile-toggle-btn:hover {
    background-color: #f0f0f0;
}


.content-display-area {
    flex-grow: 1; /* Allows content to take available space */
    overflow-y: auto; /* Enable scrolling for long content */
    padding-right: 15px; /* Space for scrollbar */
}

.content-display-area h2 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 10px;
}
.content-display-area h3 {
    font-size: 1.5rem;
    color: #4a69bd;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.content-display-area p {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #444;
    margin-bottom: 20px;
    white-space: pre-wrap;
}

.initial-message, .no-audio-message {
    text-align: center;
    color: #888;
    font-style: italic;
    padding-top: 50px;
}

/* Karaoke Transcript Highlighting */
.transcript-content .word {
    transition: background-color 0.1s ease;
    padding: 2px 0; /* Small padding to make highlight visible */
    border-radius: 3px;
}

.transcript-content .word.highlighted {
    background-color: #ffd700; /* Gold-like highlight */
    color: #333;
}

.mobile-back-btn {
    display: none;
}


/* Responsive Adjustments */
@media (max-width: 992px) {
    .player-grid {
        grid-template-columns: 1fr; /* Stack panels on smaller screens */
        gap: 20px;
    }
    .left-panel {
        max-height: 400px; /* Limit height of left panel when stacked */
    }
    .book-player-container {
        min-height: auto; /* Adjust min-height when stacked */
    }
}

/* Mobile Specific Styles (similar to the provided image) */
@media (max-width: 768px) {
    .book-player-container {
        margin: 0; /* Remove horizontal margin */
        padding: 0; /* Remove container padding */
        border-radius: 0; /* No border-radius for full width */
        box-shadow: none; /* No shadow */
        min-height: calc(100vh - 120px); /* Fill screen minus player and header/footer */
        flex-direction: column; /* Stack panels vertically initially */
    }

    .player-grid {
        display: block; /* Remove grid for mobile, handle panels with visibility */
    }

    .left-panel {
        position: fixed; /* Make left panel full screen overlay */
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        background-color: #f8f9fa; /* Match existing background */
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding: 20px;
        z-index: 1001; /* Ensure it's on top */
        transform: translateX(-100%); /* Start off-screen */
        transition: transform 0.3s ease-out;
        overflow-y: auto; /* Ensure scrolling within overlay */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .left-panel.active {
        transform: translateX(0%); /* Slide in */
    }

    .left-panel .book-info-compact {
        padding-top: 40px; /* Space from top edge */
    }

    .right-panel {
        border-radius: 0; /* No border-radius for full width */
        box-shadow: none; /* No shadow */
        min-height: calc(100vh - 120px); /* Fill remaining height */
        padding: 20px; /* Maintain padding within the panel */
    }

    .mobile-only-header {
        display: flex; /* Show on mobile */
        margin-top: 10px; /* Space from top of right panel */
    }

    /* Adjust font sizes for mobile for better readability */
    .book-info-compact h3 {
        font-size: 1.4rem;
    }
    .book-info-compact p {
        font-size: 0.9rem;
    }
    .content-navigation .nav-section h4 {
        font-size: 1.1rem;
    }
    .content-display-area h2 {
        font-size: 1.8rem;
        display: none;
    }
    .content-display-area h3 {
        font-size: 1.3rem;
        display: none;
    }
    .content-display-area p {
        font-size: 1rem;
    }
    .player-page-nav-header {
        display: none !important; 
    }

     .mobile-back-btn {
        display: flex; 
        background: none;
        border: none;
        font-size: 1.6rem; /* Slightly smaller to match menu icon */
        color: #6c757d; /* A neutral color from your theme */
        cursor: pointer;
        padding: 5px;
        border-radius: 5px;
        text-decoration: none; /* Removes underline from the <a> tag */
        transition: background-color 0.2s ease;
    }

    .mobile-back-btn:hover {
        background-color: #f0f0f0;
    }
}

#back-to-top-btn {
    display: none; /* Hidden by default */
    position: fixed;
    bottom: 110px; /* Position it above the audio player */
    right: 30px;
    z-index: 998; /* Below the player and playlist overlay */
    border: none;
    outline: none;
    background-color: #2c3e50; /* A dark color from your theme */
    color: white;
    cursor: pointer;
    padding: 15px;
    border-radius: 50%; /* Make it circular */
    font-size: 18px;
    width: 50px;
    height: 50px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

#back-to-top-btn.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

#back-to-top-btn:hover {
    background-color: #3498db; /* A blue highlight from your theme */
}

.mobile-only-close-btn {
    display: none;
}

.player-page-nav-header {
    display: flex; /* Use flexbox for alignment */
    justify-content: space-between; /* Pushes items to opposite ends */
    align-items: center;
}

/* Adjust position on mobile */
@media (max-width: 768px) {
    #back-to-top-btn {
        bottom: 20%;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 16px;
        padding: 12px;
    }

    .mobile-only-close-btn {
        display: block; /* Or inline-block */
        background: none;
        border: none;
        color: #6c757d; /* A neutral color from your theme */
        font-size: 1.8rem; /* Make it large and easy to tap */
        cursor: pointer;
        padding: 5px 10px;
        line-height: 1;
        margin-left: auto; /* Push it to the far right */
    }

    .mobile-only-close-btn:hover {
        color: #2c3e50; /* Darken on hover */
    }

}