/* Reader Mode CSS - 整合版本 with Light/Dark Theme Support */

/* CSS Custom Properties for Theme System */
:root {
    /* Dark Theme (Default) */
    --reader-bg-primary: #1a1a1a;
    --reader-bg-secondary: #2a2a2a;
    --reader-bg-tertiary: #333;
    --reader-text-primary: #ffffff;
    --reader-text-secondary: #ccc;
    --reader-text-tertiary: #999;
    --reader-text-quaternary: #666;
    --reader-border-primary: #404040;
    --reader-scrollbar-track: #2a2a2a;
    --reader-scrollbar-thumb: #666;
    --reader-scrollbar-hover: #888;
    --reader-article-hover-bg: #333;
    --reader-gradient-bg: linear-gradient(135deg, #404040, #333);
}

/* Light Theme */
[data-reader-theme="light"] {
    --reader-bg-primary: #ffffff;
    --reader-bg-secondary: #f8f9fa;
    --reader-bg-tertiary: #e9ecef;
    --reader-text-primary: #212529;
    --reader-text-secondary: #495057;
    --reader-text-tertiary: #6c757d;
    --reader-text-quaternary: #adb5bd;
    --reader-border-primary: #dee2e6;
    --reader-scrollbar-track: #f8f9fa;
    --reader-scrollbar-thumb: #adb5bd;
    --reader-scrollbar-hover: #6c757d;
    --reader-article-hover-bg: #f1f3f4;
    --reader-gradient-bg: linear-gradient(135deg, #e9ecef, #f8f9fa);
}

/* Reader Mode 容器 */
.reader-mode-container {
    display: flex;
    height: calc(100vh - 200px); /* 扣除header和tabs的高度 */
    min-height: 600px;
    background-color: var(--reader-bg-primary);
    color: var(--reader-text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    border-radius: 8px;
    margin: 10px 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 側邊欄 */
.reader-sidebar {
    width: 280px;
    background-color: var(--reader-bg-secondary);
    border-right: 1px solid var(--reader-border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

/* 側邊欄收縮狀態 */
.reader-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.reader-sidebar.collapsed .reader-sidebar-header,
.reader-sidebar.collapsed .reader-feeds-section {
    opacity: 0;
    pointer-events: none;
}

.reader-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--reader-border-primary);
    flex-shrink: 0;
    transition: border-color 0.3s ease;
}

.reader-sidebar-header h2 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--reader-text-primary);
    transition: color 0.3s ease;
}

.reader-sidebar-subtitle {
    font-size: 12px;
    color: var(--reader-text-tertiary);
    line-height: 1.4;
    transition: color 0.3s ease;
}

/* Feed列表區域 */
.reader-feeds-section {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.feed-category {
    margin-bottom: 16px;
}

.category-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--reader-text-quaternary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 0 12px;
    transition: color 0.3s ease;
}

.clickable-category {
    cursor: pointer;
    padding: 4px 12px;
    margin: -4px -12px 8px -12px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.clickable-category:hover {
    background-color: var(--reader-article-hover-bg);
    color: var(--reader-text-primary);
}

.clickable-category.active {
    background-color: #007aff;
    color: #ffffff;
}

.feed-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 2px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.feed-item:hover {
    background-color: var(--reader-article-hover-bg);
}

.feed-item.active {
    background-color: #007aff;
    color: #ffffff;
}

.feed-icon {
    width: 16px;
    height: 16px;
    background-color: var(--reader-text-quaternary);
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.feed-item.active .feed-icon {
    background-color: #ffffff;
}

/* Today 特殊樣式 */
.today-section {
    border-bottom: 1px solid #404040;
    margin-bottom: 20px;
    padding-bottom: 12px;
}

.today-item .today-icon {
    background-color: #007aff;
    position: relative;
}

.today-item.active .today-icon {
    background-color: #ffffff;
}

.today-item .feed-name {
    font-weight: 600;
}

/* Read Later 特殊樣式 */
.read-later-item .read-later-icon {
    background-color: #ffd700;
    color: #1a1a1a;
    text-align: center;
    line-height: 16px;
    font-size: 12px;
}

.read-later-item.active .read-later-icon {
    background-color: #ffffff;
    color: #1a1a1a;
}

.read-later-item .feed-name {
    font-weight: 600;
}

.feed-info {
    flex: 1;
    min-width: 0;
}

.feed-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-count {
    font-size: 11px;
    color: #999;
    background-color: #404040;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.feed-item.active .feed-count {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* 主內容區 */
.reader-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--reader-bg-primary);
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.reader-content-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--reader-border-primary);
    flex-shrink: 0;
    transition: border-color 0.3s ease;
}

.reader-content-title {
    margin: 0 0 4px 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--reader-text-primary);
    transition: color 0.3s ease;
}

.reader-content-subtitle {
    font-size: 14px;
    color: var(--reader-text-tertiary);
    transition: color 0.3s ease;
}

.reader-articles-section {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

.reader-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    font-size: 14px;
    color: var(--reader-text-tertiary);
    transition: color 0.3s ease;
}

.error {
    color: #ff6b6b;
    text-align: center;
    padding: 20px;
}

/* 文章項目 - 限制在 Reader Mode 容器內 */
.reader-mode-container .article-item {
    position: relative;
    display: flex;
    background-color: var(--reader-bg-secondary);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--reader-border-primary);
}

