/* Article Page Enhanced Styles */

/* ========== Article Container ========== */
.article-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
}

.article-page-body {
    background: #f5f5f5;
    margin: 0;
    padding: 0;
}

/* ========== Enhanced Article Header ========== */
.article-header {
    padding: 30px 50px;
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    border-bottom: 2px solid #e0e0e0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px;
    position: relative;
    z-index: 10;
}

.article-header::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #667eea 100%);
    opacity: 0.6;
}

.article-header .reader-info {
    flex: 1;
}

.article-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 12px 0;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.article-header .reader-meta {
    display: flex;
    gap: 15px;
    align-items: center;
}

.article-header .reader-meta span {
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
}

.article-header .back-link {
    flex-shrink: 0;
    align-self: flex-start;
    padding: 10px 20px;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.article-header .back-link:hover {
    background: #667eea;
    color: #ffffff;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ========== Enhanced TOC ========== */
.reader-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

.toc {
    width: 300px;
    min-width: 300px;
    padding: 30px 25px;
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    border-right: 2px solid #e0e0e0;
    overflow-y: auto;
    height: 100%;
    position: relative;
}

.toc::before {
    content: '';
    position: absolute;
    top: 0;
    right: -2px;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 50%, #667eea 100%);
    opacity: 0.3;
}

.toc h3 {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
    position: relative;
}

.toc h3::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.toc-item {
    display: block;
    padding: 12px 16px;
    color: #555;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    margin-bottom: 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
}

.toc-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}

.toc-item:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
    border-left-color: #667eea;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.toc-item:hover::before {
    width: 100%;
}

.toc-item.active {
    color: #667eea;
    font-weight: 700;
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-left-color: #667eea;
    border-left-width: 4px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.toc-item.h1 {
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 12px;
    padding-left: 16px;
}

.toc-item.h2 {
    padding-left: 28px;
    font-size: 0.88rem;
}

.toc-item.h3 {
    padding-left: 40px;
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ========== Enhanced Reader Content ========== */
.reader-content {
    flex: 1;
    padding: 50px 70px;
    overflow-y: auto;
    background: #ffffff;
    scroll-behavior: smooth;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.05);
}

.reader-content h1 {
    font-size: 2.4rem;
    font-weight: 800;
    color: #1a1a1a;
    margin: 50px 0 25px 0;
    padding-bottom: 15px;
    border-bottom: 3px solid #e0e0e0;
    position: relative;
    letter-spacing: -0.5px;
}

.reader-content h1::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.reader-content h1:first-child {
    margin-top: 0;
}

/* ========== Smooth Scrollbar for TOC and Content ========== */
.toc::-webkit-scrollbar,
.reader-content::-webkit-scrollbar {
    width: 8px;
}

.toc::-webkit-scrollbar-track,
.reader-content::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.toc::-webkit-scrollbar-thumb,
.reader-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

.toc::-webkit-scrollbar-thumb:hover,
.reader-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #5568d3 0%, #64398a 100%);
}

