/* Articles CSS */

/* Ensure parent container allows sticky */
.max-width-1440 {
    overflow: visible !important;
    max-width: 100%;
    box-sizing: border-box;
}

/* Article Layout Container - Parent */
.w-100.d-flex.flex-row {
    overflow: visible !important;
    align-items: flex-start;
    max-width: 100%;
    box-sizing: border-box;
    width: 100%;
}

/* Article Layout Container */
.article-content,
.author-sidebar,
.toc-sidebar {
    align-self: flex-start;
    height: fit-content;
    box-sizing: border-box;
}

/* Breadcrumb Styles */
.breadcrumb-item a:hover {
    color: #039BC1 !important;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "" !important;
    display: inline-block;
    width: 8px;
    height: 12px;
    background-image: url("../../assets/images/right.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    margin: 0 0.5rem;
    margin-top: 0.25rem;
    vertical-align: middle;
}

/* Author Sidebar */
.author-sidebar {
    min-width: 140px;
    max-width: 180px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    z-index: 10;
    height: fit-content;
    flex-shrink: 0;
    box-sizing: border-box;
}

@media (min-width: 992px) {
    .author-sidebar.w-lg-15 {
        flex: 0 0 auto;
        width: auto;
        min-width: 140px;
        max-width: 180px;
    }
}

.author-card {
    background: white;
    border: 1px solid #DDDDDD;
    border-radius: 10px;
    padding: 0.75rem;
    text-align: center;
    margin-bottom: 0.75rem !important;
}

.article-metadata-card {
    background: white;
    border: 1px solid #DDDDDD;
    border-radius: 10px;
    padding: 0.75rem;
}

.author-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto;
    border: 2px solid #039BC1;
}

.author-avatar-no-image {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #f8f9fa;
    border: 2px solid #039BC1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    color: #666;
}

    .author-avatar-no-image svg {
        width: 28px;
        height: 28px;
    }

.author-social {
    justify-content: center;
    gap: 0.5rem !important;
}

.social-link {
    /* color: #666; */
    color: #039BC1;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
}

    .social-link svg {
        width: 16px;
        height: 16px;
    }

    .social-link:hover {
        color: #039BC1;
        background-color: #e8f4f8;
        text-decoration: none;
    }

.metadata-item svg {
    color: #666;
    flex-shrink: 0;
}

/* Metadata Share Menu */
.metadata-share-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

    .metadata-share-container::after {
        content: '';
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        height: 0.5rem;
        background: transparent;
        z-index: 999;
    }

.metadata-share-button {
    transition: color 0.3s ease;
}

    .metadata-share-button:hover {
        color: #039BC1;
    }

        .metadata-share-button:hover svg {
            color: #039BC1;
        }

.metadata-share-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    background: white;
    border: 1px solid #DDDDDD;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: scaleY(0);
    transform-origin: bottom;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    pointer-events: none; /* Prevent interaction when hidden */
}

    .metadata-share-container:hover .metadata-share-menu,
    .metadata-share-menu:hover {
        opacity: 1;
        visibility: visible;
        transform: scaleY(1);
        pointer-events: auto; /* Enable interaction when visible */
    }

.metadata-share-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    font-family: poppins, sans-serif;
    font-size: 14px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

    .metadata-share-menu-item:hover {
        background-color: #f8f9fa;
    }

    .metadata-share-menu-item:first-child {
        border-bottom: 1px solid #DDDDDD;
    }

.metadata-share-menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background-color: #333;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.metadata-share-menu-item:hover .metadata-share-menu-icon {
    background-color: #039BC1;
}

/* Article Content */
.article-content {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
}

.article-card {
    background: white;
    border: 1px solid #DDDDDD;
    border-radius: 12px;
    padding: 2rem;
}

.article-featured-image {
    width: 100%;
    overflow: hidden;
}

    .article-featured-image img {
        width: 100%;
        height: auto;
        object-fit: cover;
    }

.article-section {
    margin-bottom: 3rem;
    scroll-margin-top: 100px;
}

/* Table of Contents Sidebar */
.toc-sidebar {
    min-width: 140px;
    max-width: 180px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    z-index: 10;
    height: fit-content;
    flex-shrink: 0;
    box-sizing: border-box;
}

