/* ===== Article Container Layout ===== */
.article-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3rem;
    margin-top: 2rem;
    align-items: start;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    padding: 1.5rem 0;
    color: #666;
    font-size: 0.9rem;
}

.breadcrumb a {
    color: #667eea;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.breadcrumb a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: #667eea;
    transition: width 0.3s ease;
}

.breadcrumb a:hover::after {
    width: 100%;
}

/* ===== Table of Contents (Left Sidebar) ===== */
.toc-sidebar {
    position: sticky;
    top: 100px;
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.toc-wrapper {
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e8e8e8;
    overflow: hidden;
}

.toc-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-header svg {
    width: 18px;
    height: 18px;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    border-bottom: 1px solid #f0f0f0;
}

.toc-item:last-child {
    border-bottom: none;
}

.toc-link {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    text-decoration: none;
    color: #444;
    font-size: 0.9rem;
    line-height: 1.5;
    transition: all 0.25s ease;
    position: relative;
    border-left: 3px solid transparent;
}

.toc-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: all 0.25s ease;
}

.toc-number {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: #f5f5f5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
    transition: all 0.25s ease;
}

.toc-text {
    flex: 1;
}

/* Hover State */
.toc-link:hover {
    background: #f8f9ff;
    color: #667eea;
}

.toc-link:hover .toc-number {
    background: #667eea;
    color: #fff;
}

