/* ====================================
   搜尋 Overlay 樣式（液態玻璃風格）
   共用模組 - 預售屋/成屋分析頁面
   ==================================== */

/* 搜尋按鈕 & 分享按鈕 & 收藏按鈕 - 共用液態玻璃樣式 */
.search-toggle-btn,
.share-btn,
.favorite-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-toggle-btn:hover,
.share-btn:hover,
.favorite-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

.share-btn:active,
.favorite-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

/* 收藏按鈕：推到右邊（在分享按鈕左側） */
.favorite-btn {
    margin-left: auto;
}

/* 分享按鈕：緊鄰收藏按鈕 */
.share-btn {
    margin-left: 0.5rem;
}

.search-toggle-btn {
    margin-left: 0.5rem;  /* 與分享按鈕間距 */
}

/* 分享成功提示動畫 */
.share-btn.shared {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.5);
}

/* ==================== 收藏按鈕樣式 ==================== */

/* 收藏按鈕已收藏狀態 */
.favorite-btn.active {
    color: var(--color-favorites);
    background: rgba(236, 72, 153, 0.15);
    border-color: rgba(236, 72, 153, 0.3);
}

.favorite-btn.active:hover {
    background: rgba(236, 72, 153, 0.25);
    border-color: rgba(236, 72, 153, 0.5);
}

/* 收藏按鈕載入狀態 */
.favorite-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.favorite-btn.loading i {
    animation: spin 1s linear infinite;
}

/* 愛心跳動動畫 */
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1); }
    75% { transform: scale(1.15); }
}

.favorite-btn.heartbeat i {
    animation: heartbeat 0.4s ease-in-out;
}

/* 未登入時收藏按鈕樣式 - 不降低透明度，點擊時再提示登入 */
.favorite-btn.not-logged-in {
    opacity: 1;
}

/* 提示訊息淡入淡出動畫 */
@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }
    15% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    85% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }
}

/* 搜尋 Overlay 容器 */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none;
    opacity: 0;
    transition: opacity 0.28s ease;
    color: #0f172a;
}

.search-overlay.active {
    display: flex;
    opacity: 1;
}

/* 半透明背景 */
.search-overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.72), transparent 34%),
        radial-gradient(circle at 100% 20%, rgba(125, 211, 252, 0.2), transparent 30%),
        rgba(241, 246, 251, 0.62);
    backdrop-filter: blur(30px) saturate(190%) brightness(106%);
    -webkit-backdrop-filter: blur(30px) saturate(190%) brightness(106%);
}

/* 搜尋框容器 */
.search-overlay .search-overlay-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: max(15vh, calc(env(safe-area-inset-top) + 96px)) 1rem 0;
}

