@import 'design-system.css';

/* ============================================
   Ramen Club Frontend Styles
   ============================================ */

body {
    padding: 0;
    margin: 0;
    overflow: hidden; /* 防止地圖外滾動 */
}

html, body {
    height: 100%;
    width: 100%;
}

/* --- 🗺️ 地圖容器 (Map Container) --- */
#map {
    height: 100vh !important;
    width: 100vw;
    min-height: 500px;
    z-index: 1;
}

/* --- 📍 定位按鈕 (Locate Button) --- */
.locate-button {
    position: absolute;
    bottom: 32px;
    right: 24px;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-float);
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
}

.locate-button:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.locate-button:active {
    transform: scale(0.95);
}

.locate-button.locating {
    color: var(--primary-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(198, 40, 40, 0); }
    100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0); }
}

/* --- 🏷️ 標記叢集 (Marker Clusters) --- */
.marker-cluster-small {
    background-color: rgba(255, 235, 238, 0.6); /* 淺紅 */
    border: 2px solid rgba(198, 40, 40, 0.5);
}

.marker-cluster-small div {
    background-color: rgba(255, 205, 210, 0.8);
}

.marker-cluster-medium {
    background-color: rgba(255, 248, 225, 0.6); /* 淺黃 */
    border: 2px solid rgba(255, 179, 0, 0.5);
}

.marker-cluster-medium div {
    background-color: rgba(255, 236, 179, 0.8);
}

.marker-cluster-large {
    background-color: rgba(255, 235, 238, 0.6);
    border: 2px solid rgba(198, 40, 40, 0.8);
}

.marker-cluster-large div {
    background-color: rgba(255, 205, 210, 0.9);
}

.marker-cluster div {
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
}

/* --- 💬 彈出視窗 (Popup) --- */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 280px;
    max-width: 320px;
}

.popup-header {
    padding: 16px 16px 8px;
    border-bottom: 1px solid #F0F0F0;
}

.leaflet-popup-content h3 {
    margin: 0 0 12px 0;
    color: var(--text-main);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    border: none;
}

.popup-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.popup-body {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.popup-body p {
    margin: 6px 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.popup-body i {
    color: var(--text-muted);
    margin-top: 3px;
    width: 16px;
    text-align: center;
}

/* 彈出視窗按鈕 */
.nav-button, .details-button, .report-button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    gap: 6px;
    white-space: nowrap;
}

.nav-button {
    background-color: var(--success-color);
    color: white;
}

.nav-button:hover {
    background-color: #1B5E20;
    transform: translateY(-1px);
}

.details-button {
    background-color: var(--info-color);
    color: white;
}

.details-button:hover {
    background-color: #0D47A1; /* 深藍 */
    transform: translateY(-1px);
}

.report-button {
    background-color: var(--danger-color);
    color: white;
    border: none;
}

.report-button:hover {
    background-color: #B71C1C; /* 深紅 */
    color: white;
    border: none;
}

/* --- 🔍 篩選控制面板 (Filter Control) --- */
.leaflet-control-layers,
.filter-control-panel {
    border: none !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-md) !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(8px);
    margin-top: 16px !important;
    margin-right: 16px !important;
    transition: all 0.3s ease;
}

.leaflet-control-layers-toggle,
.filter-control-toggle {
    width: 44px !important;
    height: 44px !important;
    border-radius: var(--radius-md) !important;
    background-size: 24px !important;
    transition: var(--transition-fast);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
}

.leaflet-control-layers-toggle:hover,
.filter-control-toggle:hover {
    background-color: #F5F5F5 !important;
    color: var(--primary-color);
}

/* 篩選內容 - 預設隱藏 */
.filter-content {
    display: none; /* 關鍵：預設隱藏 */
    padding: 16px;
    min-width: 300px;
    max-height: 70vh; /* 限制高度 */
    overflow-y: auto;
}

/* 只有在展開狀態下顯示內容 */
.filter-control-expanded .filter-content {
    display: block;
}

/* 展開時隱藏切換按鈕（可選，視設計而定，這裡保留按鈕作為標題列的一部分或隱藏） */
/* 這裡我們讓切換按鈕在展開時變為關閉按鈕的功能，或者在標題列添加關閉按鈕 */

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #EEE;
}

.filter-header h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.filter-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-clear-btn {
    font-size: 12px;
    color: var(--danger-color);
    background: none;
    border: 1px solid var(--danger-color);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.filter-clear-btn:hover {
    background-color: var(--danger-color);
    color: white;
}

.filter-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    transition: all 0.2s;
}

.filter-close-btn:hover {
    background-color: #F5F5F5;
    color: var(--text-main);
}

/* 篩選選項 */
.filter-section h5 {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 16px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 8px;
    background-color: white;
    border: 1px solid #EEE;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-option:hover {
    border-color: var(--primary-color);
    background-color: #FFEBEE;
}

.filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    accent-color: var(--primary-color);
}

.filter-label {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
}

.filter-icon {
    margin-right: 8px;
    font-size: 16px;
}

/* --- 👤 用戶位置 (User Location) --- */
.user-location-marker {
    background: transparent !important;
    border: none !important;
}

.user-location-dot {
    width: 16px;
    height: 16px;
    background-color: var(--info-color);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
    position: relative;
}

.user-location-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background-color: rgba(33, 150, 243, 0.2);
    border-radius: 50%;
    animation: location-pulse 2s infinite;
    z-index: -1;
}

@keyframes location-pulse {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

/* --- 📱 響應式調整 (Responsive) --- */
@media (max-width: 768px) {
    /* 定位按鈕調整 */
    .locate-button {
        bottom: 24px; /* 調整位置 */
        right: 16px;
        width: 48px;
        height: 48px;
    }

    /* 彈出視窗調整 */
    .leaflet-popup-content {
        min-width: 260px;
        max-width: 280px;
    }
    
    .popup-buttons {
        flex-direction: row; /* 保持水平排列 */
    }
    
    .nav-button, .details-button, .report-button {
        padding: 6px 8px;
        font-size: 12px;
    }

    /* 篩選面板手機版優化 */
    .filter-control-panel {
        margin: 10px !important;
        max-width: calc(100vw - 20px);
    }

    .filter-control-expanded {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        margin: 0 !important;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: 60vh; /* 限制高度，不佔滿全螢幕 */
        border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
        z-index: 9999 !important; /* 確保在最上層，覆蓋所有地圖控制項 */
    }

    .filter-content {
        max-height: 50vh;
        width: auto;
        min-width: auto;
    }
    
    /* 確保切換按鈕在展開時仍然可見或有替代方案 */
    .filter-control-expanded .filter-control-toggle {
        display: none; /* 展開時隱藏切換按鈕，使用標題列關閉 */
    }
}

/* 當篩選面板展開時，隱藏圖層控制按鈕 (使用 :has 選擇器) */
.leaflet-control-container:has(.filter-control-expanded) .leaflet-control-layers {
    display: none !important;
}

/* 當篩選面板展開時，也可以選擇隱藏定位按鈕，避免視覺干擾 */
body:has(.filter-control-expanded) .locate-button {
    display: none !important;
}
