/* 文章詳情頁專屬樣式 - 使用統一的 header/footer */

/* 覆寫全局 .main .container 的 grid，避免麵包屑與正文區被擠成兩欄導致側欄錯位 */
.main .container {
    display: block !important;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    grid-template-columns: none !important;
}

/* 確保容器寬度一致 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Main 區域：頂部留白，避免與 sticky 導航重疊造成視覺錯亂 */
.main {
    padding: 2rem 0;
    background: #f5f7fa;
}

/* 文章詳情頁 main 增加 scroll-margin，滾動時標題不會緊貼頂欄 */
.article-layout {
    scroll-margin-top: 5rem;
}

/* 面包屑優化 */
.breadcrumb {
    background: white;
    padding: 1.2rem 1.5rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    font-size: 0.95rem;
    align-items: center;
}

.breadcrumb li:not(:last-child)::after {
    content: '›';
    margin-left: 0.5rem;
    color: #999;
    font-size: 1.1rem;
}

.breadcrumb a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.breadcrumb li:last-child {
    color: #666;
    font-weight: 500;
}

/* 文章布局 - 主內容 + 側邊欄 */
.article-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 320px !important;
    gap: 2.5rem;
    max-width: 1200px;
    margin: 0 auto;
    align-items: start !important;
    min-width: 0 !important;
    width: 100% !important;
    float: none !important;
}

/* 確保主內容在左側、側邊欄在右側 */
.article-detail {
    grid-column: 1 !important;
    min-width: 0 !important;
}

.article-sidebar {
    grid-column: 2 !important;
    min-width: 0 !important;
}

/* 文章詳情卡片：留出 scroll-margin 避免被 sticky 頂欄遮住 */
.article-detail {
    background: white;
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    position: relative;
    z-index: 0;
    scroll-margin-top: 5rem;
}

/* 文章頭部：獨立內容區塊，避免與頂部 sticky 導航重疊或樣式混淆 */
.article-header {
    position: relative;
    z-index: 0;
    margin-bottom: 2.5rem;
    padding: 2rem;
    border-bottom: 2px solid #eee;
    background: #fafbfc;
    border-radius: 12px;
    isolation: isolate;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    color: #555;
    align-items: center;
}

.article-meta .category {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.85rem;
}

.article-meta .category a {
    color: white;
    text-decoration: none;
}

