/* Base Article Typography */
.article-content {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.175rem;
    line-height: 1.85;
    color: #1a1a1a;
    letter-spacing: -0.011em;
    word-spacing: 0.1em;
    font-feature-settings: "liga" 1, "kern" 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.dark .article-content {
    color: #e5e7eb;
}

/* Smooth Content Flow */
.article-content > * + * {
    margin-top: 1.85em;
}

/* Headings with Improved Visual Hierarchy */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    line-height: 1.3;
    color: #111827;
    letter-spacing: -0.02em;
    margin-top: 2.5em;
    margin-bottom: 0.8em;
}

.dark .article-content h1,
.dark .article-content h2,
.dark .article-content h3,
.dark .article-content h4 {
    color: #f3f4f6;
}

.article-content h1 {
    font-size: 2.5rem;
    line-height: 1.2;
}

.article-content h2 {
    font-size: 2rem;
}

.article-content h3 {
    font-size: 1.5rem;
}

.article-content h4 {
    font-size: 1.25rem;
}

/* Paragraphs with Improved Readability */
.article-content p {
    margin-bottom: 1.85em;
    max-width: 70ch; /* Optimal line length for readability */
}

.article-content p:last-child {
    margin-bottom: 0;
}

/* Enhanced Lists */
.article-content ul,
.article-content ol {
    margin: 1.5em 0;
    padding-left: 1.8em;
}

.article-content ul {
    list-style: none;
}

.article-content ul li {
    position: relative;
}

.article-content ul li::before {
    content: "•";
    color: #3b82f6;
    font-weight: bold;
    position: absolute;
    left: -1.2em;
}

.article-content ol {
    list-style-type: decimal;
    counter-reset: item;
}

.article-content li {
    margin-bottom: 0.75em;
    padding-left: 0.5em;
}

/* Refined Links */
.article-content a {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 2px solid rgba(37, 99, 235, 0.2);
    transition: all 0.2s ease;
}

.article-content a:hover {
    color: #1d4ed8;
    border-bottom-color: #2563eb;
}

.dark .article-content a {
    color: #60a5fa;
    border-bottom-color: rgba(96, 165, 250, 0.2);
}

.dark .article-content a:hover {
    color: #93c5fd;
    border-bottom-color: #60a5fa;
}

/* Elegant Blockquotes */
.article-content blockquote {
    border-left: 4px solid #3b82f6;
    padding: 1.5em 2em;
    margin: 2em 0;
    background-color: rgba(59, 130, 246, 0.05);
    border-radius: 0.5rem;
    font-style: italic;
    position: relative;
}

.article-content blockquote::before {
    content: '"';
    position: absolute;
    top: 0;
    left: 1rem;
    font-size: 3em;
    color: rgba(59, 130, 246, 0.2);
    font-family: Georgia, serif;
    line-height: 1;
}

.dark .article-content blockquote {
    background-color: rgba(96, 165, 250, 0.05);
    border-left-color: #60a5fa;
}

/* Enhanced Images */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 1rem;
    margin: 2em 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease;
}

.article-content img:hover {
    transform: scale(1.01);
}

