/* ✅ UPDATED: Compact Header Design - Full Width */
.article-detail-header {
    margin-top: 4rem;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    padding: 1.5rem 2rem;
    border-radius: 16px;
    margin-bottom: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    position: relative;
    overflow: hidden;
}

.article-detail-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    border-radius: 16px 16px 0 0;
}

/* Category Badge Compact */
.article-card-category {
    display: inline-flex !important;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1e40af;
    border-radius: 50px;
    font-size: 0.8125rem;
    font-weight: 700;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15);
    border: 2px solid #bfdbfe;
    margin-bottom: 0.75rem !important;
}

.article-card-category::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #3b82f6;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.article-card-category:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.7; transform: scale(1.3); }
}

/* Article Title Compact */
.article-detail-title {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.3;
    color: #1f2937;
    margin: 0.75rem 0 1rem 0;
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
    word-break: break-word; /* ✅ FIX: judul panjang tidak overflow */
}

/* Meta Information Compact */
.article-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #f3f4f6;
}

.article-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
    position: relative;
    padding-left: 0.75rem;
}

.article-meta-item::before {
    content: '';
    position: absolute;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 2px;
}

.article-meta-item:first-child::before {
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
}

.article-meta-item:nth-child(2)::before {
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
}

.article-meta-item:nth-child(3)::before {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}

.article-meta-item:last-child::before {
    background: linear-gradient(180deg, #8b5cf6 0%, #7c3aed 100%);
}

.article-meta-item i {
    font-size: 1rem;
    color: #3b82f6;
}

.article-meta-item:first-child i  { color: #10b981; }
.article-meta-item:nth-child(2) i { color: #f59e0b; }
.article-meta-item:nth-child(3) i { color: #ef4444; }
.article-meta-item:last-child i   { color: #8b5cf6; }

/* ✅ UPDATED: Full Width Featured Image */
.article-featured-image-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
    margin-bottom: 2.5rem;
    overflow: hidden;
    border-radius: 12px;
    background: #0f172a;
}

.article-detail-image {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain;
    object-position: center;
    display: block;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* ===================================
   ARTICLE CONTENT — GLOBAL OVERFLOW FIX
   ✅ FIX v3: overflow-x:hidden + word-break secara GLOBAL.
      Ini adalah fix utama: elemen apapun di dalam konten artikel
      (URL panjang, tabel, product card, injected HTML dari controller)
      tidak akan bisa memaksa horizontal scroll halaman.
   =================================== */
.article-detail-content {
    font-family: 'Poppins', sans-serif;
    font-size: 1.125rem;
    line-height: 1.8;
    color: #374151;
    /* ✅ Tiga baris ini adalah core fix — JANGAN dihapus */
    overflow-x: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
    /* Pastikan box model konsisten */
    box-sizing: border-box;
    max-width: 100%;
}

.article-detail-content p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
    word-break: break-word;      /* ✅ FIX */
    overflow-wrap: break-word;   /* ✅ FIX */
}

.article-detail-content h1,
.article-detail-content h2,
.article-detail-content h3,
.article-detail-content h4,
.article-detail-content h5 {
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    font-weight: 800;
    line-height: 1.3;
    color: #1f2937;
    word-break: break-word; /* ✅ FIX */
}

.article-detail-content h1 { font-size: 2.5rem; }
.article-detail-content h2 { font-size: 2rem; }
.article-detail-content h3 { font-size: 1.75rem; }
.article-detail-content h4 { font-size: 1.5rem; }
.article-detail-content h5 { font-size: 1.25rem; }

.article-detail-content p {
    margin: 0.85rem 0 !important;
    line-height: 1.75 !important;
}

.article-detail-content .article-paragraph {
    margin: 0.85rem 0 !important;
    line-height: 1.75 !important;
    font-family: 'Poppins', sans-serif !important;
    font-size: 1.125rem !important;
    font-weight: 400 !important;
    color: #374151 !important;
    word-break: break-word;
    overflow-wrap: break-word;
}

.article-detail-content .article-paragraph,
.article-detail-content .article-paragraph * {
    font-family: 'Poppins', sans-serif !important;
    font-size: 1.125rem !important;
    line-height: 1.75 !important;
    color: inherit !important;
}

.article-detail-content .article-paragraph {
    font-weight: 400 !important;
}

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

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

.article-detail-content h1,
.article-detail-content h2,
.article-detail-content h3,
.article-detail-content h4,
.article-detail-content h5 {
    margin: 1.25rem 0 0.65rem !important;
}

.article-detail-content h1 + p,
.article-detail-content h2 + p,
.article-detail-content h3 + p,
.article-detail-content h4 + p,
.article-detail-content h5 + p {
    margin-top: 0.35rem !important;
}

.article-detail-content ul,
.article-detail-content ol {
    margin: 1.5rem 0;
    padding-left: 2rem;
    line-height: 1.8;
}

.article-detail-content ul li,
.article-detail-content ol li {
    margin-bottom: 0.75rem;
    color: #374151;
    word-break: break-word; /* ✅ FIX */
}

.article-detail-content blockquote {
    border-left: 4px solid #3b82f6;
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
    color: #4b5563;
    font-style: italic;
    background: #f8fafc;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    word-break: break-word; /* ✅ FIX */
}

.article-detail-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: 2rem 0;
    display: block; /* ✅ FIX: block agar tidak ada whitespace overflow */
}

.article-detail-content figure {
    margin: 2rem 0;
    text-align: center;
    max-width: 100%; /* ✅ FIX */
    overflow: hidden; /* ✅ FIX */
}

/* ===================================
   PRODUCT CARD — RESPONSIVE
   =================================== */
.article-product-card {
    display: flex !important;
    flex-direction: row !important;
    gap: 1.25rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    margin: 2rem 0;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
    /* ✅ FIX: card tidak lebih lebar dari kolom */
    max-width: 100%;
    box-sizing: border-box;
    width: 100%;
}

.article-product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    border-radius: 12px 12px 0 0;
}

.article-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

.article-product-card img {
    width: 140px !important;
    height: 140px !important;
    min-width: 140px;
    min-height: 140px;
    max-width: 140px;
    max-height: 140px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    margin: 0 !important;
}

.article-product-card:hover img {
    border-color: #3b82f6;
    transform: scale(1.03);
}

.article-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0; /* ✅ FIX: critical untuk flex child overflow */
}

.product-info-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0; /* ✅ FIX */
}

