* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft JhengHei', 'Segoe UI', sans-serif;
}

body {
    background: linear-gradient(135deg, #f0f5ff 0%, #e8f4ff 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 25px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    border-left: 8px solid #e31837;
}

h1 {
    color: #e31837;
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.1);
}

.subtitle {
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.stat-item {
    background: #f8f9fa;
    padding: 12px 25px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    text-align: center;
    min-width: 160px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #e31837;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
}

.legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    background: white;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.05);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.line-color {
    width: 20px;
    height: 6px;
    border-radius: 3px;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid;
}

/* 地圖區塊（置中顯示） */
.map-section-main {
    margin-bottom: 40px;
}

.map-container {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.1);
    height: 650px;
    position: relative;
    overflow: hidden;
}

#railwayMap {
    width: 100%;
    height: 100%;
    position: relative;
    background: 
        radial-gradient(circle at 30% 30%, rgba(173, 216, 230, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(144, 238, 144, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(255, 182, 193, 0.1) 0%, transparent 50%),
        #f8fafc;
}

.region {
    position: absolute;
    border-radius: 12px;
    opacity: 0.05;
    z-index: 1;
    border: 1px solid rgba(0,0,0,0.1);
}

.guangdong { 
    background: #e31837; 
    left: 20%; top: 20%; 
    width: 50%; height: 55%; 
}

.guangzhou { 
    background: #00a650; 
    left: 35%; top: 40%; 
    width: 22%; height: 28%; 
}

.shenzhen { 
    background: #ff6b35; 
    left: 22%; top: 65%; 
    width: 16%; height: 22%; 
}

.east-guangdong { 
    background: #00a650; 
    left: 62%; top: 22%; 
    width: 28%; height: 32%; 
}

.north-guangdong { 
    background: #ff6b35; 
    left: 32%; top: 12%; 
    width: 28%; height: 28%; 
}

.fujian { 
    background: #9c27b0; 
    left: 75%; top: 18%; 
    width: 22%; height: 38%; 
}

.jiangxi { 
    background: #2196f3; 
    left: 18%; top: 8%; 
    width: 22%; height: 22%; 
}

.station {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid;
    z-index: 100;
    cursor: pointer;
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.station:hover {
    transform: translate(-50%, -50%) scale(1.8);
    z-index: 1000;
    box-shadow: 0 0 25px rgba(0,0,0,0.4);
}

.station-label {
    position: absolute;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 10px;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    z-index: 50;
    white-space: nowrap;
    pointer-events: none;
    border-left: 3px solid;
    transition: all 0.3s ease;
    opacity: 0.9;
    font-weight: 500;
}

.station:hover + .station-label {
    opacity: 1;
    background: white;
    z-index: 1001;
    font-weight: bold;
    transform: scale(1.05);
}

.station-info {
    position: absolute;
    background: white;
    border-radius: 12px;
    padding: 20px;
    width: 300px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 10000;
    display: none;
    border-top: 6px solid;
}

.station-info h3 {
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.time-badge {
    display: inline-block;
    background: #e31837;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 15px;
}

/* 篩選和結果區塊 */
.filter-result-section {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
}

.filter-panel {
    flex: 1;
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.1);
    min-width: 350px;
    max-width: 400px;
}

.result-panel {
    flex: 2;
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.filter-header h2 {
    color: #333;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-icon {
    font-size: 1.2rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.result-header h2 {
    color: #333;
    font-size: 1.5rem;
}

.result-stats {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.result-count {
    font-size: 1.8rem;
    font-weight: bold;
    color: #e31837;
}

.result-text {
    font-size: 0.9rem;
    color: #666;
}

.search-container {
    margin-bottom: 25px;
}

.search-box {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.search-box:focus {
    outline: none;
    border-color: #e31837;
    box-shadow: 0 0 0 3px rgba(227, 24, 55, 0.1);
}

/* 組合篩選器 */
.combined-filters {
    margin-bottom: 20px;
}

.filter-group {
    margin-bottom: 25px;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.filter-group-header h3 {
    color: #333;
    font-size: 1.1rem;
    font-weight: 600;
}

/* 藥丸按鈕樣式 */
.pill-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill-btn {
    padding: 10px 16px;
    border-radius: 25px;
    border: 2px solid #e0e0e0;
    background: white;
    color: #666;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pill-btn:hover {
    border-color: #e31837;
    color: #e31837;
    transform: translateY(-2px);
}

.pill-btn.active {
    background: #e31837;
    color: white;
    border-color: #e31837;
}

.line-pill {
    padding: 10px 14px;
}

.line-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* 活動篩選標籤 */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
    min-height: 40px;
}

.active-filter-tag {
    background: #f0f7ff;
    color: #0066cc;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #cce0ff;
}

.active-filter-tag .remove-btn {
    background: none;
    border: none;
    color: #0066cc;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.active-filter-tag .remove-btn:hover {
    background: #0066cc;
    color: white;
}

/* 車站列表 */
.station-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-height: 600px;
}

.station-list::-webkit-scrollbar {
    width: 6px;
}

.station-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.station-list::-webkit-scrollbar-thumb {
    background: #e31837;
    border-radius: 3px;
}

.station-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.08);
    border-left: 6px solid;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
}

.station-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border-color: #e0e0e0;
}

.station-card h4 {
    color: #333;
    margin-bottom: 12px;
    font-size: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-time {
    font-size: 1.4rem;
    font-weight: bold;
    color: #e31837;
    margin-bottom: 12px;
}

.card-line {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.card-region {
    display: inline-block;
    padding: 4px 12px;
    background: #f8f9fa;
    border-radius: 15px;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 12px;
}

.station-card p {
    font-size: 14px;
    color: #666;
    margin-top: 8px;
    line-height: 1.5;
}

/* 重置按鈕 */
.reset-btn {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #e0e0e0;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reset-btn:hover {
    background: #e31837;
    color: white;
    border-color: #e31837;
    transform: translateY(-2px);
}

.reset-icon {
    font-size: 1rem;
}

.region-label {
    position: absolute;
    font-size: 16px;
    font-weight: bold;
    color: rgba(0,0,0,0.7);
    z-index: 5;
    pointer-events: none;
    text-shadow: 1px 1px 3px rgba(255,255,255,0.8);
}

footer {
    text-align: center;
    margin-top: 40px;
    padding: 25px;
    background: white;
    border-radius: 15px;
    color: #777;
    font-size: 14px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.05);
}

.time-scale {
    position: absolute;
    bottom: 30px;
    left: 30px;
    background: rgba(255,255,255,0.9);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.1);
    z-index: 50;
}

.time-scale h4 {
    margin-bottom: 10px;
    color: #e31837;
}

.time-bar {
    height: 10px;
    background: linear-gradient(90deg, 
        #4CAF50 0%, 
        #FFC107 33%, 
        #FF9800 66%, 
        #F44336 100%);
    border-radius: 5px;
    margin-bottom: 10px;
    position: relative;
}

.time-marker {
    position: absolute;
    top: -5px;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: bold;
}

.time-marker:nth-child(1) { left: 0%; }
.time-marker:nth-child(2) { left: 33%; }
.time-marker:nth-child(3) { left: 66%; }
.time-marker:nth-child(4) { left: 100%; }

/* 響應式設計 */
@media (max-width: 1200px) {
    .filter-result-section {
        flex-direction: column;
    }
    
    .filter-panel {
        max-width: 100%;
    }
    
    .station-list {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .map-container {
        height: 550px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .legend {
        gap: 15px;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .stats {
        gap: 15px;
    }
    
    .stat-item {
        min-width: 140px;
        padding: 10px 15px;
    }
    
    .map-container {
        height: 450px;
        padding: 10px;
    }
    
    .legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .station-list {
        grid-template-columns: 1fr;
    }
    
    .pill-container {
        gap: 6px;
    }
    
    .pill-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .filter-result-section {
        gap: 20px;
    }
    
    .active-filters {
        gap: 6px;
    }
    
    .active-filter-tag {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .stats {
        gap: 10px;
    }
    
    .stat-item {
        min-width: 120px;
        padding: 8px 12px;
    }
    
    .map-container {
        height: 400px;
    }
    
    .pill-container {
        justify-content: center;
    }
    
    .filter-panel,
    .result-panel {
        padding: 20px;
    }
}

/* 空狀態樣式 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    grid-column: 1 / -1;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 20px;
}

/* 車站群組樣式 */
.station-cluster {
    position: absolute;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 5px;
    z-index: 90;
}

.station-cluster .station {
    position: relative;
    transform: none;
    margin: 2px;
}