/* ===================================
   ENHANCED ARTICLE DETAIL STYLES
   Improved Featured Image & Mobile Responsive
   v3 FIX: Added padding: 0 1rem to .article-detail-content at 768px
           breakpoint so image bleed (-1rem) works correctly and text
           doesn't go edge-to-edge on mobile.
   ================================== */

/* ===================================
   READING PROGRESS BAR
   ================================== */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    width: 0%;
    z-index: 9999;
    transition: width 0.1s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
    display: block;
    opacity: 1;
}

/* ===================================
   FEATURED IMAGE - NATURAL HEIGHT
   ================================== */
.article-featured-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin-top: 2rem;
    margin-bottom: 2.5rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(37, 99, 235, 0.55)),
        #0f172a;
}

.article-detail-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center;
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.article-featured-image-container:hover .article-detail-image {
    transform: scale(1.01);
}

.article-inline-media {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(37, 99, 235, 0.5)),
        #0f172a;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
}

.article-inline-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center;
}

/* ===================================
   TAGS WITH SHOW MORE/LESS
   ================================== */
.article-tags-container {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #e5e7eb;
}

.article-tags-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.article-tags-header i {
    color: #6b7280;
    font-size: 1.25rem;
}

.article-tags-header h4 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #374151;
}

.article-tags-wrapper {
    position: relative;
}

.article-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-height: 80px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    position: relative;
}

.article-tags-list.expanded {
    max-height: none;
}

.article-tags-list::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, white);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.article-tags-list.expanded::after {
    opacity: 0;
}

.article-tag {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #f3f4f6;
    color: #374151;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.article-tag:hover {
    background: #3b82f6;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
}

