/* ========================================
   BOOK DETAILS PAGE STYLES
   Vietnamese Book Reading Platform
   ======================================== */

/* ==================== LAYOUT & SPACING ==================== */

/* Fix header overlap issue - add extra top padding */
.book-details-page {
    padding-top: 1rem;
}

/* Main container spacing */
.book-details-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ==================== BOOK COVER SECTION ==================== */

.book-cover-wrapper {
    position: relative;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(139, 69, 19, 0.3);
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #D2B48C 0%, #A0826D 50%, #8B4513 100%);
    border: 2px solid rgba(139, 69, 19, 0.2);
}

.book-cover-wrapper img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.book-cover-wrapper:hover {
    transform: translateY(-5px);
    box-shadow: 0 25px 50px rgba(139, 69, 19, 0.4);
    border-color: var(--primary-color);
}

.book-cover-wrapper:hover img {
    transform: scale(1.05);
}

/* ==================== BOOK ACTIONS ==================== */

.book-actions {
    margin-top: 1.5rem;
}

.book-actions .btn {
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    padding: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.book-actions .btn i {
    font-size: 1.25rem;
}

.book-actions .btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
}

.book-actions .btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-dark) 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(139, 69, 19, 0.4);
}

.book-actions .btn-outline-danger {
    border: 2px solid var(--danger-color);
    color: var(--danger-color);
    background: white;
}

.book-actions .btn-outline-danger:hover {
    background: var(--danger-color);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(160, 68, 63, 0.3);
}

.book-actions .bookmark-btn i {
    transition: transform 0.2s ease;
}

.book-actions .bookmark-btn:hover i {
    transform: scale(1.2);
}

/* ==================== BOOK STATS CARD ==================== */

.book-stats {
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: none;
    background: white;
}

.book-stats .card-body {
    padding: 1.5rem;
}

.book-stats .card-body > div {
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.book-stats .card-body > div:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.book-stats .card-body > div:hover {
    padding-left: 0.5rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
}

.book-stats i {
    font-size: 1.1rem;
    margin-right: 0.5rem;
    color: #6c757d;
}

.book-stats strong {
    color: #0d6efd;
    font-weight: 600;
}

/* ==================== BOOK HEADER SECTION ==================== */

.book-header-section {
    margin-bottom: 2rem;
}

.book-header-section h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: #212529;
    line-height: 1.3;
    margin-bottom: 1rem;
    letter-spacing: -0.5px;
}

.book-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.book-metadata .badge {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 2rem;
}

.book-metadata .genre-badge {
    transition: transform 0.2s ease;
}

.book-metadata .genre-badge:hover {
    transform: translateY(-2px);
}

.book-meta-info {
    color: #6c757d;
    font-size: 1rem;
    line-height: 1.6;
}

.book-meta-info strong {
    color: #495057;
    font-weight: 600;
}

.book-meta-info i {
    margin-right: 0.25rem;
    font-size: 1rem;
}

/* ==================== RATING SECTION ==================== */

.rating-section {
    background: linear-gradient(135deg, #fff9e6 0%, #fffbf0 100%);
    padding: 1.5rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.rating-stars {
    color: #ffc107;
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.rating-stars i {
    transition: all 0.2s ease;
}

.rating-stars .average-rating {
    font-size: 1.25rem;
    font-weight: 700;
    color: #495057;
    margin-left: 0.5rem;
}

.user-rating {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.user-rating .bi-star {
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.75rem;
}

.user-rating .bi-star:hover {
    transform: scale(1.3);
    color: #ff9800;
}

/* ==================== CONTENT CARDS ==================== */

.content-card {
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    /*border: none;*/
    background: white;
    margin-bottom: 2rem;
}

.content-card .card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    padding: 1.25rem 1.5rem;
    border-bottom: 2px solid #dee2e6;
}

.content-card .card-header h5 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-card .card-header i {
    font-size: 1.5rem;
    color: #0d6efd;
}

.content-card .card-body {
    padding: 2rem;
    overflow-x: hidden;
}

/* ==================== BOOK DESCRIPTION ==================== */

.book-description {
    font-size: 1rem;
    line-height: 1.8;
    color: #495057;
    text-align: justify;
}

.book-description p {
    margin-bottom: 1rem;
}

/* ==================== CHAPTER LIST ==================== */

.chapter-search-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#chapter-search {
    max-width: 300px;
    border-radius: 2rem;
    border: 2px solid #e9ecef;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
}

#chapter-search:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
    outline: none;
}

.chapter-list-table {
    margin-bottom: 0;
}

.chapter-list-table thead th {
    background: #f8f9fa;
    color: #495057;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #dee2e6;
    padding: 1rem 1.5rem;
}

.chapter-list-table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid #e9ecef;
}

.chapter-list-table tbody tr:hover {
    background: #f8f9fa;
    transform: translateX(5px);
}

.chapter-list-table tbody tr td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
}

.chapter-list-table tbody tr td:first-child {
    font-weight: 600;
    color: #0d6efd;
    font-size: 0.95rem;
}

.chapter-list-table tbody tr td a {
    color: #212529;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.chapter-list-table tbody tr:hover td a {
    color: #0d6efd;
}

/* ==================== COMMENTS SECTION ==================== */

.comments-section .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#comment-form {
    margin-bottom: 2rem;
}

#comment-form textarea {
    border-radius: 0.75rem;
    border: 2px solid #e9ecef;
    padding: 1rem;
    transition: all 0.3s ease;
    resize: vertical;
    min-height: 100px;
}

#comment-form textarea:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
    outline: none;
}

#comment-form .btn {
    border-radius: 0.75rem;
    padding: 0.75rem 2rem;
    font-weight: 600;
}

