/**
 * 地圖搜尋功能樣式 - map-search.css
 * 包含搜尋容器、篩選器、統計資訊等搜尋相關功能
 * 2025/07/30 - 整合搜尋歷史記錄功能 - 修正手機版問題
 */

/* ===== 懸浮搜尋覆蓋層 ===== */
.map-search-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(rgba(0, 0, 0, 0.6), transparent);
    color: white;
    padding: 20px;
    padding-bottom: 50px;
    pointer-events: none;
    transition: all 0.3s ease;
}

.map-search-overlay * {
    pointer-events: auto;
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    align-items: center;
}

/* ===== 搜尋輸入框包裝器 ===== */
.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-row .uk-input,
.search-row .uk-select {
    font-size: 14px;
    border-radius: 6px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    flex: 1;
    min-width: 120px;
    background: white;
    color: #333;
    transition: all 0.3s ease;
}

.search-row .uk-input::placeholder {
    color: #999;
}

.search-row .uk-input:focus,
.search-row .uk-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    background: white;
}

.search-row .uk-select option {
    background: white;
    color: #333;
}

/* ===== 搜尋歷史下拉選單 ===== */
.search-history-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(221, 221, 221, 0.8);
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.search-history-dropdown.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-history-item {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(240, 240, 240, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
}

.search-history-item:hover {
    background: rgba(248, 249, 250, 0.9);
}

.search-history-item:last-child {
    border-bottom: none;
}

.search-history-text {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.search-history-text .query {
    font-weight: 500;
    margin-bottom: 2px;
}

.search-history-text .meta {
    font-size: 12px;
    color: #666;
}

.search-history-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s ease;
}

.search-history-remove:hover {
    background-color: rgba(248, 215, 218, 0.9);
    color: #d32f2f;
}

.search-history-footer {
    padding: 8px 12px;
    border-top: 1px solid rgba(240, 240, 240, 0.8);
    background-color: rgba(250, 250, 250, 0.9);
}

.search-history-clear {
    width: 100%;
    padding: 6px 12px;
    background: none;
    border: 1px solid rgba(222, 226, 230, 0.8);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: all 0.2s ease;
}

.search-history-clear:hover {
    background-color: rgba(248, 215, 218, 0.9);
    border-color: #d32f2f;
    color: #d32f2f;
}

.search-history-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* ===== 手機版搜尋按鈕 ===== */
.mobile-search-container {
    position: relative;
    display: none; /* 桌面版隱藏 */
}

.mobile-search-toggle {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
}

.mobile-search-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mobile-search-toggle.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* ===== 手機版搜尋面板 ===== */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-search-overlay.show {
    opacity: 1;
    visibility: visible;
}

.mobile-search-input {
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    background: white;
    z-index: 2001;
    padding: 20px;
    border-bottom: 1px solid #eee;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.mobile-search-input.show {
    transform: translateY(0);
}

.mobile-search-input input {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px 15px;
    font-size: 16px; /* 防止 iOS 縮放 */
    background: white;
    transition: all 0.3s ease;
}

.mobile-search-input input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    outline: none;
}

/* ===== 手機版搜尋歷史特殊樣式 ===== */
.search-history-dropdown.mobile {
    position: relative;
    top: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    max-height: 250px;
    background: white;
    backdrop-filter: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 地點類型篩選器 */
.category-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 5px 0 10px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-bottom: 0;
}

.category-filters::-webkit-scrollbar {
    display: none;
}

.category-filter {
    background: rgb(255 255 255 / 67%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 8px 16px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    flex-shrink: 0;
    color: #313131;
}

.category-filter.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.category-filter:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.category-filter.active:hover {
    background: #0056b3;
}

/* 統計資訊區域 */
.map-info-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.place-count-text {
    font-size: 14px;
    font-weight: 600;
    color: white;
    letter-spacing: 0.3px;
}

.page-count-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* 載入動畫 */
.map-search-overlay.loading .place-count-text {
    opacity: 0.6;
    animation: pulse 1.5s ease-in-out infinite;
}

.map-search-overlay .page-count-text {
    display: none;
}

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

/* 響應式設計 */
@media (max-width: 768px) {
    .map-search-overlay {
        top: 0;
        left: 0;
        right: 0;
        padding: 12px 15px;
    }

    .search-row {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 12px;
    }

    /* 手機版搜尋切換 */
    .mobile-search-container {
        display: block;
        order: -1;
        flex-shrink: 0;
    }

    /* 隱藏桌面版搜尋框和歷史 */
    .search-input-wrapper {
        display: none !important;
    }

    .search-row select {
        flex: 1;
        min-width: auto;
    }

    .category-filters {
        gap: 6px;
        margin-bottom: 0;
    }

    .category-filter {
        padding: 6px 12px;
        font-size: 12px;
    }

    .place-count-text {
        font-size: 13px;
    }

    .page-count-text {
        font-size: 12px;
    }
    
    .search-row .uk-input, 
    .search-row .uk-select {
        height: 34px !important;
    }

    /* 隱藏桌面版搜尋歷史 */
    .search-history-dropdown:not(.mobile) {
        display: none !important;
    }
}

@media (min-width: 769px) {
    /* 桌面版隱藏手機版元素 */
    .mobile-search-input,
    .mobile-search-overlay {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .map-search-overlay {
        top: 0;
        left: 0;
        right: 0;
        padding: 10px 12px;
    }

    .search-row .uk-input,
    .search-row .uk-select {
        font-size: 13px;
        padding: 6px 10px;
    }

    .mobile-search-toggle {
        width: 35px;
        height: 35px;
    }
}