.article-meta .date,
.article-meta .updated,
.article-meta .views {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* 文章標題 */
.article-title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    color: #1a1a1a;
    margin: 0 0 1rem 0;
    line-height: 1.35;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* 文章摘要 */
.article-excerpt {
    font-size: 1.15rem;
    color: #555;
    line-height: 1.8;
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    border-radius: 8px;
}

/* 作者信息 */
.article-author {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    color: #666;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.author-label {
    font-weight: 500;
}

.author-name {
    color: #667eea;
}

/* 封面圖片 */
.article-cover {
    margin: 2.5rem 0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.article-cover img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s;
}

.article-cover:hover img {
    transform: scale(1.02);
}

/* 文章內容 - 最重要的部分 */
.article-body {
    font-size: 1.1rem;
    line-height: 2;
    color: #333;
    margin: 2.5rem 0;
    letter-spacing: 0.01em;
}

.article-body h2 {
    font-size: 1.8rem;
    color: #1a1a1a;
    margin: 3rem 0 1.5rem;
    padding-top: 2rem;
    border-top: 2px solid #f0f0f0;
    font-weight: 700;
    line-height: 1.4;
}

.article-body h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.article-body h3 {
    font-size: 1.4rem;
    color: #1a1a1a;
    margin: 2rem 0 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.article-body p {
    margin-bottom: 1.5rem;
    text-align: justify;
}

.article-body ul,
.article-body ol {
    margin: 1.5rem 0 2rem 2rem;
    line-height: 2;
}

.article-body li {
    margin-bottom: 0.8rem;
    padding-left: 0.5rem;
}

.article-body ul li {
    list-style-type: disc;
}

.article-body ol li {
    list-style-type: decimal;
}

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

.article-body blockquote {
    border-left: 4px solid #667eea;
    padding: 1.5rem 2rem;
    margin: 2rem 0;
    background: #f8f9fa;
    color: #555;
    font-style: italic;
    border-radius: 8px;
    font-size: 1.05rem;
}

.article-body a {
    color: #667eea;
    text-decoration: underline;
    text-decoration-color: rgba(102, 126, 234, 0.3);
    text-underline-offset: 3px;
    transition: all 0.2s;
}

.article-body a:hover {
    color: #764ba2;
    text-decoration-color: #764ba2;
}

.article-body code {
    background: #f5f5f5;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95em;
    color: #e83e8c;
}

.article-body pre {
    background: #f5f5f5;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.article-body pre code {
    background: none;
    padding: 0;
    color: #333;
}

/* 標籤區域 */
.article-tags {
    margin: 2.5rem 0;
    padding: 1.5rem 0;
    border-top: 1px solid #e8e8e8;
    border-bottom: 1px solid #e8e8e8;
}

.tag-label {
    font-weight: 500;
    color: #666;
    margin-right: 0.5rem;
}

.article-tags .tag {
    display: inline-block;
    background: #e8f4fd;
    color: #667eea;
    padding: 0.5rem 1.2rem;
    border-radius: 25px;
    margin: 0.3rem;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.article-tags .tag:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

/* 分享按鈕 */
.article-share {
    margin: 2.5rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 16px;
}

.article-share h3 {
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    color: #333;
}

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

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 10px;
    text-decoration: none;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.share-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.share-btn.facebook {
    background: #1877f2;
}

.share-btn.twitter {
    background: #000;
}

.share-btn.line {
    background: #00b900;
}

.share-btn.copy {
    background: #6c757d;
}

/* 文章導航 */
.article-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 2.5rem 0;
}

.nav-link {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.nav-link:hover {
    background: white;
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.15);
}

.nav-link.prev {
    text-align: left;
}

.nav-link.next {
    text-align: right;
}

.nav-label {
    font-size: 0.9rem;
    color: #999;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.nav-link:hover .nav-label {
    color: #667eea;
}

.nav-title {
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1.4;
}

/* 側邊欄：固定寬度、防止被擠壓與文字豎排錯位 */
.article-sidebar {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 320px !important;
    flex-shrink: 0 !important;
    float: none !important;
    position: relative !important;
}

/* 重置：避免全局 .sidebar 樣式影響 */
.article-sidebar::before,
.article-sidebar::after {
    content: none;
}

.sidebar-widget {
    background: white;
    padding: 1.8rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    min-width: 0;
    overflow: hidden;
}

.sidebar-widget h3 {
    font-size: 1.15rem;
    margin-bottom: 1.2rem;
    color: #1a1a1a;
    font-weight: 600;
}

/* 目錄 */
.toc-list {
    list-style: none;
}

.toc-item {
    margin-bottom: 0.6rem;
}

.toc-item a {
    color: #555;
    text-decoration: none;
    display: block;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.95rem;
    line-height: 1.5;
}

.toc-item a:hover {
    color: #667eea;
    background: #f8f9fa;
    padding-left: 1.2rem;
}

.toc-h3 {
    padding-left: 1.5rem;
    font-size: 0.9rem;
}

.toc-h3 a {
    color: #777;
}

.no-toc {
    color: #999;
    font-size: 0.9rem;
    font-style: italic;
}

/* 相關文章和熱門文章 */
.related-articles,
.popular-articles {
    list-style: none;
}

.related-articles li,
.popular-articles li {
    margin-bottom: 1.2rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid #f0f0f0;
}

.related-articles li:last-child,
.popular-articles li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.related-articles a,
.popular-articles a {
    color: #333;
    text-decoration: none;
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    line-height: 1.5;
    transition: color 0.2s;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

.related-articles a:hover,
.popular-articles a:hover {
    color: #667eea;
}

.views-count {
    font-size: 0.85rem;
    color: #999;
}

.no-related {
    color: #999;
    font-size: 0.9rem;
    font-style: italic;
}

/* 工具列表样式 */
.tools-widget .tools-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tools-widget .tools-list li {
    margin-bottom: 0.8rem;
}

.tools-widget .tools-list li:last-child {
    margin-bottom: 0;
}

.tools-widget .tools-list a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    background: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.tools-widget .tools-list a:hover {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    transform: translateX(3px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.tools-widget .tool-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.tools-widget .tool-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.view-all-tools {
    display: block;
    text-align: center;
    margin-top: 1rem;
    padding: 0.6rem;
    background: #f8f9fa;
    color: #667eea;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s;
}

.view-all-tools:hover {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

/* 工具對比按鈕 */
.compare-tools-btn {
    display: block;
    text-align: center;
    margin-top: 0.8rem;
    padding: 0.6rem;
    background: linear-gradient(135deg, #4a6cf7, #6c5ce7);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s;
}

.compare-tools-btn:hover {
    background: linear-gradient(135deg, #6c5ce7, #4a6cf7);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74,108,247,0.3);
}

/* FAQ 區域 */
.article-faq {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    margin: 3rem 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.article-faq h2 {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: #1a1a1a;
    font-weight: 700;
}

.faq-grid {
    display: grid;
    gap: 1.5rem;
}

.faq-item {
    padding: 1.8rem;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid #667eea;
    transition: all 0.3s;
}

.faq-item:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateX(5px);
}

.faq-item h3 {
    font-size: 1.15rem;
    color: #1a1a1a;
    margin-bottom: 1rem;
    font-weight: 600;
}

.faq-item p {
    color: #555;
    line-height: 1.8;
    margin: 0;
}

.faq-item a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.faq-item a:hover {
    text-decoration: underline;
}

/* 免責聲明 */
.article-disclaimer {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 2px solid #ffc107;
    padding: 2rem;
    border-radius: 16px;
    margin: 3rem 0;
}

.article-disclaimer h3 {
    color: #856404;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.article-disclaimer p {
    color: #856404;
    line-height: 1.8;
    margin: 0;
    font-size: 1.05rem;
}

/* 響應式設計 */
@media (max-width: 1200px) {
    .article-layout {
        grid-template-columns: 1fr 280px;
        gap: 2rem;
    }
    
    .article-detail {
        padding: 2.5rem;
    }
}

@media (max-width: 992px) {
    .article-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .article-sidebar {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
    
    .article-detail {
        padding: 2rem;
    }
    
    .article-title {
        font-size: clamp(1.5rem, 5vw, 2.2rem);
    }
    
    .article-body {
        font-size: 1.05rem;
    }
    
    .article-navigation {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .article-detail {
        padding: 1.5rem;
    }
    
    .article-body {
        font-size: 1rem;
        line-height: 1.9;
    }
    
    .article-body h2 {
        font-size: 1.5rem;
    }
    
    .article-body h3 {
        font-size: 1.25rem;
    }
    
    .share-buttons {
        flex-direction: column;
    }
    
    .share-btn {
        width: 100%;
        justify-content: center;
    }
    
    .article-sidebar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .breadcrumb {
        padding: 1rem;
    }
    
    .breadcrumb ol {
        font-size: 0.85rem;
    }
    
    .article-detail {
        padding: 1.2rem;
    }
    
    .article-meta {
        font-size: 0.85rem;
        gap: 0.8rem;
    }
    
    .article-faq,
    .article-disclaimer {
        padding: 1.5rem;
    }
}
