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

:root {
    /* 主色調 */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    
    /* 中性色 */
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* 狀態色 */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    /* 陰影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* 間距 */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* 圓角 */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==================== 容器布局 ==================== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1e40af 100%);
    color: white;
    padding: var(--spacing-lg) var(--spacing-xl);
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    font-size: 2rem;
}

.header-subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
    font-weight: 300;
}

.main-content {
    display: grid;
    grid-template-columns: 320px 1fr 380px;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    height: calc(100vh - 120px);
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* ==================== 卡片樣式 ==================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: var(--spacing-md);
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ==================== 左側控制面板 ==================== */
.control-panel {
    overflow-y: auto;
    padding-right: var(--spacing-sm);
}

.control-panel::-webkit-scrollbar {
    width: 6px;
}

.control-panel::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

.control-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

.control-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 搜尋區塊 */
.search-box {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.search-input {
    height: 45px;  /* RWD需要再調整 */
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-icon {
    font-size: 1.1rem;
}

/* 分類篩選 */
.filter-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.chip {
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.chip:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
    transform: translateY(-1px);
}

.chip.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 權重控制 */
.weight-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.5;
}

.weight-slider-group {
    margin-bottom: var(--spacing-lg);
}

.slider-container {
    margin-bottom: var(--spacing-lg);
}

.slider-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.label-icon {
    margin-right: var(--spacing-xs);
}

.weight-value {
    color: var(--primary-color);
    font-weight: 600;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: var(--radius-sm);
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.slider-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
}

/* 快速模式按鈕 */
.mode-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
}

.mode-btn {
    padding: var(--spacing-md);
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-family: inherit;
}

.mode-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.mode-btn.active {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.mode-icon {
    display: block;
    font-size: 1.5rem;
    margin-bottom: var(--spacing-xs);
}

.mode-name {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.mode-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 篩選器 */
.filter-group {
    margin-bottom: var(--spacing-md);
}

.filter-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.filter-select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--card-bg);
    cursor: pointer;
    font-family: inherit;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filter-checkbox {
    margin-right: var(--spacing-sm);
    cursor: pointer;
}

/* 統計區塊 */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
/* ==================== 地圖區域 ==================== */
.map-section {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.map-container {
    width: 100%;
    height: 100%;
    background: var(--bg-color);
}

.map-controls {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 1000;
}

.map-control-btn {
    width: 44px;
    height: 44px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.map-control-btn:hover {
    background: var(--primary-color);
    transform: scale(1.05);
}

.map-control-btn:hover .control-icon {
    filter: grayscale(100%) brightness(2);
}

.control-icon {
    font-size: 1.25rem;
}

.location-status {
    position: absolute;
    bottom: var(--spacing-md);
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    z-index: 1000;
    border: 1px solid var(--border-color);
}

.status-icon {
    font-size: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.status-text {
    color: var(--text-primary);
    font-weight: 500;
}

/* ==================== 右側結果面板 ==================== */
.results-panel {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.results-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sort-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--card-bg);
    cursor: pointer;
    font-family: inherit;
}

.results-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

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

.results-list::-webkit-scrollbar-track {
    background: var(--bg-color);
}

.results-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

.results-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 結果卡片 */
.result-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.result-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.result-card.selected {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.02);
}

.result-rank {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.result-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    padding-right: 40px;
}

.result-category {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: var(--bg-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    margin-bottom: var(--spacing-sm);
}

.result-rating {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.stars {
    color: var(--accent-color);
    font-size: 0.9rem;
}

.rating-value {
    font-weight: 600;
    color: var(--text-primary);
}

.rating-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.result-distance {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.result-score {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
    margin-top: var(--spacing-sm);
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.score-bar {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: var(--radius-sm);
    margin: 0 var(--spacing-sm);
    overflow: hidden;
}

.score-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    border-radius: var(--radius-sm);
    transition: width 0.5s ease;
}

.score-value {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.875rem;
    min-width: 40px;
    text-align: right;
}

/* 空狀態 */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-text {
    font-size: 0.875rem;
    line-height: 1.6;
}

/* ==================== 彈窗 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    z-index: 1;
}

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-color);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2;
}

.modal-close:hover {
    background: var(--error-color);
    color: white;
    transform: rotate(90deg);
}

.detail-header {
    padding: var(--spacing-xl);
    border-bottom: 1px solid var(--border-color);
}

.detail-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.detail-body {
    padding: var(--spacing-xl);
}

.detail-section {
    margin-bottom: var(--spacing-xl);
}

.detail-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.info-item {
    display: flex;
    align-items: start;
    gap: var(--spacing-sm);
}

.info-icon {
    font-size: 1.25rem;
    margin-top: 2px;
}

.info-content {
    flex: 1;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-xs);
}

.info-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.detail-actions {
    padding: var(--spacing-lg) var(--spacing-xl);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: var(--spacing-md);
}

.action-btn {
    flex: 1;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.action-btn:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.action-btn.primary:hover {
    background: var(--primary-hover);
}

/* ==================== 載入中 ==================== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==================== 響應式設計 ==================== */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 280px 1fr 340px;
    }
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .control-panel {
        max-height: 400px;
    }
    
    .results-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 50vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

@media (max-width: 768px) {
    .header {
        padding: var(--spacing-md);
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .header-subtitle {
        font-size: 0.85rem;
    }
    
    .main-content {
        padding: var(--spacing-sm);
        gap: var(--spacing-sm);
    }
    
    .mode-buttons {
        grid-template-columns: 1fr;
    }
    
    .stats-row {
        grid-template-columns: 1fr;
    }
    
    .detail-info-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== 工具類 ==================== */
.text-primary {
    color: var(--text-primary);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-muted {
    color: var(--text-muted);
}

.text-success {
    color: var(--success-color);
}

.text-warning {
    color: var(--warning-color);
}

.text-error {
    color: var(--error-color);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
}