@media (min-width: 992px) {
    .toc-sidebar.w-lg-15 {
        flex: 0 0 auto;
        width: auto;
        min-width: 140px;
        max-width: 180px;
    }

    .article-content.w-lg-70 {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
        max-width: none;
    }
}

.toc-card {
    background: white;
    border: 1px solid #DDDDDD;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    min-height: auto;
    height: fit-content;
    transition: border-radius 0.3s ease;
}

    .toc-card.collapsed {
        min-height: auto;
        height: auto;
        border-radius: 10px; /* Fully rounded when collapsed since only header is visible */
    }

.toc-header {
    background-color: #E8F4F8;
    padding: 0.625rem 0.75rem;
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}

.toc-card.collapsed .toc-header {
    border-radius: 10px; /* Fully rounded when collapsed */
}

.toc-title {
    font-size: 13px !important;
}

.toc-toggle-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    color: #333;
    transform: rotate(180deg); /* Default: pointing up when expanded */
}

    .toc-toggle-btn:hover {
        color: #039BC1;
    }

    .toc-toggle-btn.collapsed {
        transform: rotate(0deg); /* Pointing down when collapsed */
    }

.toc-list.collapsed {
    max-height: 0 !important;
    min-height: 0 !important;
    height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin: 0 !important;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

.toc-list:not(.collapsed) {
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.toc-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0.625rem 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    box-sizing: border-box;
    min-height: 0;
    /* Max-height for exactly 5 items (will be calculated dynamically by JS if more than 5 items exist):
       Default fallback: ~8.5rem for 5 items */
    max-height: 8.5rem;
    scrollbar-width: thin;
    scrollbar-color: #039BC1 #f0f0f0;
    list-style: none;
    margin: 0;
}

    /* When there are more than 5 items, allow more height but still show scrollbar */
    .toc-list.has-more-items {
        max-height: calc(100vh - 120px);
    }

    /* Custom Scrollbar */
    .toc-list::-webkit-scrollbar {
        width: 5px;
    }

    .toc-list::-webkit-scrollbar-track {
        background: #f0f0f0;
        border-radius: 10px;
        margin: 5px 0;
    }

    .toc-list::-webkit-scrollbar-thumb {
        background: #039BC1;
        border-radius: 10px;
    }

        .toc-list::-webkit-scrollbar-thumb:hover {
            background: #0288a1;
        }

/* Ensure scrolling works when content overflows */
.toc-card {
    max-height: calc(100vh - 40px);
}

.toc-item {
    position: relative;
    padding-left: 0;
    list-style: none;
    margin: 0;
}

.toc-radio {
    width: 10px;
    height: 10px;
    min-width: 10px;
    border-radius: 50%;
    border: 2px solid #039BC1;
    background-color: transparent;
    flex-shrink: 0;
    transition: all 0.3s ease;
    display: block;
    margin: 0;
    align-self: center;
}

.toc-item.active .toc-radio {
    background-color: #039BC1;
    border-color: #039BC1;
}

.toc-link {
    position: relative;
    z-index: 1;
    width: 100%;
    font-size: 12px !important;
    padding: 0.375rem 0 !important;
    gap: 0.5rem !important;
}

.toc-text {
    flex: 1;
}

.toc-item.active .toc-link {
    color: #333 !important;
    font-weight: 500;
}

.toc-link:hover {
    color: #039BC1 !important;
    text-decoration: none;
}

    .toc-link:hover .toc-radio {
        border-color: #039BC1;
        background-color: #039BC1;
    }

/* Responsive Styles */
@media (max-width: 991px) {
    /* Center the parent container on mobile */
    .w-100.d-flex.flex-row.flex-column.flex-lg-row {
        align-items: center !important;
        justify-content: center !important;
    }

    .author-sidebar {
        position: static;
        width: 100% !important;
        max-width: 400px !important;
        min-width: auto !important;
        margin: 0 auto 2rem auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .toc-sidebar {
        position: static;
        width: 100% !important;
        max-width: 400px !important;
        min-width: auto !important;
        margin: 0 auto 2rem auto;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .author-card,
    .article-metadata-card {
        position: static;
        width: 100%;
        max-width: 100%;
        margin: 0 auto 0.75rem auto;
    }

    .toc-card {
        position: static;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }

    .article-content {
        width: 100% !important;
    }

    .article-card {
        padding: 1.5rem;
    }

    .article-title {
        font-size: 32px !important;
    }

    .section-title {
        font-size: 24px !important;
    }
}

@media (max-width: 768px) {
    .author-sidebar {
        max-width: 100% !important;
    }

    .toc-sidebar {
        max-width: 100% !important;
    }

    .article-card {
        padding: 1rem;
    }

    .article-title {
        font-size: 28px !important;
    }

    .section-title {
        font-size: 22px !important;
    }

    .author-card,
    .article-metadata-card,
    .toc-card {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .article-title {
        font-size: 24px !important;
    }

    .section-title {
        font-size: 20px !important;
    }
}

/* References Section */
.references-section {
    margin-top: 3rem;
}

.references-title {
    font-family: poppins, sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: #333;
    margin-bottom: 1.5rem;
}

.references-list {
    list-style: disc;
    padding-left: 1.5rem;
    margin: 0;
}

    .references-list li {
        margin-bottom: 0.75rem;
    }

    .references-list a {
        font-family: poppins, sans-serif;
        font-size: 16px;
        color: #039BC1;
        text-decoration: none;
        transition: color 0.3s ease;
    }

        .references-list a:hover {
            color: #0288a1;
            text-decoration: underline;
        }

/* Comments Section */
.comments-section {
    margin-top: 3rem;
}

.comments-title {
    font-family: poppins, sans-serif;
    font-size: 32px;
    font-weight: 600;
    color: #333;
    margin-bottom: 1.5rem;
}

.comments-textarea {
    font-family: poppins, sans-serif;
    font-size: 16px;
    color: #333;
    width: 100%;
    padding: 1rem;
    border: 1px solid #DDDDDD;
    border-radius: 12px;
    resize: vertical;
    outline: none;
    transition: border-color 0.3s ease;
}

    .comments-textarea:focus {
        border-color: #039BC1;
    }

    .comments-textarea::placeholder {
        color: #999;
    }

.comments-send-btn {
    font-family: poppins, sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: white;
    background-color: #039BC1;
    border: none;
    border-radius: 12px;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.3s ease;
    cursor: pointer;
}

    .comments-send-btn:hover {
        background-color: #0288a1;
    }

    .comments-send-btn svg {
        flex-shrink: 0;
    }

/* Recommended Articles Section */
.recommended-articles-section {
    margin-top: 3rem;
}

.recommended-title {
    font-family: poppins, sans-serif;
    font-size: 32px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.recommended-swiper-navigation {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

/* Swiper Navigation Buttons */
.recommended-button-next,
.recommended-button-prev {
    position: static !important;
    width: 35px !important;
    height: 35px !important;
    margin: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    transition: all 0.3s ease;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
}

.recommended-button-next {
    background-color: #039BC1 !important;
    color: white !important;
    border: 1px solid #039BC1 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.recommended-button-prev {
    border: 1px solid #039BC1 !important;
    background-color: white !important;
    color: #039BC1 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

    .recommended-button-next:hover,
    .recommended-button-prev:hover {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(3, 155, 193, 0.3);
    }

.recommended-button-next:hover {
    background-color: #0288a1 !important;
}

.recommended-button-prev:hover {
    background-color: #f8f9fa !important;
    border-color: #039BC1 !important;
}

.recommended-button-next::after,
.recommended-button-prev::after {
    font-size: 20px !important;
    font-weight: bold !important;
}

.recommended-button-next.swiper-button-disabled,
.recommended-button-prev.swiper-button-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.recommendedArticlesSwiper {
    width: 100%;
    padding-bottom: 20px;
    overflow: hidden;
}

    .recommendedArticlesSwiper .swiper-wrapper {
        display: flex;
    }

    .recommendedArticlesSwiper .swiper-slide {
        height: auto;
        box-sizing: border-box;
    }

.recommended-article-card {
    background: white;
    border: 1px solid #DDDDDD;
    border-radius: 12px;
    padding: 0.75rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    margin-top:10px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

    .recommended-article-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

.recommended-image-container {
    width: 100%;
    height: 180px;
    overflow: hidden;
    border-radius: 12px;
    background-color: #f8f9fa;
    position: relative;
    margin-bottom: 0.75rem;
}

.recommended-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    border-radius: 12px;
}

.recommended-article-card:hover .recommended-image {
    transform: scale(1.05);
}

.recommended-arrow-link {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 30px;
    height: 30px;
    background-color: rgba(3, 155, 193, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2;
}

    .recommended-arrow-link:hover {
        background-color: #039BC1;
        transform: scale(1.1);
    }

.recommended-arrow-icon {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

.recommended-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.recommended-link {
    text-decoration: none;
    color: inherit;
    flex: 1;
}

    .recommended-link:hover {
        text-decoration: none;
        color: inherit;
    }

.recommended-title-text {
    font-family: poppins, sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.recommended-description {
    font-family: poppins, sans-serif;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 2;
}

.recommended-author {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: auto;
    flex: 1;
}

.recommended-author-profile {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.recommended-author-info {
    flex: 1;
}

.recommended-author-name {
    font-family: poppins, sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin: 0 0 0.25rem 0;
}

.recommended-author-meta {
    font-family: poppins, sans-serif;
    font-size: 11px;
    color: #666;
    margin: 0;
}

/* Share Menu Styles for Recommended Articles */
.recommended-share-container {
    position: relative;
    display: inline-block;
}

.recommended-share-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #666;
    font-family: poppins, sans-serif;
    font-size: 14px;
    transition: color 0.3s ease;
}

    .recommended-share-button:hover {
        color: #039BC1;
    }

.recommended-share-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border: 1px solid #DDDDDD;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.recommended-share-container:hover .recommended-share-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.recommended-share-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    font-family: poppins, sans-serif;
    font-size: 14px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

    .recommended-share-menu-item:hover {
        background-color: #f8f9fa;
    }

    .recommended-share-menu-item:first-child {
        border-bottom: 1px solid #DDDDDD;
    }

.recommended-share-menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background-color: #333;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.recommended-share-menu-item:hover .recommended-share-menu-icon {
    background-color: #039BC1;
}

/* Responsive Styles for Comments and Recommended */
@media (max-width: 991px) {
    .recommendedArticlesSwiper {
        padding-bottom: 30px;
    }

    .recommended-article-card {
        padding: 0.75rem;
    }

    .recommended-image-container {
        height: 160px;
    }
}

@media (max-width: 768px) {
    .comments-title,
    .recommended-title {
        font-size: 24px !important;
    }

    .recommended-articles-grid {
        gap: 1rem !important;
    }

    .recommended-swiper-navigation {
        margin-top: 1rem;
    }

    .recommended-button-next,
    .recommended-button-prev {
        width: 45px !important;
        height: 45px !important;
    }

        .recommended-button-next::after,
        .recommended-button-prev::after {
            font-size: 18px !important;
        }

    .recommended-image-container {
        height: 150px;
    }

    .recommended-article-card {
        padding: 0.625rem;
    }
}

@media (max-width: 576px) {
    .comments-title,
    .recommended-title {
        font-size: 20px !important;
    }

    .comments-send-btn {
        width: 100%;
        justify-content: center;
    }

    .recommended-swiper-navigation {
        margin-top: 1.5rem;
    }

    .recommended-button-next,
    .recommended-button-prev {
        width: 40px !important;
        height: 40px !important;
    }

        .recommended-button-next::after,
        .recommended-button-prev::after {
            font-size: 16px !important;
        }

    .recommended-image-container {
        height: 140px;
    }

    .recommended-article-card {
        padding: 0.5rem;
    }

    .recommended-title-text {
        font-size: 16px !important;
    }

    .recommended-description {
        font-size: 13px !important;
    }

    .recommended-author-name {
        font-size: 13px !important;
    }

    .recommended-author-meta {
        font-size: 11px !important;
    }
}