/* 液態玻璃搜尋框 */
.overlay-search-box {
    position: relative;
    width: 100%;
    max-width: min(720px, calc(100vw - 28px));
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    animation: overlaySlideIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes overlaySlideIn {
    from {
        opacity: 0;
        transform: translateY(-14px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 關閉按鈕 */
.search-close-btn {
    position: absolute;
    top: 13px;
    right: 14px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(226, 238, 250, 0.42));
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    color: rgba(15, 23, 42, 0.68);
    font-size: 17px;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease, color 0.25s ease, border-color 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 8px 22px rgba(15, 23, 42, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.82);
    z-index: 2;
}

.search-close-btn:hover {
    background: rgba(255, 255, 255, 0.74);
    border-color: rgba(255, 255, 255, 0.9);
    color: rgba(15, 23, 42, 0.92);
    transform: scale(1.04);
}

.search-close-btn:active {
    transform: scale(0.96);
}

/* Overlay 內搜尋表單 */
.overlay-search-box .search-form {
    display: flex;
    align-items: center;
    gap: 0;
}

.overlay-search-box .search-input-group {
    position: relative;
    flex: 1;
}

.overlay-search-box .search-input {
    width: 100%;
    height: 68px;
    background:
        linear-gradient(112deg, rgba(255, 255, 255, 0.72), rgba(242, 248, 255, 0.42) 48%, rgba(214, 232, 248, 0.38)),
        linear-gradient(90deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.16) 38%, rgba(125, 211, 252, 0.08));
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 24px;
    padding: 0 4.25rem 0 4.1rem;
    font-size: 1.12rem;
    color: rgba(15, 23, 42, 0.94);
    font-weight: 650;
    letter-spacing: 0;
    backdrop-filter: blur(34px) saturate(220%) brightness(108%);
    -webkit-backdrop-filter: blur(34px) saturate(220%) brightness(108%);
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    outline: none;
    box-shadow:
        0 18px 52px rgba(15, 23, 42, 0.12),
        0 6px 18px rgba(15, 23, 42, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.88),
        inset 0 -1px 0 rgba(255, 255, 255, 0.2);
}

.overlay-search-box .search-input::placeholder {
    color: rgba(51, 65, 85, 0.52);
    font-weight: 500;
}

.overlay-search-box .search-input:focus-visible {
    background:
        linear-gradient(112deg, rgba(255, 255, 255, 0.82), rgba(242, 248, 255, 0.52) 48%, rgba(224, 242, 254, 0.42)),
        linear-gradient(90deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.22) 38%, rgba(125, 211, 252, 0.14));
    border-color: rgba(255, 255, 255, 0.88);
    box-shadow:
        0 0 0 4px rgba(125, 211, 252, 0.18),
        0 22px 62px rgba(15, 23, 42, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

/* 搜尋圖標 */
.overlay-search-box .search-icon {
    position: absolute;
    left: 1.45rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(51, 65, 85, 0.64);
    font-size: 1.22rem;
    transition: color 0.3s ease;
    pointer-events: none;
}

.overlay-search-box .search-input:focus-visible + .search-icon {
    color: rgba(15, 23, 42, 0.86);
}

/* 搜尋建議下拉 */
.overlay-search-box .search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background:
        linear-gradient(112deg, rgba(255, 255, 255, 0.74), rgba(242, 248, 255, 0.48) 48%, rgba(214, 232, 248, 0.42));
    backdrop-filter: blur(36px) saturate(210%) brightness(108%);
    -webkit-backdrop-filter: blur(36px) saturate(210%) brightness(108%);
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 22px;
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow:
        0 18px 48px rgba(15, 23, 42, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.82);
    padding: 0.45rem;
}

.overlay-search-box .suggestion-item {
    padding: 0.92rem 0.85rem;
    color: rgba(15, 23, 42, 0.9);
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: transparent;
    text-decoration: none;
}

.overlay-search-box .history-item {
    opacity: 0.96;
}

.overlay-search-box .suggestion-item:last-child {
    border-bottom: none;
}

.overlay-search-box .suggestion-item:hover,
.overlay-search-box .suggestion-item.highlighted {
    background: rgba(255, 255, 255, 0.36);
    border-color: rgba(255, 255, 255, 0.48);
}

.overlay-search-box .suggestion-name {
    font-size: 16px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.5;
    margin-right: 12px;
    text-align: left;
    color: rgba(15, 23, 42, 0.94);
}

.overlay-search-box .suggestion-type {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    flex-shrink: 0;
    line-height: 1.5;
}

.overlay-search-box .suggestion-type.presale {
    background: var(--color-type-presale-soft);
    border-color: var(--color-type-presale-border);
    color: var(--color-type-presale);
}

.overlay-search-box .suggestion-type.completed {
    background: var(--color-type-completed-soft);
    border-color: var(--color-type-completed-border);
    color: var(--color-type-completed);
}

.overlay-search-box .suggestion-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.overlay-search-box .delete-history-btn {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    color: rgba(51, 65, 85, 0.62);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

@media (hover: hover) {
    .overlay-search-box .delete-history-btn:hover {
        background: rgba(15, 23, 42, 0.14);
        color: rgba(15, 23, 42, 0.88);
        transform: scale(1.04);
    }
}

.overlay-search-box .no-suggestions {
    padding: 20px;
    text-align: center;
    color: rgba(51, 65, 85, 0.62);
    font-size: 14px;
}

.overlay-search-box .suggestions-loading {
    min-height: 56px;
    padding: 16px 18px;
    color: rgba(51, 65, 85, 0.68);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.overlay-search-box .suggestions-loading i {
    color: var(--color-type-presale);
    font-size: 15px;
}

body:not(.search-page) .search-navigation-feedback {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: none;
    place-items: center;
    padding: 24px;
    background: rgba(8, 11, 15, 0);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, background 160ms ease;
}

body:not(.search-page) .search-navigation-feedback.is-visible {
    opacity: 1;
    background: rgba(8, 11, 15, 0.28);
}

body:not(.search-page) .navigation-feedback-panel {
    width: min(320px, 100%);
    border-radius: 18px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(15, 23, 42, 0.92);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(30px) saturate(150%);
    -webkit-backdrop-filter: blur(30px) saturate(150%);
    transform: translateY(8px) scale(0.98);
    transition: transform 180ms ease;
}

body:not(.search-page) .search-navigation-feedback.is-visible .navigation-feedback-panel {
    transform: translateY(0) scale(1);
}

body:not(.search-page) .navigation-feedback-panel i {
    color: var(--color-type-presale);
    font-size: 20px;
    flex: 0 0 auto;
}

body:not(.search-page) .navigation-feedback-panel strong,
body:not(.search-page) .navigation-feedback-panel span {
    display: block;
}

body:not(.search-page) .navigation-feedback-panel strong {
    font-size: 14px;
    margin-bottom: 3px;
}

body:not(.search-page) .navigation-feedback-panel span {
    color: rgba(51, 65, 85, 0.72);
    font-size: 13px;
}

/* ====================================
   淺色背景頁面用 - 搜尋按鈕燻黑風格
   ==================================== */

.light-theme-btn.search-toggle-btn,
.light-theme-btn.share-btn,
.light-theme-btn.favorite-btn {
    background: rgba(40, 40, 40, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
    color: #f0f0f0;
}

.light-theme-btn.search-toggle-btn:hover,
.light-theme-btn.share-btn:hover,
.light-theme-btn.favorite-btn:hover {
    background: rgba(30, 30, 30, 0.95);
    border-color: rgba(0, 0, 0, 0.2);
}

/* 淺色主題下的收藏按鈕已收藏狀態 */
.light-theme-btn.favorite-btn.active {
    color: var(--color-favorites);
    background: rgba(236, 72, 153, 0.2);
    border-color: rgba(236, 72, 153, 0.4);
}

/* RWD 響應式 */
@media (max-width: 768px) {
    /* 手機版收藏按鈕 */
    .favorite-btn {
        display: flex;
        width: 40px;
        height: 40px;
        font-size: 16px;
        margin-left: auto;
    }

    /* 手機版顯示分享按鈕，緊鄰收藏按鈕 */
    .share-btn {
        display: flex;
        width: 40px;
        height: 40px;
        font-size: 16px;
        margin-left: 0.5rem;
    }

    .search-toggle-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        margin-left: 0.5rem;  /* 與分享按鈕的小間距 */
    }

    .search-overlay .search-overlay-container {
        padding: max(14vh, calc(env(safe-area-inset-top) + 88px)) 0.75rem 0;
    }

    .overlay-search-box {
        max-width: calc(100vw - 24px);
    }

    .overlay-search-box .search-input {
        height: 60px;
        font-size: 1rem;
        padding-left: 3.55rem;
        border-radius: 22px;
    }

    .search-close-btn {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .search-toggle-btn,
    .share-btn,
    .favorite-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
        border-radius: var(--radius-lg);
    }

    .overlay-search-box {
        max-width: calc(100vw - 20px);
    }

    .overlay-search-box .search-input {
        height: 56px;
        font-size: 15px;
        padding-left: 3.35rem;
        padding-right: 3.75rem;
    }

    .overlay-search-box .search-icon {
        left: 1.25rem;
        font-size: 18px;
    }

    .overlay-search-box .suggestion-item {
        padding: 14px 12px;
    }

    .overlay-search-box .suggestion-name {
        font-size: 15px;
    }
}

/* ====================================
   收藏 Toast 提示樣式
   ==================================== */

.favorites-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(40, 40, 40, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.favorites-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.favorites-toast i {
    font-size: 16px;
}

/* Toast 類型顏色 */
.favorites-toast-success {
    background: rgba(22, 163, 74, 0.95);
}

.favorites-toast-success i {
    color: white;
}

.favorites-toast-info {
    background: rgba(40, 40, 40, 0.95);
}

.favorites-toast-warning {
    background: rgba(255, 193, 7, 0.95);
    color: var(--color-text-dark);
}

.favorites-toast-error {
    background: rgba(220, 53, 69, 0.95);
}

/* 手機版 Toast */
@media (max-width: 768px) {
    .favorites-toast {
        bottom: 80px;
        padding: 10px 20px;
        font-size: 13px;
        max-width: 90%;
    }
}
