/* TARDIS 主題變量 */
:root {
    --tardis-blue: #003b6f;
    --tardis-light-blue: #0066cc;
    --tardis-gold: #ffd700;
    --tardis-white: #ffffff;
    --tardis-dark: #001a33;
    --tardis-gray: #2a2a2a;
    --tardis-light-gray: #4a4a4a;
    --tardis-text: #e0e0e0;
    --tardis-text-secondary: #b0b0b0;
    --tardis-shadow: rgba(0, 102, 204, 0.3);
    --tardis-glow: rgba(255, 215, 0, 0.2);
}

/* 全局樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: linear-gradient(135deg, var(--tardis-dark) 0%, var(--tardis-blue) 50%, var(--tardis-dark) 100%);
    background-attachment: fixed;
    color: var(--tardis-text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* TARDIS 容器 */
.tardis-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* TARDIS 頭部 */
.tardis-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 20px;
    background: linear-gradient(135deg, rgba(0, 59, 111, 0.8), rgba(0, 26, 51, 0.8));
    border: 2px solid var(--tardis-gold);
    border-radius: 15px;
    box-shadow: 0 0 30px var(--tardis-shadow);
    backdrop-filter: blur(10px);
}

.tardis-title h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(45deg, var(--tardis-gold), var(--tardis-light-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px var(--tardis-glow);
}

.subtitle {
    font-size: 1.2rem;
    color: var(--tardis-gold);
    margin-bottom: 10px;
    font-weight: 500;
}

.description {
    font-size: 1rem;
    color: var(--tardis-text-secondary);
    font-weight: 300;
}

/* 搜索區域 */
.search-section {
    margin-bottom: 30px;
}

.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto 15px;
}

#searchInput {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: 2px solid var(--tardis-gold);
    border-radius: 25px;
    background: rgba(0, 26, 51, 0.8);
    color: var(--tardis-text);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#searchInput:focus {
    border-color: var(--tardis-light-blue);
    box-shadow: 0 0 20px var(--tardis-shadow);
    transform: scale(1.02);
}

#searchInput::placeholder {
    color: var(--tardis-text-secondary);
}

.search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--tardis-gold);
    pointer-events: none;
}

.search-stats {
    text-align: center;
    color: var(--tardis-text-secondary);
    font-size: 0.9rem;
}

/* 分類標籤 */
.category-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    border: 2px solid var(--tardis-gold);
    background: rgba(0, 26, 51, 0.6);
    color: var(--tardis-text);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.tab-btn:hover {
    background: var(--tardis-gold);
    color: var(--tardis-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--tardis-glow);
}

.tab-btn.active {
    background: var(--tardis-gold);
    color: var(--tardis-dark);
    box-shadow: 0 0 15px var(--tardis-glow);
}

/* 門戶網格 */
.portals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
    flex: 1;
}

/* 門戶卡片 */
.portal-card {
    background: linear-gradient(135deg, rgba(0, 59, 111, 0.8), rgba(0, 26, 51, 0.8));
    border: 2px solid var(--tardis-gold);
    border-radius: 15px;
    padding: 25px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.portal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.1), transparent);
    transition: left 0.5s ease;
}

.portal-card:hover::before {
    left: 100%;
}

.portal-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: var(--tardis-light-blue);
    box-shadow: 0 10px 30px var(--tardis-shadow);
}

.portal-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: block;
}

.portal-card h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--tardis-gold);
}

.portal-card p {
    color: var(--tardis-text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.portal-link {
    display: inline-block;
    padding: 8px 20px;
    background: linear-gradient(45deg, var(--tardis-gold), var(--tardis-light-blue));
    color: var(--tardis-dark);
    text-decoration: none;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.portal-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--tardis-glow);
}

/* 禁用的門戶卡片樣式 */
.portal-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.portal-card.disabled:hover {
    transform: none;
    box-shadow: none;
}

.portal-card.disabled::before {
    display: none;
}

.portal-link.disabled {
    background: var(--tardis-gray);
    color: var(--tardis-text-secondary);
    cursor: not-allowed;
    border: 1px solid var(--tardis-light-gray);
}

.portal-link.disabled:hover {
    background: var(--tardis-gray);
    color: var(--tardis-text-secondary);
    transform: none;
}

.portal-tags {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.portal-tag {
    padding: 3px 8px;
    background: rgba(255, 215, 0, 0.2);
    color: var(--tardis-gold);
    border-radius: 10px;
    font-size: 0.75rem;
    border: 1px solid var(--tardis-gold);
}

/* 主題切換按鈕 */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 26, 51, 0.8);
    border: 2px solid var(--tardis-gold);
    color: var(--tardis-gold);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 100;
}

.theme-toggle:hover {
    background: var(--tardis-gold);
    color: var(--tardis-dark);
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--tardis-glow);
}

