:root {
    --primary-blue: #007bff;
    --dark-blue: #0056b3;
    --light-blue: #e9f5ff;
    --text-color: #333;
    --secondary-text-color: #666;
    --border-color: #dee2e6;
    --card-bg: #ffffff;
    --dark-bg: #222;
    /* Darker background for player */
    --player-bg: #2d2d2d;
    /* Slightly lighter dark for player container */
    --player-border: #444;
    --player-text: #f0f0f0;
    --player-icon: #f0f0f0;
    --player-icon-hover: var(--primary-blue);
    --progress-bar-bg: #555;
    --progress-bar-fill: var(--primary-blue);
}

body {
    background-color: #f8f9fa;
}

.book-description-page-container {
    max-width: 900px;
    margin: 30px auto;
    padding: 30px;
    background-color: var(--card-bg);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    border-radius: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
}

.book-header-section {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.book-cover-large {
    flex-shrink: 0;
}

.book-cover-large img {
    width: 180px;
    height: 250px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.book-details-main {
    flex-grow: 1;
}

.book-main-title {
    font-size: 2.8rem;
    color: var(--primary-blue);
    margin-bottom: 10px;
    line-height: 1.2;
}

.book-main-author {
    font-size: 1.5rem;
    color: var(--secondary-text-color);
    font-weight: 500;
}

/* Tabs Section */
.tabs-section {
    margin-bottom: 30px;
}

.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-button {
    background-color: transparent;
    border: none;
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary-text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.tab-button:hover:not(.active) {
    color: var(--primary-blue);
    background-color: var(--light-blue);
}

.tab-button.active {
    color: var(--primary-blue);
    border-bottom: 2px solid var(--primary-blue);
    background-color: var(--light-blue);
}

.tab-content-container {
    padding: 0 10px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Overview Tab Content */
.content-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    margin-bottom: 25px;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 500;
}

.content-stats span {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--light-blue);
    padding: 8px 15px;
    border-radius: 25px;
    color: var(--primary-blue);
}

.content-stats i {
    color: var(--dark-blue);
}

.book-description-text h3 {
    font-size: 1.8rem;
    color: var(--primary-blue);
    margin-bottom: 15px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 10px;
}

.book-description-text p {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--secondary-text-color);
    white-space: pre-wrap;
}

/* Audio Tab Content */
.audio-list-header {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.audio-list-header h3 {
    font-size: 1.8rem;
    color: var(--primary-blue);
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-parts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.audio-list-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    border-radius: 8px;
    margin-bottom: 5px;
}

.audio-list-item:hover {
    background-color: var(--light-blue);
    transform: translateX(5px);
}

.audio-list-item.playing {
    background-color: var(--light-blue);
    border-left: 5px solid var(--primary-blue);
    padding-left: 15px;
}


.audio-list-item:last-child {
    border-bottom: none;
}

.play-icon {
    font-size: 1.8rem;
    color: var(--primary-blue);
    flex-shrink: 0;
}

.audio-info {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;

    overflow: hidden;
}

.audio-title-wrapper {
    display: flex;
    /* Use flexbox to align the title and part number */
    align-items: baseline;
    /* Aligns the text nicely on the same line */
    flex-grow: 1;
    /* Allows the wrapper to take up available space */
    min-width: 0;
    /* CRUCIAL for flexbox truncation to work */
    margin-right: 15px;
    font-size: 1.0rem;
    font-weight: 500;
    color: var(--text-color);
}

/* 2. Apply truncation ONLY to the main title text */
.title-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 3. Protect the part number from ever being hidden */
.part-text {
    flex-shrink: 0;
    /* This is the magic property! It prevents this element from shrinking. */
    margin-left: 0.5em;
    /* Adds a small space between the title and the part number */
}

.audio-duration {
    font-size: 0.9rem;
    color: var(--secondary-text-color);
    flex-shrink: 0;
}

.no-audio-message {
    text-align: center;
    color: var(--secondary-text-color);
    font-style: italic;
    padding: 20px;
}

/* Sticky Tabs */
.tabs.sticky {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: var(--card-bg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 999;
    padding-top: 10px;
    padding-bottom: 0px;
    border-bottom: 0px solid var(--primary-blue);
    max-width: 900px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.book-description-page-container.sticky-tabs-active {
    padding-top: 80px;
    /* Adjusted slightly for better spacing */
}

/* Accordion Styles for Read Tab */
.accordion-container {
    margin-top: 20px;
}

.accordion-section {
    margin-bottom: 30px;
}

.accordion-section h2 {
    font-size: 1.8rem;
    color: var(--primary-blue);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    /* Alignment for icons */
    display: flex;
    align-items: center;
    gap: 10px;
}

.accordion-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    transition: background-color 0.3s ease;
}

.accordion-header:hover {
    background-color: var(--light-blue);
}

.accordion-icon {
    transition: transform 0.3s ease;
}

.accordion-header.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: #fff;
}

.accordion-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.accordion-content li {
    padding: 12px 20px;
    border-top: 1px solid #f0f0f0;
    color: var(--secondary-text-color);
}


/* Responsive Adjustments */
@media (max-width: 768px) {
    .book-description-page-container {
        margin: 0px;
        padding: 20px;
        border-radius: 10px;
    }

    .book-header-section {
        flex-direction: column;
        text-align: center;
        gap: 20px;
        margin-bottom: 30px;
    }

    .book-cover-large img {
        width: 150px;
        height: 200px;
    }

    .book-main-title {
        font-size: 2.2rem;
    }

    .book-main-author {
        font-size: 1.2rem;
    }

    .tabs {
        margin-bottom: 15px;
    }

    .content-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .audio-list-item {
        padding: 5px 0px;
        gap: 10px;
    }

    .play-icon {
        font-size: 1.5rem;
    }

    .title-text {
        white-space: normal;

        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 1rem;
    }

    .audio-info {
        flex-direction: column;
        /* Stack items vertically */
        align-items: flex-start;
        /* Align them to the left */
        gap: 4px;
        /* Add a small space between them */
    }

    .audio-duration {
        font-size: 0.85rem;
    }

    .tabs.sticky {
        max-width: 100%;
        border-radius: 0;
        padding-left: 10px;
        padding-right: 10px;
        transform: translateX(0);
        left: 0;
        flex-direction: row;
        justify-content: space-around;
    }

    .book-description-page-container.sticky-tabs-active {
        padding-top: 80px;
    }
}

@media (max-width: 480px) {
    .book-main-title {
        font-size: 1.8rem;
    }

    .book-main-author {
        font-size: 1rem;
    }

    .book-description-text h3,
    .audio-list-header h3,
    .accordion-section h2 {
        font-size: 1.5rem;
    }

    .book-description-text p {
        font-size: 1rem;
    }

    .tab-button {
        padding: 15px 12px;
        font-size: 1rem;
    }
}

.accordion-container {
    margin-top: 20px;
}

.accordion-section {
    margin-bottom: 30px;
}

.accordion-section h2 {
    font-size: 1.8rem;
    color: var(--primary-blue);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.accordion-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.accordion-header:hover {
    background-color: var(--light-blue);
}

.accordion-icon {
    transition: transform 0.3s ease;
}

.accordion-header.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.accordion-content ul {
    list-style: none;
    padding: 5px 10px 10px 10px;
    margin: 0;
    background-color: #f8f9fa;
}

.accordion-content li {
    padding: 0;
    border: none;
}

.accordion-part-item {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 5px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.accordion-part-item:hover {
    border-color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* Renamed from .part-play-button */
.part-icon {
    font-size: 1.8rem;
    /* Made slightly smaller */
    color: var(--primary-blue);
    width: 30px;
    /* Give it a fixed width for alignment */
    text-align: center;
}

.part-details {
    flex-grow: 1;
}

.part-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.part-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-color);
}

.part-duration {
    font-size: 0.9rem;
    color: var(--secondary-text-color);
    display: flex;
    align-items: center;
    gap: 5px;
}

.part-snippet {
    font-size: 0.95rem;
    color: var(--secondary-text-color);
    line-height: 1.5;
    margin: 0;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    /* Limit to 3 lines */
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.no-parts {
    padding: 15px;
    color: var(--secondary-text-color);
    font-style: italic;
    list-style-type: none;
}

#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 */
}

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

    .part-snippet {
        -webkit-line-clamp: 2;

    }

    .accordion-header {
        align-items: center;
    }

    .accordion-title-text {
        /* Allow the text to wrap */
        white-space: normal;

        /* Apply the 2-line clamp */
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}