/* Refined Code Blocks */
.article-content pre {
    background-color: #1f2937;
    padding: 1.5em;
    border-radius: 0.75rem;
    overflow-x: auto;
    margin: 2em 0;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

.article-content code {
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.9em;
    padding: 0.2em 0.4em;
    background-color: rgba(243, 244, 246, 0.8);
    border-radius: 0.25rem;
    border: 1px solid rgba(229, 231, 235, 0.5);
}

.dark .article-content code {
    background-color: rgba(55, 65, 81, 0.8);
    border-color: rgba(75, 85, 99, 0.5);
}

/* Elegant Tables */
.article-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 2em 0;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.article-content th,
.article-content td {
    padding: 1em 1.5em;
    border: 1px solid #e5e7eb;
}

.article-content th {
    background-color: #f8fafc;
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
    font-size: 0.875em;
    letter-spacing: 0.05em;
}

.article-content tr:nth-child(even) {
    background-color: #f9fafb;
}

.dark .article-content table {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.dark .article-content th {
    background-color: #374151;
    border-color: #4b5563;
}

.dark .article-content td {
    border-color: #4b5563;
}

.dark .article-content tr:nth-child(even) {
    background-color: #1f2937;
}

/* Horizontal Rule */
.article-content hr {
    margin: 1.5em 0;  /* Dikurangi dari 2em menjadi 1.5em */
    border: 0;
    height: 1px;
    background: linear-gradient(
        to right,
        transparent,
        #e5e7eb 20%,    /* Mulai solid color lebih awal */
        #e5e7eb 80%,    /* Pertahankan solid color lebih lama */
        transparent
    );
    opacity: 0.8;      /* Sedikit transparansi agar tidak terlalu mencolok */
}

.dark .article-content hr {
    background: linear-gradient(
        to right,
        transparent,
        #4b5563 20%,
        #4b5563 80%,
        transparent
    );
}

/* Responsive Design */
@media (max-width: 768px) {
    .article-content {
        font-size: 1.05rem;
        line-height: 1.75;
    }

    .article-content h1 { font-size: 2rem; }
    .article-content h2 { font-size: 1.75rem; }
    .article-content h3 { font-size: 1.35rem; }
    .article-content h4 { font-size: 1.15rem; }

    .article-content blockquote {
        padding: 1.25em 1.5em;
        margin: 1.5em 0;
    }

    .article-content pre {
        padding: 1.25em;
        margin: 1.5em 0;
    }

    .article-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Print Styles */
@media print {
    .article-content {
        font-size: 12pt;
        line-height: 1.6;
        color: #000;
    }

    .article-content a {
        text-decoration: underline;
        color: #000;
    }

    .article-content img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }

    .article-content pre,
    .article-content blockquote {
        page-break-inside: avoid;
        border: 1px solid #ddd;
    }
}

/* Baca Juga Section */
.article-content .my-4 {
    animation: fadeIn 0.3s ease-out forwards;
    max-width: 70ch; /* Match dengan max-width paragraf */
}

.article-content .my-4 a {
    border-bottom: none; /* Remove default link underline */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: #4b5563; /* gray-600 */
    transition: all 0.2s ease;
}

.article-content .my-4 a:hover {
    color: #2563eb; /* blue-600 */
    transform: translateX(4px);
}

.dark .article-content .my-4 a {
    color: #9ca3af; /* dark:gray-400 */
}

.dark .article-content .my-4 a:hover {
    color: #60a5fa; /* dark:blue-400 */
}

.article-content .my-4 .p-3 {
    background-color: rgba(243, 244, 246, 0.5); /* Subtle gray background */
    border: 1px solid rgba(229, 231, 235, 0.5);
    border-radius: 0.75rem;
    transition: all 0.2s ease;
}

.dark .article-content .my-4 .p-3 {
    background-color: rgba(31, 41, 55, 0.5); /* dark:gray-800 with opacity */
    border-color: rgba(75, 85, 99, 0.5);
}

.article-content .my-4 .p-3:hover {
    background-color: rgba(243, 244, 246, 0.8);
    border-color: rgba(229, 231, 235, 0.8);
}

.dark .article-content .my-4 .p-3:hover {
    background-color: rgba(31, 41, 55, 0.8);
    border-color: rgba(75, 85, 99, 0.8);
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(5px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0);
    }
}

/* Reduce Motion */
@media (prefers-reduced-motion: reduce) {
    .article-content .my-4 {
        animation: none;
    }
    
    .article-content .my-4 a:hover {
        transform: none;
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .article-content .my-4 {
        margin: 1.5rem 0;
    }
    
    .article-content .my-4 a {
        font-size: 0.875rem;
    }
    
    .article-content .my-4 .p-3 {
        padding: 0.75rem;
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .article-content hr {
        margin: 1.2em 0;  /* Dikurangi dari 1.5em menjadi 1.2em untuk mobile */
    }
}

/* Sticky Sidebar */
.sidebar {
    position: sticky;
    top: 2rem; /* Jarak dari atas saat sticky */
    height: max-content;
    max-height: calc(100vh - 4rem); /* Tinggi maksimum viewport dikurangi margin atas dan bawah */
    overflow-y: auto; /* Scroll jika konten terlalu panjang */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #cbd5e1 transparent; /* Firefox */
}

/* Webkit Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
}

/* Dark mode adjustments */
.dark .sidebar::-webkit-scrollbar-thumb {
    background-color: #4b5563;
}

.dark .sidebar {
    scrollbar-color: #4b5563 transparent;
}

/* Disable sticky on mobile */
@media (max-width: 768px) {
    .sidebar {
        position: relative;
        top: 0;
        max-height: none;
        overflow-y: visible;
    }
}