.reader-mode-container .article-item:hover {
    background-color: var(--reader-article-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.reader-mode-container .article-item.selected {
    border-color: #007aff;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

/* 已處理文章樣式 */
.reader-mode-container .article-item.processed {
    opacity: 0.6;
    background-color: var(--reader-bg-secondary);
    cursor: default;
}

.reader-mode-container .article-item.processed:hover {
    background-color: var(--reader-bg-secondary);
    transform: none;
    box-shadow: none;
}

/* 文章勾選框 */
.reader-mode-container .article-checkbox {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 10;
}

.reader-mode-container .article-checkbox input[type="checkbox"] {
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    opacity: 0.8;
}

.reader-mode-container .article-checkbox input[type="checkbox"]:checked {
    opacity: 1;
}

.reader-mode-container .article-checkbox input[type="checkbox"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 縮略圖容器 */
.reader-mode-container .article-thumbnail-container {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--reader-border-primary);
    transition: background-color 0.3s ease;
}

.reader-mode-container .article-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reader-mode-container .article-thumbnail-placeholder {
    width: 100%;
    height: 100%;
    background: var(--reader-gradient-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--reader-text-tertiary);
    font-size: 12px;
    text-align: center;
    transition: background 0.3s ease, color 0.3s ease;
}

/* 文章內容 */
.reader-mode-container .article-content-wrapper {
    flex: 1;
    padding: 16px 16px 16px 20px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.reader-mode-container .article-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--reader-text-primary);
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s ease;
}

.reader-mode-container .article-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.reader-mode-container .article-source-badge {
    background-color: #007aff;
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.reader-mode-container .article-time-ago {
    font-size: 11px;
    color: var(--reader-text-tertiary);
    transition: color 0.3s ease;
}

.reader-mode-container .article-processed-badge {
    background-color: #28a745;
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.reader-mode-container .article-summary {
    font-size: 13px;
    color: var(--reader-text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s ease;
}

.reader-mode-container .article-content {
    font-size: 12px;
    color: var(--reader-text-tertiary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.reader-mode-container .article-read-more {
    font-size: 12px;
    color: #007aff;
    font-weight: 500;
    margin-top: auto;
}

/* 處理選定文章按鈕 */
.reader-process-selected-articles {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #007aff;
    color: #ffffff;
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.4);
    transition: all 0.2s ease;
    z-index: 1000;
    display: none;
}

.reader-process-selected-articles:hover {
    background-color: #0056cc;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.6);
}

.reader-selected-count {
    background-color: rgba(255, 255, 255, 0.2);
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* 滾動條樣式 */
.reader-feeds-section::-webkit-scrollbar,
.reader-articles-section::-webkit-scrollbar {
    width: 6px;
}

.reader-feeds-section::-webkit-scrollbar-track,
.reader-articles-section::-webkit-scrollbar-track {
    background: var(--reader-scrollbar-track);
}

.reader-feeds-section::-webkit-scrollbar-thumb,
.reader-articles-section::-webkit-scrollbar-thumb {
    background: var(--reader-scrollbar-thumb);
    border-radius: 3px;
}

.reader-feeds-section::-webkit-scrollbar-thumb:hover,
.reader-articles-section::-webkit-scrollbar-thumb:hover {
    background: var(--reader-scrollbar-hover);
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: 1px solid var(--reader-border-primary);
    color: var(--reader-text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-top: 8px;
    width: 100px;
}

.theme-toggle:hover {
    background-color: var(--reader-article-hover-bg);
    border-color: #007aff;
}

.theme-toggle:active {
    transform: scale(0.98);
}

/* Sidebar Hide Button (在側邊欄內部) */
.sidebar-hide-container {
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px 0 16px;
}

.sidebar-hide-btn {
    background: none;
    border: 1px solid var(--reader-border-primary);
    color: var(--reader-text-tertiary);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.sidebar-hide-btn:hover {
    background-color: var(--reader-article-hover-bg);
    border-color: #007aff;
    color: var(--reader-text-primary);
    opacity: 1;
}

/* Sidebar Show Button (在閱讀內容區域內) */
.sidebar-show-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: var(--reader-bg-secondary);
    border: 1px solid var(--reader-border-primary);
    color: var(--reader-text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    display: none; /* 預設隱藏，只在側邊欄收縮時顯示 */
}

.sidebar-show-btn:hover {
    background-color: var(--reader-article-hover-bg);
    border-color: #007aff;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.sidebar-show-btn:active {
    transform: translateY(0);
}

/* 確保文章內容區域有相對定位，讓 Show 按鈕正確定位 */
.reader-articles-section {
    position: relative;
}

/* 當側邊欄收縮時，給文章內容增加頂部空間，避免與 Show 按鈕重疊 */
.reader-mode-container.sidebar-collapsed .reader-articles-section {
    padding-top: 60px;
}

/* 當側邊欄收縮時，主內容區域調整 */
.reader-mode-container.sidebar-collapsed .reader-main-content {
    margin-left: 0;
}

/* 響應式設計 - 手機版 */
@media (max-width: 768px) {
    /* 手機版 Reader Mode 容器調整 */
    .reader-mode-container {
        height: calc(100vh - 140px);
        margin: 5px 0;
        position: relative;
    }
    
    /* 手機版側邊欄設為絕對定位覆蓋層 */
    .reader-sidebar {
        position: absolute !important;
        left: 0 !important;
        top: 0;
        height: 100%;
        width: 250px !important;
        min-width: 250px !important;
        z-index: 1000;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
        transition: left 0.3s ease !important;
        border-right: 1px solid var(--reader-border-primary) !important;
        opacity: 1 !important;
        overflow: visible !important;
    }
    
    /* 手機版側邊欄收縮狀態 */
    .reader-sidebar.collapsed {
        left: -250px !important;
        width: 250px !important;
        min-width: 250px !important;
        border-right: 1px solid var(--reader-border-primary) !important;
        opacity: 1 !important;
    }
    
    /* 手機版時側邊欄內容始終可見 */
    .reader-sidebar.collapsed .reader-sidebar-header,
    .reader-sidebar.collapsed .reader-feeds-section {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    
    /* 手機版主內容區域始終佔滿寬度 */
    .reader-main-content {
        width: 100%;
        margin-left: 0;
    }
    
    /* 手機版文章列表區域 */
    .reader-articles-section {
        padding-top: 0;
    }
    
    /* 手機版時不需要為收縮側邊欄調整內容區域 */
    .reader-mode-container.sidebar-collapsed .reader-main-content {
        margin-left: 0;
    }
    
    .reader-mode-container.sidebar-collapsed .reader-articles-section {
        padding-top: 0;
    }
    
    /* 手機版按鈕觸控優化 */
    .sidebar-hide-btn {
        padding: 8px 16px !important;
        font-size: 14px !important;
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* 手機版文章項目調整 */
    .article-thumbnail-container {
        width: 100px;
        height: 100px;
    }
    
    .article-content-wrapper {
        padding: 12px;
    }
    
    /* 手機版文章詳細視圖調整 */
    .article-detail-content {
        padding: 16px;
    }
    
    .article-detail-title {
        font-size: 24px;
    }
    
    .article-detail-text {
        font-size: 14px;
    }
    
    .article-detail-header {
        padding: 12px 16px;
    }
    
    .article-visit-original-btn {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* 文章詳細視圖 */
.article-detail-container {
    padding: 0;
    background-color: #1a1a1a;
    color: #ffffff;
    height: 100%;
    overflow-y: auto;
}

.article-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #404040;
    position: sticky;
    top: 0;
    background-color: #1a1a1a;
    z-index: 10;
}

.article-detail-back-btn {
    background: none;
    border: 1px solid #666;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.article-detail-back-btn:hover {
    background-color: #333;
    border-color: #888;
}

.article-detail-source-badge {
    background-color: #007aff;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    text-transform: uppercase;
}

.article-detail-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    line-height: 1.6;
}

.article-detail-title {
    font-size: 32px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 16px 0;
    line-height: 1.3;
}

.article-detail-meta {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #404040;
}

.article-detail-date {
    font-size: 14px;
    color: #999;
}

.article-detail-image {
    margin: 24px 0;
    text-align: center;
}

.article-detail-image img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.article-detail-text {
    font-size: 16px;
    color: #e0e0e0;
    line-height: 1.8;
    margin-bottom: 32px;
}

.article-detail-text br {
    margin-bottom: 12px;
}

.article-detail-actions {
    text-align: center;
    padding: 24px 0;
    border-top: 1px solid #404040;
    margin-top: 32px;
}

.article-visit-original-btn {
    background: linear-gradient(135deg, #007aff, #0056cc);
    color: #ffffff;
    border: none;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

.article-visit-original-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

/* 深色主題適配 */
#tech-news-reader.tab-content {
    background-color: transparent;
    padding: 0;
}

#tech-news-reader .reader-mode-container {
    border: 1px solid #e9ecef;
}

/* 文章控制項區域 */
.article-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
}

.article-star {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.2s ease;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.1);
}

.article-star:hover {
    color: #ffd700;
    background-color: rgba(255, 215, 0, 0.1);
    transform: scale(1.1);
}

.article-star.saved {
    color: #ffd700;
    background-color: rgba(255, 215, 0, 0.2);
}

.article-star.saved:hover {
    color: #ff6b6b;
    background-color: rgba(255, 107, 107, 0.1);
}