.product-info-right {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: flex-start;
    min-width: 0; /* ✅ FIX */
}

.article-product-card h4 {
    font-weight: 700;
    margin: 0;
    color: #1f2937;
    font-size: 1.125rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word; /* ✅ FIX */
}

/* Price Display */
.product-price-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.product-price-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap; /* ✅ FIX: harga wrap di layar sempit */
}

.product-original-price {
    font-size: 0.9375rem;
    color: #9ca3af;
    text-decoration: line-through;
    font-weight: 500;
}

.product-discount-badge {
    padding: 0.25rem 0.625rem;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #dc2626;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 700;
    border: 1px solid #fecaca;
    white-space: nowrap;
}

.product-final-price {
    font-size: 1.375rem;
    font-weight: 800;
    color: #2563eb;
    line-height: 1;
}

.product-stock-sold {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.45rem;
    border-radius: 10px;
    border-top: 1px solid #e5e7eb;
    font-size: 0.875rem;
    color: #6b7280;
    background: #f9fafb;
    flex-wrap: wrap; /* ✅ FIX */
}

.product-stock-sold span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-weight: 600;
}

.product-stock-sold i { font-size: 0.875rem; color: #3b82f6; }
.product-stock-sold span:first-child i { color: #10b981; }

.product-view-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.25);
    margin-top: auto;
    align-self: flex-start;
    white-space: nowrap; /* ✅ tombol tidak wrap */
}

.product-view-button:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateX(4px);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.35);
    color: #ffffff;
}

/* ===================================
   INTERNAL LINK CARD
   =================================== */
.article-internal-link {
    display: block;
    padding: 1.25rem;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 2px solid #bfdbfe;
    border-radius: 10px;
    text-decoration: none;
    margin: 2rem 0;
    transition: all 0.3s ease;
    max-width: 100%;    /* ✅ FIX */
    box-sizing: border-box; /* ✅ FIX */
    overflow: hidden;   /* ✅ FIX */
    word-break: break-word; /* ✅ FIX */
}

.article-internal-link:hover {
    transform: translateX(4px);
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #3b82f6;
}