/* ========== Loading Animation ========== */
.loading {
    text-align: center;
    color: #999;
    padding: 80px 20px;
    font-size: 1.1rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* ========== Dark Mode Support ========== */
body.dark-mode .article-container {
    background: linear-gradient(135deg, #1a1a1a 0%, #222222 100%);
}

body.dark-mode .article-header {
    background: linear-gradient(135deg, #222222 0%, #1a1a1a 100%);
    border-bottom-color: #333;
}

body.dark-mode .article-header h1 {
    background: linear-gradient(135deg, #8b9ef8 0%, #9b6bc4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.dark-mode .article-header .back-link {
    background: #2a2a2a;
    border-color: #444;
    color: #8b9ef8;
}

body.dark-mode .article-header .back-link:hover {
    background: #667eea;
    color: #ffffff;
    border-color: #667eea;
}

body.dark-mode .toc {
    background: linear-gradient(135deg, #222222 0%, #1a1a1a 100%);
    border-right-color: #333;
}

body.dark-mode .toc h3 {
    background: linear-gradient(135deg, #8b9ef8 0%, #9b6bc4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.dark-mode .toc-item {
    color: #999;
    background: rgba(255, 255, 255, 0.02);
}

body.dark-mode .toc-item:hover {
    color: #8b9ef8;
    background: rgba(139, 158, 248, 0.1);
    border-left-color: #8b9ef8;
}

body.dark-mode .toc-item.active {
    color: #8b9ef8;
    background: linear-gradient(90deg, rgba(139, 158, 248, 0.15) 0%, rgba(155, 107, 196, 0.08) 100%);
    border-left-color: #8b9ef8;
}

body.dark-mode .reader-content {
    background: #1a1a1a;
}

body.dark-mode .reader-content h1 {}

.toc-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}

.toc-item:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
    border-left-color: #667eea;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.toc-item:hover::before {
    width: 100%;
}

.toc-item.active {
    color: #667eea;
    font-weight: 700;
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-left-color: #667eea;
    border-left-width: 4px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.toc-item.h1 {
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 12px;
    padding-left: 16px;
}

.toc-item.h2 {
    padding-left: 28px;
    font-size: 0.88rem;
}

.toc-item.h3 {
    padding-left: 40px;
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ========== Enhanced Reader Content ========== */
.reader-content {
    flex: 1;
    padding: 50px 70px;
    overflow-y: auto;
    background: #ffffff;
    scroll-behavior: smooth;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.05);
}

.reader-content h1 {
    font-size: 2.4rem;
    font-weight: 800;
    color: #1a1a1a;
    margin: 50px 0 25px 0;
    padding-bottom: 15px;
    border-bottom: 3px solid #e0e0e0;
    position: relative;
    letter-spacing: -0.5px;
}

.reader-content h1::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.reader-content h1:first-child {
    margin-top: 0;
}

/* ========== Smooth Scrollbar for TOC and Content ========== */
.toc::-webkit-scrollbar,
.reader-content::-webkit-scrollbar {
    width: 8px;
}

.toc::-webkit-scrollbar-track,
.reader-content::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.toc::-webkit-scrollbar-thumb,
.reader-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

.toc::-webkit-scrollbar-thumb:hover,
.reader-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #5568d3 0%, #64398a 100%);
}

/* ========== Loading Animation ========== */
.loading {
    text-align: center;
    color: #999;
    padding: 80px 20px;
    font-size: 1.1rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* ========== Dark Mode Support ========== */
body.dark-mode .article-container {
    background: linear-gradient(135deg, #1a1a1a 0%, #222222 100%);
}

body.dark-mode .article-header {
    background: linear-gradient(135deg, #222222 0%, #1a1a1a 100%);
    border-bottom-color: #333;
}

body.dark-mode .article-header h1 {
    background: linear-gradient(135deg, #8b9ef8 0%, #9b6bc4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.dark-mode .article-header .back-link {
    background: #2a2a2a;
    border-color: #444;
    color: #8b9ef8;
}

body.dark-mode .article-header .back-link:hover {
    background: #667eea;
    color: #ffffff;
    border-color: #667eea;
}

body.dark-mode .toc {
    background: linear-gradient(135deg, #222222 0%, #1a1a1a 100%);
    border-right-color: #333;
}

body.dark-mode .toc h3 {
    background: linear-gradient(135deg, #8b9ef8 0%, #9b6bc4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.dark-mode .toc-item {
    color: #999;
    background: rgba(255, 255, 255, 0.02);
}

body.dark-mode .toc-item:hover {
    color: #8b9ef8;
    background: rgba(139, 158, 248, 0.1);
    border-left-color: #8b9ef8;
}

body.dark-mode .toc-item.active {
    color: #8b9ef8;
    background: linear-gradient(90deg, rgba(139, 158, 248, 0.15) 0%, rgba(155, 107, 196, 0.08) 100%);
    border-left-color: #8b9ef8;
}

body.dark-mode .reader-content {
    background: #1a1a1a;
}

body.dark-mode .reader-content h1 {
    color: #e0e0e0;
    border-bottom-color: #333;
}

/* ========== Mobile TOC Toggle ========== */
.mobile-toc-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.mobile-toc-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

body.dark-mode .mobile-toc-toggle {
    background: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .article-container {
        height: auto;
        min-height: 100vh;
    }

    .article-header {
        flex-direction: column;
        padding: 20px 20px;
        gap: 15px;
    }

    .article-header h1 {
        font-size: 1.8rem;
    }

    .article-header .back-link {
        width: 100%;
        text-align: center;
        order: -1;
        /* Move back link to top for better navigation on mobile */
        margin-bottom: 5px;
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    .reader-body {
        flex-direction: column;
        height: auto;
        overflow: visible;
        position: relative;
    }

    .toc {
        display: block;
        /* Enable for mobile but hide via transform */
        position: fixed;
        top: 0;
        right: 0;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        z-index: 1001;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -2px 0 12px rgba(0, 0, 0, 0.1);
        border-right: none;
        border-left: 1px solid #e0e0e0;
    }

    .toc.active {
        transform: translateX(0);
    }

    .toc::before {
        display: none;
    }

    .mobile-toc-toggle {
        display: flex;
    }

    .reader-content {
        padding: 20px 20px 80px 20px;
        /* Add bottom padding for FAB */
        overflow-y: visible;
        height: auto;
    }

    /* Overlay for TOC */
    .toc-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .toc-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}