.tags-show-more {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.tags-show-more:hover {
    background: #f9fafb;
    border-color: #3b82f6;
    color: #3b82f6;
}

.tags-show-more i {
    transition: transform 0.3s ease;
}

.tags-show-more.expanded i {
    transform: rotate(180deg);
}

/* ===================================
   SHARE BUTTONS RESPONSIVE
   ================================== */
.article-share {
    margin-top: 2rem;
    padding: 2rem;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #f3f4f6;
}

.article-share h4 {
    margin-bottom: 1.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-share h4 i {
    color: #3b82f6;
}

.article-share-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.article-share-buttons .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.article-share-buttons .btn i {
    font-size: 1.1rem;
}

/* ===================================
   AUTHOR WIDGET
   ================================== */
.author-widget-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.author-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    flex-shrink: 0;
}

/* ===================================
   SIDEBAR IMPROVEMENTS
   ================================== */
.sidebar-widget {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
    border: 1px solid #f3f4f6;
}

/* ✅ Mobile author widget - hidden by default, shown only on mobile */
.author-widget-mobile {
    display: none;
}

/* ✅ Ensure proper display control */
@media (min-width: 992px) {
    .author-widget-mobile {
        display: none !important;
    }
}

.popular-item {
    display: flex;
    gap: 1rem;
    text-decoration: none;
    padding: 0.75rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.popular-item:hover {
    background: #f9fafb;
    border-color: #e5e7eb;
    transform: translateX(4px);
}

.popular-item img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

/* ===================================
   MOBILE RESPONSIVE (max-width: 768px)
   ================================== */
@media (max-width: 768px) {
    .article-detail-header {
        padding: 1rem;
        margin-top: 2rem;
    }

    .article-detail-title {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    .article-detail-meta {
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .article-meta-item {
        font-size: 0.75rem;
        padding-left: 0.5rem;
    }

    .article-meta-item::before {
        width: 2px;
    }

    /* ✅ Featured image stays full width */
    .article-featured-image-container {
        margin-top: 1.5rem;
        margin-bottom: 2rem;
        border-radius: 8px;
        margin-left: 0;
        margin-right: 0;
    }

    .article-inline-media {
        border-radius: 0;
    }

    /*
     * ✅ FIX v3: Tambahkan padding horizontal pada konten artikel.
     *    Tanpa ini, teks mepet ke tepi layar karena hanya ada
     *    Bootstrap gutter (0.75rem) yang tersisa. Selain itu,
     *    image bleed (margin: -1rem) butuh padding 1rem agar bisa
     *    "cancel" dengan benar — tanpa padding ini gambar overflow
     *    melewati gutter Bootstrap dan layout rusak.
     */
    .article-detail-content {
        font-size: 1.125rem;
        line-height: 1.4;
        color: #374151;
        padding: 0 1rem;
    }

    /* ✅ FIX v3: Override text-align:justify dari konten artikel.
     *    justify terlihat buruk di layar sempit karena word-spacing
     *    menjadi tidak merata. Paksa left alignment di mobile. */
    .article-detail-content [style*="text-align:justify"],
    .article-detail-content [style*="text-align: justify"] {
        text-align: left !important;
    }

    /* ✅ CRITICAL: Reset all default margins first */
    .article-detail-content > * {
        margin-top: 0;
    }

    .article-detail-content p {
        margin-bottom: 0.75rem;
        margin-top: 0;
        line-height: 1.4;
    }

    /* ✅ FIX: Consistent spacing for all paragraphs */
    .article-detail-content > p {
        margin-bottom: 0.75rem !important;
        margin-top: 0 !important;
    }

    /* ✅ Remove spacing between consecutive paragraphs if needed */
    .article-detail-content p + p {
        margin-top: 0;
    }

    /* ✅ FIX: Reset line-height for br tags */
    .article-detail-content br {
        display: block;
        content: "";
        margin: 0;
        line-height: 0.3;
        height: 0.3em;
    }

    /* ✅ Alternative: Control spacing between lines with br */
    .article-detail-content p br {
        line-height: 0.2;
        height: 0.2em;
    }

    /*
     * ✅ FIX v3: Image bleed menggunakan negative margin -1rem.
     *    Sekarang padding: 0 1rem sudah ada di atas, sehingga
     *    -1rem tepat men-cancel padding dan gambar span full col width.
     *    border-radius: 0 agar gambar terasa edge-to-edge di dalam kolom.
     */
    .article-detail-content img,
    .article-detail-content .article-product-card,
    .article-detail-content .article-video-wrapper,
    .article-detail-content .article-internal-link {
        margin-left: -1rem;
        margin-right: -1rem;
        max-width: calc(100% + 2rem);
        width: calc(100% + 2rem);
        border-radius: 0;
    }

    /* ✅ Other sections keep their own padding */
    .article-tags-container {
        padding: 0 1rem;
    }

    .article-share {
        margin: 0 1rem;
    }

    .related-articles {
        padding: 0 1rem;
    }

    .article-detail-content h1 {
        font-size: 2rem;
    }

    .article-detail-content h2 {
        font-size: 1.75rem;
    }

    .article-detail-content h3 {
        font-size: 1.5rem;
    }

    .article-detail-content h4 {
        font-size: 1.25rem;
    }

    .article-detail-content h5 {
        font-size: 1.125rem;
    }

    .article-tags-container {
        margin-top: 2rem;
        padding-top: 1.5rem;
    }

    .article-tags-list {
        max-height: 60px;
    }

    .article-tag {
        font-size: 0.8125rem;
        padding: 0.375rem 0.875rem;
    }

    .article-share {
        padding: 1.5rem 1rem;
    }

    .article-share h4 {
        font-size: 1.125rem;
    }

    .article-share-buttons .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .related-articles {
        margin-top: 3rem;
    }

    .related-articles-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .related-articles-grid {
        gap: 1rem;
    }

    .sidebar-widget {
        padding: 1rem;
    }

    .popular-item {
        padding: 0.5rem;
    }

    .popular-item img {
        width: 60px;
        height: 45px;
    }

    /* ✅ Show mobile author widget, hide desktop sidebar author */
    .author-widget-mobile {
        display: block !important;
        margin: 2rem 0;
    }
}

/* ===================================
   MOBILE RESPONSIVE (max-width: 576px)
   ================================== */
@media (max-width: 576px) {
    .article-card-category {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    .article-detail-header {
        padding: 0.75rem;
    }

    .article-detail-title {
        font-size: 1.35rem;
    }

    .article-detail-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.625rem;
    }

    .article-meta-item {
        font-size: 0.7rem;
    }

    /* ✅ Featured image stays full width */
    .article-featured-image-container {
        margin-top: 1rem;
        margin-bottom: 1.5rem;
        border-radius: 6px;
        margin-left: 0;
        margin-right: 0;
    }

    .article-inline-media {
        border-radius: 0;
    }

    /* ✅ Padding inherited from 768px rule, override font size only */
    .article-detail-content {
        font-size: 0.9375rem;
        padding: 0 1rem;
    }

    /* ✅ Justify override juga berlaku di 576px */
    .article-detail-content [style*="text-align:justify"],
    .article-detail-content [style*="text-align: justify"] {
        text-align: left !important;
    }

    /* ✅ Image bleed — sama seperti 768px, padding sudah 1rem */
    .article-detail-content img,
    .article-detail-content .article-product-card,
    .article-detail-content .article-video-wrapper,
    .article-detail-content .article-internal-link {
        margin-left: -1rem;
        margin-right: -1rem;
        max-width: calc(100% + 2rem);
        width: calc(100% + 2rem);
        border-radius: 0;
    }

    .article-tags-container {
        padding: 0 1rem;
    }

    .article-share {
        margin: 0 1rem;
    }

    .related-articles {
        padding: 0 1rem;
    }

    .author-widget-mobile {
        margin: 2rem 1rem;
    }

    .article-detail-content h1 {
        font-size: 1.75rem;
        margin-top: 2rem;
    }

    .article-detail-content h2 {
        font-size: 1.5rem;
        margin-top: 1.75rem;
    }

    .article-detail-content h3 {
        font-size: 1.25rem;
        margin-top: 1.5rem;
    }

    .article-detail-content h4 {
        font-size: 1.125rem;
    }

    .article-detail-content h5 {
        font-size: 1rem;
    }

    .article-tags-header {
        gap: 0.5rem;
    }

    .article-tags-header i {
        font-size: 1rem;
    }

    .article-tags-header h4 {
        font-size: 1rem;
    }

    .article-tags-list {
        max-height: 48px;
        gap: 0.375rem;
    }

    .article-tag {
        font-size: 0.75rem;
        padding: 0.3rem 0.75rem;
    }

    .tags-show-more {
        padding: 0.375rem 0.875rem;
        font-size: 0.8125rem;
    }

    .article-share {
        padding: 1.25rem 0.875rem;
    }

    .article-share h4 {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .article-share-buttons {
        gap: 0.5rem;
    }

    .article-share-buttons .btn {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 0;
        padding: 0.5rem 0.75rem;
        justify-content: center;
    }

    .article-share-buttons .btn span {
        display: none;
    }

    .article-share-buttons .btn i {
        margin: 0;
        font-size: 1rem;
    }

    .related-articles {
        margin-top: 2rem;
    }

    .related-articles-title {
        font-size: 1.35rem;
        margin-bottom: 1.25rem;
    }

    .related-articles-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }

    .author-photo {
        width: 60px;
        height: 60px;
        border-width: 2px;
    }

    .author-widget-content {
        gap: 0.75rem;
    }

    .sidebar-widget-title {
        font-size: 1rem;
    }

    .popular-item {
        gap: 0.75rem;
    }

    .popular-item img {
        width: 50px;
        height: 38px;
    }

    .popular-item h6 {
        font-size: 0.875rem;
    }

    .popular-item .ranking-badge {
        width: 28px;
        height: 28px;
        font-size: 0.875rem;
    }
}

/* ===================================
   TABLET LANDSCAPE (max-width: 991px)
   ================================== */
@media (max-width: 991px) {
    .articles-sidebar {
        position: static !important;
        margin-top: 3rem;
    }
}

/* ===================================
   PRINT STYLES
   ================================== */
@media print {
    .article-featured-image-container {
        page-break-inside: avoid;
        padding-bottom: 50%;
    }

    .article-share,
    .related-articles,
    .articles-sidebar {
        display: none;
    }

    .article-detail-content {
        font-size: 12pt;
        line-height: 1.6;
    }

    .article-tags-list {
        max-height: none;
    }

    .tags-show-more {
        display: none;
    }
}

/* ===================================
   ACCESSIBILITY IMPROVEMENTS
   ================================== */
.article-tag:focus,
.tags-show-more:focus,
.article-share-buttons .btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.article-detail-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ===================================
   PERFORMANCE OPTIMIZATIONS
   ================================== */
.article-detail-image,
.popular-item img,
.author-photo {
    will-change: transform;
}

.article-tags-list,
.article-share-buttons {
    contain: layout;
}

/* ===================================
   INLINE FORMATTING - FORCE STYLES
   Ensure bold/italic/underline render
   correctly regardless of source
   ================================== */
.article-detail-content strong,
.article-detail-content b {
    font-weight: 700 !important;
    font-family: 'Poppins', sans-serif;
}

.article-detail-content em,
.article-detail-content i {
    font-style: italic !important;
    font-family: 'Poppins', sans-serif;
}

.article-detail-content u {
    text-decoration: underline !important;
}

.article-detail-content p strong,
.article-detail-content p b {
    font-weight: 700 !important;
}

.article-detail-content p em,
.article-detail-content p i {
    font-style: italic !important;
}

.article-detail-content span[style*="font-weight"] {
    font-family: 'Poppins', sans-serif;
}
