:root {
    --primary-color: #2c3e50;    /* 深藍 */
    --accent-color: #3498db;     /* 亮藍 */
    --hover-color: #1abc9c;      /* 藍綠 */
    --bg-color: #f4f7f6;         /* 淺灰背景 */
    --card-bg: #ffffff;
    --text-color: #333;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --nav-height: 60px;
}

body {
    margin: 0;
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* --- 導覽列 --- */
.navbar {
    background-color: var(--primary-color);
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.nav-logo {
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none;
    letter-spacing: 1px;
}

.nav-menu {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
    gap: 15px;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    color: #ecf0f1;
    text-decoration: none;
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.3s;
}

.nav-menu a:hover, .nav-menu a:focus {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
}

/* 下拉選單 */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    border-radius: 4px;
    padding: 10px 0;
    z-index: 1001;
    list-style: none;
}

.dropdown-menu a {
    color: #333;
    display: block;
    padding: 10px 20px;
    font-size: 0.9rem;
}

.dropdown-menu a:hover {
    background-color: #f1f1f1;
    color: var(--accent-color);
}

/* JS 切換 class 用來顯示選單 */
.show-dropdown {
    display: block !important;
}

/* 漢堡選單按鈕 (手機版) */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
}
.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 5px 0;
    transition: 0.3s;
}

/* --- 主要內容 --- */
.main-content {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
    min-height: calc(100vh - var(--nav-height) - 100px);
}

.breadcrumb-container {
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: #666;
}
.breadcrumb-container .highlight {
    color: var(--accent-color);
    font-weight: bold;
}

/* 卡片式設計 */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    overflow: hidden;
    animation: fadeIn 0.5s ease;
}

.card-header {
    background: linear-gradient(to right, #ffffff, #f9f9f9);
    padding: 15px 25px;
    border-bottom: 1px solid #eee;
}

.card-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--primary-color);
}

.card-body {
    padding: 25px;
}

/* 頁面切換控制 */
.page { display: none; }
.page.active { display: block; }

/* --- 控制面板 (Forms) --- */
.control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 5px;
    font-weight: 500;
}

input[type="date"], select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    outline: none;
    background: white;
}

input[type="date"]:focus, select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

button {
    padding: 9px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-primary { background-color: var(--accent-color); color: white; }
.btn-primary:hover { background-color: #2980b9; transform: translateY(-1px); }

.btn-success { background-color: #27ae60; color: white; }
.btn-success:hover { background-color: #219150; }

.btn-danger { background-color: #e74c3c; color: white; }
.btn-danger:hover { background-color: #c0392b; }

/* --- 表格樣式 --- */
.table-responsive {
    width: 100%;
    overflow-x: auto; /* 橫向捲動 */
    margin-top: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px; /* 確保表格不會擠在一起 */
}

th, td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #f1f2f6;
    color: #444;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

tr:hover {
    background-color: #fbfbfb;
}

tr:nth-child(even) {
    background-color: #fdfdfd;
}

/* 數據顏色 */
.cases { color: #007bff; font-weight: bold; }
.deaths { color: #dc3545; font-weight: bold; }
.injuries { color: #28a745; font-weight: bold; }

/* --- 地圖與圖表 --- */
#map, #his-map {
    height: 600px;
    width: 100%;
    border-radius: 4px;
    z-index: 1; /* 避免蓋過 Nav */
}

.echart-box {
    height: 600px;
    width: 100%;
    margin-bottom: 30px;
}

canvas {
    max-height: 500px;
}

/* --- 其他元件 --- */
.alert-box {
    padding: 15px;
    border-left: 4px solid #f1c40f;
    background: #fef9e7;
    margin: 10px 0;
    font-size: 0.9rem;
}

.main-footer {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    font-size: 0.9rem;
    border-top: 1px solid #eee;
    margin-top: 40px;
}

/* --- Loading Overlay --- */
#loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
#loading-overlay.active { display: flex; }
.loading-content p { color: #333; font-weight: 500; margin-top: 10px; }

/* --- RWD 手機版 --- */
@media (max-width: 768px) {
    .menu-toggle { display: block; }

    .nav-menu {
        display: none; /* 預設隱藏 */
        flex-direction: column;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        width: 100%;
        background-color: var(--primary-color);
        padding: 0;
        gap: 0;
    }

    .nav-menu.active { display: flex; }

    .nav-menu li {
        width: 100%;
        text-align: center;
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .nav-menu a {
        display: block;
        padding: 15px;
        border-radius: 0;
    }

    /* 手機版下拉選單變成直接展開或另外處理，這裡簡單處理為相對定位 */
    .dropdown-menu {
        position: static;
        width: 100%;
        background-color: #1a252f; /* 深一點的顏色 */
        box-shadow: none;
    }
    
    .dropdown-menu a {
        color: #bbb;
        padding-left: 30px;
    }

    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }

    #map, #his-map, .echart-box {
        height: 400px;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}