/* Active State */
.toc-link.active {
    background: linear-gradient(90deg, #f0f4ff 0%, #fff 100%);
    color: #667eea;
    font-weight: 600;
    border-left-color: #667eea;
}

.toc-link.active::before {
    background: #667eea;
}

.toc-link.active .toc-number {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* ===== Main Article ===== */
.article-main {
    max-width: 100%;
    min-width: 0;
}

.article-header {
    margin-bottom: 2.5rem;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.article-header h1 {
    font-size: 2.5rem;
    line-height: 1.3;
    margin-bottom: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
}

.article-meta {
    display: flex;
    gap: 2rem;
    align-items: center;
    color: #666;
    font-size: 0.95rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #eee;
}

.article-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-meta span::before {
    content: '•';
    color: #667eea;
    font-weight: bold;
    font-size: 1.2rem;
}

.article-meta a {
    color: #667eea;
    text-decoration: none;
}

.article-meta a:hover {
    text-decoration: underline;
}

/* ===== Content Sections ===== */
.content-section {
    scroll-margin-top: 100px;
    padding-top: 0.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2.5rem 0 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e8e8e8;
}

.section-number {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.section-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.3;
}

.content-section:first-child .section-header {
    margin-top: 1.5rem;
}

/* ===== Article Content ===== */
.article-content {
    font-size: 1.1rem;
    line-height: 1.9;
    color: #333;
}

.article-content h2 {
    font-size: 1.75rem;
    margin: 2.5rem 0 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
    position: relative;
    padding-left: 1.25rem;
}

.article-content h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: linear-gradient(to bottom, #667eea, #764ba2);
    border-radius: 10px;
}

.article-content h3 {
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    font-weight: 600;
    color: #2a2a2a;
}

.article-content p {
    margin-bottom: 1.5rem;
}

.article-content ul,
.article-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.article-content li {
    margin-bottom: 0.6rem;
}

.article-content li::marker {
    color: #667eea;
    font-weight: bold;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 2rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.article-content blockquote {
    border-left: 4px solid #667eea;
    padding: 1.5rem 2rem;
    margin: 2rem 0;
    font-style: italic;
    color: #555;
    background: linear-gradient(to right, #f8f9ff, transparent);
    border-radius: 0 8px 8px 0;
    position: relative;
}

.article-content blockquote::before {
    content: '"';
    position: absolute;
    top: 10px;
    left: 15px;
    font-size: 3rem;
    color: #667eea;
    opacity: 0.3;
    font-family: Georgia, serif;
}

/* ===== Enhanced Table Styles ===== */
.article-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 2.5rem 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.article-content thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
}

.article-content thead::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
    rgba(255,255,255,0.3) 0%,
    rgba(255,255,255,0.8) 50%,
    rgba(255,255,255,0.3) 100%);
}

.article-content th {
    background: transparent;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1.25rem 1rem;
    text-align: center;
    border: none;
    position: relative;
}

.article-content th:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 1px;
    background: rgba(255,255,255,0.3);
}

.article-content tbody tr {
    transition: all 0.3s ease;
    border-bottom: 1px solid #f0f0f0;
}

.article-content tbody tr:last-child {
    border-bottom: none;
}

.article-content td {
    padding: 1rem;
    text-align: center;
    border: none;
    border-right: 1px solid #f0f0f0;
    color: #333;
    font-size: 0.95rem;
    line-height: 1.6;
}

.article-content td:last-child {
    border-right: none;
}

.article-content td:first-child {
    font-weight: 600;
    color: #667eea;
    background: #f8f9ff;
}

.article-content tbody tr:nth-child(even) {
    background: #fafbff;
}

.article-content tbody tr:hover {
    background: linear-gradient(90deg, #f0f4ff 0%, #fff 100%);
    transform: translateX(4px);
    box-shadow: -4px 0 0 0 #667eea;
}

/* 表格响应式包装 */
.article-content .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 2.5rem 0;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

/* ===== FAQ Section ===== */
.faq-section {
    margin: 3rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #f9f9f9 0%, #fff 100%);
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.faq-section h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: #1a1a1a;
}

.faq-item {
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.faq-item:hover {
    transform: translateX(8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.faq-question {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #667eea;
    display: flex;
    align-items: start;
    gap: 0.75rem;
}

.faq-question::before {
    content: 'Q:';
    flex-shrink: 0;
    font-weight: bold;
}

.faq-answer {
    color: #555;
    line-height: 1.7;
    padding-left: 1.75rem;
}

/* ===== Popular Articles Sidebar ===== */
.popular-articles {
    margin-top: 2rem;
}

.popular-articles .toc-header {
    background: #333;
}

.popular-link {
    display: block;
    padding: 0.875rem 1.25rem;
    text-decoration: none;
    color: #444;
    font-size: 0.9rem;
    line-height: 1.5;
    transition: all 0.25s ease;
    border-bottom: 1px solid #f0f0f0;
}

.popular-link:last-child {
    border-bottom: none;
}

.popular-link:hover {
    background: #f8f9ff;
    color: #667eea;
    padding-left: 1.5rem;
}

/* ===== Related Posts ===== */
.related-posts {
    margin: 4rem 0;
}

.related-posts p {
    font-size: 1.75rem;
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
    padding-bottom: 1rem;
}

.related-posts p::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(to right, #667eea, #764ba2);
    border-radius: 10px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.related-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid transparent;
}

.related-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.related-card-image-wrapper {
    position: relative;
    overflow: hidden;
    height: 150px;
}

.related-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.related-card:hover img {
    transform: scale(1.1);
}

.related-card-content {
    padding: 1rem;
}

.related-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #000;
    text-decoration: none;
    display: block;
    line-height: 1.5;
    transition: color 0.3s ease;
}

.related-card-title:hover {
    color: #667eea;
}

/* ===== Responsive Styles ===== */
@media (max-width: 1024px) {
    .article-container {
        grid-template-columns: 1fr;
    }

    .toc-sidebar {
        position: relative;
        top: 0;
        max-height: none;
        order: 2;
        margin-top: 2rem;
    }

    .article-main {
        order: 1;
    }

    .related-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .article-container {
        gap: 1.5rem;
        margin-top: 1rem;
    }

    .breadcrumb {
        padding: 1rem 0;
        font-size: 0.85rem;
    }

    .article-header h1 {
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }

    .article-meta {
        flex-wrap: wrap;
        gap: 0.75rem 1.5rem;
        font-size: 0.85rem;
        padding-bottom: 1rem;
    }

    .section-header {
        margin: 2rem 0 1rem;
    }

    .section-number {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }

    .section-title {
        font-size: 1.35rem;
    }

    .article-content {
        font-size: 1rem;
        line-height: 1.8;
    }

    .article-content h2 {
        font-size: 1.4rem;
        margin: 2rem 0 1rem;
        padding-left: 1rem;
    }

    .article-content h3 {
        font-size: 1.2rem;
        margin: 1.5rem 0 0.75rem;
    }

    .faq-section {
        padding: 1.5rem;
        margin: 2rem 0;
    }

    .faq-item {
        padding: 1rem;
    }

    .faq-item:hover {
        transform: none;
    }

    /* ===== 移动端表格优化 ===== */
    .article-content table {
        font-size: 0.85rem;
        box-shadow: 0 2px 12px rgba(0,0,0,0.08);
        border-radius: 10px;
    }

    .article-content th {
        padding: 1rem 0.75rem;
        font-size: 0.825rem;
        letter-spacing: 0.3px;
    }

    .article-content td {
        padding: 0.875rem 0.75rem;
        font-size: 0.85rem;
    }

    /* 表格横向滚动提示 */
    .article-content .table-wrapper {
        position: relative;
        margin: 2rem 0;
    }

    .article-content .table-wrapper::after {
        content: '← Swipe to see more →';
        position: absolute;
        bottom: -1.5rem;
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.75rem;
        color: #999;
        white-space: nowrap;
    }

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

    /* 移动端隐藏Table of Contents按钮 */
    .toc-mobile-toggle {
        display: none !important;
    }

    /* 移动端Content目录直接显示，可收缩 */
    .toc-wrapper {
        display: block;
    }

    .toc-header {
        cursor: pointer;
        position: relative;
        padding-right: 2.5rem;
    }

    .toc-header::after {
        content: '';
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        width: 0;
        height: 0;
        border-left: 6px solid transparent;
        border-right: 6px solid transparent;
        border-top: 6px solid #fff;
        transition: transform 0.3s ease;
    }

    .toc-wrapper.collapsed .toc-header::after {
        transform: translateY(-50%) rotate(-90deg);
    }

    .toc-list {
        max-height: 1000px;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .toc-wrapper.collapsed .toc-list {
        max-height: 0;
    }

    /* 移动端热门文章保持显示，也可收缩 */
    .popular-articles {
        display: block !important;
        margin-top: 1rem;
    }

    .popular-articles .toc-header {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
        cursor: pointer;
        position: relative;
        padding-right: 2.5rem;
    }

    .popular-articles .toc-header::after {
        content: '';
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        width: 0;
        height: 0;
        border-left: 6px solid transparent;
        border-right: 6px solid transparent;
        border-top: 6px solid #fff;
        transition: transform 0.3s ease;
    }

    .popular-articles.collapsed .toc-header::after {
        transform: translateY(-50%) rotate(-90deg);
    }

    .popular-articles > div:last-child {
        max-height: 1000px;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .popular-articles.collapsed > div:last-child {
        max-height: 0;
    }

    .popular-link {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
}

@media (min-width: 769px) {
    .toc-mobile-toggle {
        display: none;
    }
}

/* ===== Scrollbar Styling ===== */
.toc-sidebar::-webkit-scrollbar {
    width: 4px;
}

.toc-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.toc-sidebar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.toc-sidebar::-webkit-scrollbar-thumb:hover {
    background: #667eea;
}