/* ===================================
   VIDEO WRAPPER
   =================================== */
.article-video-wrapper {
    position: relative;
    margin: 2rem 0;
    max-width: 100%; /* ✅ FIX */
    box-sizing: border-box;
}

.article-video-wrapper > div {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.article-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ===================================
   EXTERNAL LINKS — ART-LINK
   ✅ FIX v3: Hapus display:inline-block dari .article-detail-content
      a[target="_blank"] yang konflik dengan .art-link (display:inline-flex)
      dari controller. Sekarang .art-link dari controller yang berlaku.
      Tambahkan max-width:100%, word-break, overflow-wrap agar URL
      panjang tidak memaksa horizontal scroll.
   =================================== */

/*
 * SEBELUM (menyebabkan bug):
 * .article-detail-content a[target="_blank"] { display: inline-block; }
 * → inline-block tanpa max-width akan overflow jika URL/teks panjang.
 *
 * FIX: Ubah ke inline-flex + beri constraint width.
 */
.article-detail-content a[target="_blank"] {
    display: inline-flex;       /* konsisten dengan .art-link dari controller */
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-left: 4px solid #2563eb;
    border-radius: 6px;
    font-weight: 700;
    color: #2563eb !important;
    text-decoration: none;
    margin: 0.5rem 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* ✅ FIX v3: tiga baris ini mencegah overflow */
    max-width: 100%;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;        /* pastikan teks panjang bisa wrap */
}

.article-detail-content a[target="_blank"]:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    transform: translateX(4px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Internal links (no target="_blank") */
.article-detail-content a:not([target="_blank"]) {
    color: #2563eb;
    text-decoration: underline;
    transition: color 0.2s;
    word-break: break-word;     /* ✅ FIX */
    overflow-wrap: break-word;  /* ✅ FIX */
}

.article-detail-content a:not([target="_blank"]):hover {
    color: #1d4ed8;
}

/*
 * ✅ FIX v3: Override .art-link dan .art-link-wa yang diinjeksi
 *    controller agar juga punya max-width dan word-break.
 *    Selector dengan specificity lebih tinggi agar override CSS inline.
 */
.article-detail-content .art-link,
.article-detail-content .art-link-wa {
    max-width: 100%;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Strong/Bold */
.article-detail-content strong { font-weight: 700; color: #1f2937; }

/* Emphasis/Italic */
.article-detail-content em { font-style: italic; }

/* Underline */
.article-detail-content u { text-decoration: underline; }

/* ===================================
   SIDEBAR WIDGET STYLING
   =================================== */
.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;
}

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

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 768px) {
    .article-detail-header { padding: 1.25rem 1rem; }
    .article-detail-title  { font-size: 1.5rem; }

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

    .article-meta-item  { font-size: 0.8125rem; }
    .article-detail-image { max-height: 400px; }

    /* Product card: stack vertikal di mobile */
    .article-product-card {
        flex-direction: column;
        gap: 1rem;
        min-height: auto;
    }

    /* ✅ FIX: hapus fixed width agar gambar tidak overflow */
    .article-product-card img {
        width: 100% !important;
        max-width: 100% !important;
        min-width: unset !important;
        height: 200px !important;
        max-height: 200px !important;
        min-height: unset !important;
        border-radius: 8px;
    }

    .article-product-info {
        grid-template-columns: 1fr;
    }

    .article-product-card h4 { font-size: 1.125rem; }
    .product-final-price      { font-size: 1.25rem; }

    /* External link di mobile — pastikan tidak overflow */
    .article-detail-content a[target="_blank"] {
        font-size: 0.9rem;
        padding: 0.625rem 1rem;
        max-width: 100%;
    }

    .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; }
}

@media (max-width: 576px) {
    /* Product card image lebih kecil di mobile kecil */
    .article-product-card img {
        height: 160px !important;
        max-height: 160px !important;
    }

    .article-product-card h4 { font-size: 1rem; }

    .product-final-price { font-size: 1.125rem; }

    .product-view-button {
        font-size: 0.8125rem;
        padding: 0.5rem 1rem;
    }

    /* External link lebih compact */
    .article-detail-content a[target="_blank"] {
        font-size: 0.875rem;
        padding: 0.5rem 0.875rem;
    }
}