.tardis-header {
    position: relative;
}

/* 頁腳 */
.tardis-footer {
    text-align: center;
    padding: 20px;
    color: var(--tardis-text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 215, 0, 0.3);
    margin-top: auto;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .tardis-container {
        padding: 15px;
    }
    
    .tardis-title h1 {
        font-size: 2rem;
    }
    
    .portals-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .portal-card {
        padding: 20px;
    }
    
    .category-tabs {
        gap: 8px;
    }
    
    .tab-btn {
        padding: 8px 15px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .tardis-title h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .description {
        font-size: 0.9rem;
    }
    
    #searchInput {
        padding: 12px 45px 12px 15px;
        font-size: 0.9rem;
    }
}

/* 動畫效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.portal-card {
    animation: fadeIn 0.6s ease forwards;
}

.portal-card:nth-child(1) { animation-delay: 0.1s; }
.portal-card:nth-child(2) { animation-delay: 0.2s; }
.portal-card:nth-child(3) { animation-delay: 0.3s; }
.portal-card:nth-child(4) { animation-delay: 0.4s; }
.portal-card:nth-child(5) { animation-delay: 0.5s; }
.portal-card:nth-child(6) { animation-delay: 0.6s; }

/* 隱藏元素 */
.hidden {
    display: none !important;
}

/* 加載動畫 */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--tardis-text-secondary);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--tardis-gold);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* News Section Styles - TARDIS Theme */
.news-section {
    margin: 40px 0;
    padding: 30px;
    background: linear-gradient(135deg, rgba(0, 59, 111, 0.15), rgba(0, 26, 51, 0.15));
    border: 2px solid var(--tardis-gold);
    border-radius: 15px;
    box-shadow: 0 0 30px var(--tardis-shadow);
    backdrop-filter: blur(10px);
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

/* Add a subtle border to separate from main content */
.news-section::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--tardis-gold), transparent);
}

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 20px;
    border-bottom: 3px solid #cc0000;
}

.news-header h2 {
    color: var(--tardis-gold);
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0 0 20px 0;
    text-transform: uppercase;
    letter-spacing: -0.5px;
    text-shadow: 0 0 10px var(--tardis-glow);
}

.news-controls {
    display: flex;
    gap: 8px;
}

