/* 地圖共用樣式 - 彰化縣防災資訊網 */

/* 地圖容器樣式 */
#map,
#emergency-map {
    width: 100%;
    height: 600px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px;
}

/* 行動裝置優化 */
@media (max-width: 768px) {
    #map,
    #emergency-map {
        height: 400px;
        border-radius: 0;
    }
}

/* Leaflet 彈出視窗自訂樣式 */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
}

.leaflet-popup-content {
    margin: 15px;
    font-size: 14px;
    line-height: 1.6;
    min-width: 200px;
}

.leaflet-popup-content h3 {
    margin: 0 0 12px 0;
    color: #1e5799;
    font-size: 16px;
    font-weight: bold;
    border-bottom: 2px solid #6495ED;
    padding-bottom: 6px;
}

.leaflet-popup-content p {
    margin: 8px 0;
    color: #333;
}

.leaflet-popup-content strong {
    color: #555;
    font-weight: 600;
}

/* 狀態標籤 */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 5px;
}

.status-open {
    background-color: #4CAF50;
    color: white;
}

.status-closed {
    background-color: #757575;
    color: white;
}

.status-normal {
    background-color: #2196F3;
    color: white;
}

.status-warning {
    background-color: #FF9800;
    color: white;
}

.status-alert {
    background-color: #F44336;
    color: white;
}

/* 導航按鈕 */
.navigate-btn {
    width: 100%;
    margin-top: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.navigate-btn:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

/* 設施清單 */
.facilities-list {
    margin: 10px 0;
    padding: 8px;
    background-color: #f5f5f5;
    border-radius: 4px;
    font-size: 13px;
}

.facilities-list strong {
    display: block;
    margin-bottom: 4px;
    color: #1e5799;
}

.facilities-list span {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 2px 8px;
    background-color: #e3f2fd;
    border-radius: 3px;
    font-size: 11px;
    color: #1565c0;
}

/* 資料數值樣式 */
.data-value {
    font-size: 16px;
    font-weight: bold;
    color: #1e5799;
}

.data-unit {
    font-size: 12px;
    color: #757575;
    margin-left: 2px;
}

/* Marker Cluster 樣式調整 */
.marker-cluster-small {
    background-color: rgba(110, 204, 57, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(110, 204, 57, 0.8);
    color: white;
    font-weight: bold;
}

.marker-cluster-medium {
    background-color: rgba(241, 211, 87, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(241, 211, 87, 0.8);
    color: white;
    font-weight: bold;
}

.marker-cluster-large {
    background-color: rgba(253, 156, 115, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(253, 156, 115, 0.8);
    color: white;
    font-weight: bold;
}

/* 圖層控制面板樣式 */
.leaflet-control-layers {
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.leaflet-control-layers-expanded {
    padding: 10px;
    background-color: white;
}

.leaflet-control-layers-toggle {
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTggMTBoMjBNOCAxOGgyME04IDI2aDIwIiBzdHJva2U9IiMzMzMiIHN0cm9rZS13aWR0aD0iMiIgZmlsbD0ibm9uZSIvPjwvc3ZnPg==');
    width: 36px;
    height: 36px;
}

/* GPS 定位按鈕樣式 */
.leaflet-control-locate {
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.leaflet-control-locate a {
    background-color: white;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.leaflet-control-locate a:hover {
    background-color: #f5f5f5;
}

/* 鄉鎮市篩選控制面板 */
.town-filter-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-width: 200px;
}

.town-filter-panel h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #1e5799;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 6px;
}

.town-filter-panel select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.town-filter-panel select:hover {
    border-color: #6495ED;
}

.town-filter-panel select:focus {
    outline: none;
    border-color: #1e5799;
    box-shadow: 0 0 0 2px rgba(30, 87, 153, 0.1);
}

/* 圖例面板 */
.map-legend {
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-size: 13px;
    line-height: 1.6;
}

.map-legend h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #1e5799;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 6px 0;
}

.legend-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border-radius: 50%;
}

.legend-icon.open {
    background-color: #4CAF50;
}

.legend-icon.closed {
    background-color: #757575;
}

.legend-icon.normal {
    background-color: #2196F3;
}

.legend-icon.warning {
    background-color: #FF9800;
}

.legend-icon.alert {
    background-color: #F44336;
}

/* 載入動畫 */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    text-align: center;
}

.map-loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 10px auto 0;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1e5799;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 無障礙優化 */
.leaflet-container a.leaflet-popup-close-button {
    font-size: 20px;
    padding: 4px 8px;
}

.leaflet-container a.leaflet-popup-close-button:focus {
    outline: 2px solid #1e5799;
    outline-offset: 2px;
}

/* 高對比模式支援 */
@media (prefers-contrast: high) {
    .leaflet-popup-content-wrapper {
        border: 2px solid #000;
    }

    .navigate-btn {
        border: 2px solid #000;
    }
}

/* 行動裝置觸控優化 */
@media (hover: none) and (pointer: coarse) {
    .navigate-btn {
        padding: 14px 18px;
        font-size: 16px;
    }

    .leaflet-popup-content {
        font-size: 16px;
    }

    .town-filter-panel select {
        padding: 10px;
        font-size: 16px;
    }
}

/* 列印樣式 */
@media print {
    #map,
    #emergency-map {
        height: 400px;
        page-break-inside: avoid;
    }

    .leaflet-control-container {
        display: none;
    }
}