.comment-item {
    padding: 1.5rem;
    border-radius: 1rem;
    background: #f8f9fa;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.comment-item:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #e9ecef;
    transform: translateY(-2px);
}

.comment-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.75rem;
    flex-shrink: 0;
}

.comment-item h6 {
    font-size: 1rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 0.5rem;
}

.comment-item p {
    font-size: 0.95rem;
    color: #495057;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.comment-item small {
    font-size: 0.85rem;
    color: #6c757d;
}

.comment-item small i {
    margin-right: 0.25rem;
}

/* ==================== RELATED BOOKS SECTION ==================== */

.related-books-section {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 2px solid #e9ecef;
}

.related-books-section h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.related-books-section h3 i {
    font-size: 2rem;
    color: #0d6efd;
}

/* Related books card styling for 4-item layout */
.related-books-section .card {
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: none;
    transition: all 0.3s ease;
    height: 100%;
}

.related-books-section .card:hover {
    /*transform: translateY(-8px);*/
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.related-books-section .card-img-top {
    transition: transform 0.3s ease;
    border-radius: 0;
}

.related-books-section .card:hover .card-img-top {
    transform: scale(1.05);
}

.related-books-section .card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.related-books-section .card-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0;
    min-height: 2.8rem;
}

.related-books-section .card-title a {
    transition: color 0.2s ease;
}

.related-books-section .card-title a:hover {
    color: #0d6efd !important;
}

.related-books-section .rating-stars {
    color: #ffc107;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.related-books-section .rating-stars i {
    font-size: 0.875rem;
}

.related-books-section .rating-stars .text-muted {
    margin-left: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.related-books-section .badge {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.5rem;
}

/* ==================== RESPONSIVE DESIGN ==================== */

@media (max-width: 991px) {
    .book-header-section h1 {
        font-size: 1.75rem;
    }

    .book-cover-wrapper {
        margin-bottom: 2rem;
    }

    .book-stats {
        margin-bottom: 2rem;
    }

    #chapter-search {
        max-width: 100%;
    }

    .content-card .card-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start !important;
    }

    .chapter-search-wrapper {
        width: 100%;
    }

    #chapter-search {
        flex: 1;
    }
}

@media (max-width: 767px) {
    .book-details-page {
        padding-top: 0.5rem;
    }

    .book-header-section h1 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }

    .book-metadata {
        gap: 0.5rem;
    }

    .book-metadata .badge {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .book-actions .btn {
        font-size: 0.95rem;
        padding: 0.875rem;
    }

    .rating-stars {
        font-size: 1.25rem;
    }

    .rating-stars .average-rating {
        font-size: 1rem;
    }

    .user-rating .bi-star {
        font-size: 1.5rem;
    }

    .content-card .card-header {
        padding: 1rem;
    }

    .content-card .card-header h5 {
        font-size: 1.1rem;
    }

    .content-card .card-body {
        padding: 1.25rem;
    }

    .chapter-list-table thead th {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }

    .chapter-list-table tbody tr td {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .comment-item {
        padding: 1rem;
    }

    .comment-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .related-books-section {
        margin-top: 3rem;
        padding-top: 2rem;
    }

    .related-books-section h3 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

/*    .related-books-section .card-img-top {
        height: 250px !important;
    }*/

    .related-books-section .card-title {
        font-size: 0.95rem;
        min-height: 2.6rem;
    }
}

@media (max-width: 575px) {
    .book-meta-info {
        font-size: 0.9rem;
    }

    .book-stats .card-body {
        padding: 1rem;
    }

    .book-stats .card-body > div {
        padding: 0.5rem 0;
    }

    .chapter-list-table {
        font-size: 0.85rem;
    }

    .chapter-list-table thead th:last-child,
    .chapter-list-table tbody tr td:last-child {
        display: none; /* Hide date column on very small screens */
    }

    #comment-form .btn {
        width: 100%;
        padding: 1rem;
    }

    .related-books-section {
        margin-top: 2rem;
        padding-top: 1.5rem;
    }

    .related-books-section h3 {
        font-size: 1.25rem;
        margin-bottom: 1.25rem;
    }

/*    .related-books-section .card-img-top {
        height: 320px !important;
    }*/

    .related-books-section .card-body {
        padding: 1rem;
    }

    .related-books-section .card-title {
        font-size: 0.9rem;
        min-height: 2.4rem;
    }
}

/* ==================== LOADING STATES ==================== */

.book-details-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50vh;
}

.book-details-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .book-actions,
    .book-stats,
    .comments-section,
    .related-books-section,
    #chapter-search {
        display: none !important;
    }

    .book-cover-wrapper {
        box-shadow: none;
        max-width: 300px;
    }

    .content-card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }

    .chapter-list-table tbody tr:hover {
        background: transparent;
        transform: none;
    }
}

/* ==================== ACCESSIBILITY ==================== */

.book-actions .btn:focus,
#chapter-search:focus,
#comment-form textarea:focus,
.chapter-list-table tbody tr td a:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .content-card {
        border: 2px solid #212529;
    }

    .book-stats .card-body > div {
        border-bottom: 2px solid #495057;
    }

    .chapter-list-table tbody tr {
        border-bottom: 2px solid #495057;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .book-cover-wrapper,
    .book-cover-wrapper img,
    .book-actions .btn,
    .chapter-list-table tbody tr,
    .comment-item,
    .rating-stars i,
    .related-books-section .card,
    .related-books-section .card-img-top {
        transition: none !important;
        animation: none !important;
    }

    .book-cover-wrapper:hover,
    .book-actions .btn:hover,
    .chapter-list-table tbody tr:hover,
    .comment-item:hover,
    .related-books-section .card:hover,
    .related-books-section .card:hover .card-img-top {
        transform: none !important;
    }
}