.news-refresh-btn,
.news-search-toggle {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
    border-radius: 4px;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.news-refresh-btn:hover,
.news-search-toggle:hover {
    background: #e9ecef;
    color: #495057;
    border-color: #adb5bd;
}

.advanced-search {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.search-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.search-filters input,
.search-filters select {
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #ffffff;
    color: #495057;
    font-size: 0.9rem;
    font-family: inherit;
}

.search-filters input:focus,
.search-filters select:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.search-filters button {
    padding: 10px 20px;
    background: #cc0000;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.search-filters button:hover {
    background: #b30000;
    transform: none;
    box-shadow: none;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.news-card {
    background: rgba(0, 59, 111, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.news-card:hover {
    background: rgba(0, 59, 111, 0.2);
    border-color: var(--tardis-gold);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px var(--tardis-shadow);
}

.news-card .news-header {
    margin-bottom: 12px;
    padding: 0;
    border: none;
}

.news-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
    color: #212529;
}

.news-title a {
    color: var(--tardis-text);
    text-decoration: none;
    font-weight: 600;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.news-title a:hover {
    color: var(--tardis-gold);
    text-decoration: underline;
}

.news-keyword {
    display: inline-block;
    padding: 3px 8px;
    background: #cc0000;
    color: #ffffff;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    border: none;
    margin-left: 8px;
}

.news-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--tardis-text-secondary);
}

.news-source {
    font-weight: 600;
    color: var(--tardis-gold);
}

.news-date {
    color: #6c757d;
    line-height: 1.3;
}

.relative-time {
    font-weight: 500;
    color: var(--tardis-gold);
}

.absolute-time {
    font-size: 0.85em;
    color: var(--tardis-text-secondary);
    opacity: 0.8;
}

.news-score {
    font-size: 0.75rem;
    color: #6c757d;
    font-style: italic;
}

.news-stats {
    margin-top: 30px;
    padding: 20px;
    background: rgba(0, 26, 51, 0.3);
    border-top: 1px solid var(--tardis-gold);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

.news-stats .stat {
    padding: 8px 16px;
    background: rgba(0, 59, 111, 0.6);
    border: 1px solid rgba(255, 215, 0, 0.7);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.news-stats .stat:hover {
    background: rgba(0, 59, 111, 0.8);
    border-color: var(--tardis-gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.stats-grid {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-weight: 600;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #cc0000;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    grid-column: 1 / -1;
    background: rgba(0, 59, 111, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

.no-results-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #6c757d;
}

.no-results h3 {
    color: var(--tardis-text);
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.no-results p {
    color: var(--tardis-text-secondary);
    font-size: 1rem;
}

.loading {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 1rem;
    grid-column: 1 / -1;
}

/* Responsive News Design */
@media (max-width: 768px) {
    .news-section {
        margin: 20px 0;
        padding: 20px;
    }
    
    .news-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .news-header h2 {
        font-size: 1.8rem;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .news-card {
        padding: 15px;
        margin-bottom: 10px;
    }
    
    .search-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-filters input,
    .search-filters select,
    .search-filters button {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .stats-grid {
        gap: 20px;
    }
    
    .news-stats {
        gap: 10px;
        padding: 15px;
    }
    
    .news-stats .stat {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .news-header h2 {
        font-size: 1.5rem;
    }
    
    .news-card {
        padding: 15px;
    }
    
    .news-title {
        font-size: 1rem;
    }
    
    .stats-grid {
        gap: 15px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .news-stats .stat {
        font-size: 0.75rem;
        padding: 4px 8px;
        margin: 2px;
    }
}

/* Light theme styles for news section */
body.light-theme .news-section {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 249, 250, 0.95));
    border: 2px solid #3498db;
    box-shadow: 0 0 30px rgba(52, 152, 219, 0.3);
}

body.light-theme .news-section::before {
    background: linear-gradient(90deg, transparent, #3498db, transparent);
}

body.light-theme .news-header {
    border-bottom-color: #e74c3c;
}

body.light-theme .news-header h2 {
    color: #3498db;
    text-shadow: 0 0 10px rgba(52, 152, 219, 0.3);
}

body.light-theme .news-refresh-btn,
body.light-theme .news-search-toggle {
    background: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
}

body.light-theme .news-refresh-btn:hover,
body.light-theme .news-search-toggle:hover {
    background: #e9ecef;
    color: #495057;
    border-color: #adb5bd;
}

body.light-theme .advanced-search {
    background: #f8f9fa;
    border-color: #dee2e6;
}

body.light-theme .search-filters input,
body.light-theme .search-filters select {
    background: #ffffff;
    color: #495057;
    border-color: #ced4da;
}

body.light-theme .search-filters input:focus,
body.light-theme .search-filters select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

body.light-theme .search-filters button {
    background: #3498db;
    color: #ffffff;
}

body.light-theme .search-filters button:hover {
    background: #2980b9;
}

body.light-theme .news-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(52, 152, 219, 0.5);
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body.light-theme .news-card:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(52, 152, 219, 0.4);
}

body.light-theme .news-title a {
    color: #2c3e50;
    font-weight: 600;
}

body.light-theme .news-title a:hover {
    color: #3498db;
}

body.light-theme .news-keyword {
    background: #e74c3c;
    color: #ffffff;
}

body.light-theme .news-meta {
    color: #6c757d;
}

body.light-theme .news-source {
    color: #3498db;
    font-weight: 600;
}

body.light-theme .news-date {
    color: #6c757d;
}

body.light-theme .relative-time {
    color: #e74c3c;
    font-weight: 500;
}

body.light-theme .absolute-time {
    color: #6c757d;
    opacity: 0.8;
}

body.light-theme .news-score {
    color: #6c757d;
}

body.light-theme .news-stats {
    background: rgba(255, 255, 255, 0.9);
    border-top-color: #3498db;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body.light-theme .news-stats .stat {
    background: rgba(52, 152, 219, 0.15);
    border: 1px solid rgba(52, 152, 219, 0.8);
    color: #2c3e50;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

body.light-theme .news-stats .stat:hover {
    background: rgba(52, 152, 219, 0.25);
    border-color: #3498db;
    color: #1a252f;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

body.light-theme .stat-label {
    color: #6c757d;
}

body.light-theme .stat-value {
    color: #e74c3c;
}

body.light-theme .no-results {
    background: #f8f9fa;
}

body.light-theme .no-results-icon {
    color: #6c757d;
}

body.light-theme .no-results h3 {
    color: #495057;
}

body.light-theme .no-results p {
    color: #6c757d;
}

body.light-theme .loading {
    color: #6c757d;
}

/* 日間模式主題切換按鈕 */
body.light-theme .theme-toggle {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #3498db;
    color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

body.light-theme .theme-toggle:hover {
    background: #3498db;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    transform: scale(1.1);
}

/* 回到頂部按鈕 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--tardis-gold), var(--tardis-light-blue));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    color: var(--tardis-dark);
    box-shadow: 0 4px 15px rgba(0, 102, 204, 0.3);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-2px) scale(1.1);
    box-shadow: 0 6px 25px rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, var(--tardis-light-blue), var(--tardis-gold));
}

.back-to-top:active {
    transform: translateY(0) scale(0.95);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .back-to-top {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
} 