@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-primary);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

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

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

/* --- 👤 地圖首頁：個人頁面與管理入口（右上角） --- */
.map-corner-links {
    position: absolute;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-profile-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.map-profile-link:hover {
    background-color: var(--bg-secondary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-xl);
}

.map-profile-link:active {
    transform: scale(0.98);
}

.map-profile-link .fa-user-circle,
.map-profile-link .fa-gauge-high {
    font-size: 1.25rem;
    line-height: 1;
}

.map-admin-link[hidden] {
    display: none !important;
}

@media (min-width: 769px) {
    .map-corner-links {
        right: calc(68px + env(safe-area-inset-right, 0px));
    }
}

body:has(.filter-control-expanded) .map-corner-links {
    opacity: 0.35;
    pointer-events: none;
}

@media (max-width: 768px) {
    .map-profile-link {
        padding: 7px 12px;
        font-size: 13px;
    }
}

/* --- 🏷️ 標記叢集 (Marker Clusters) --- */
.marker-cluster-small {
    background-color: rgba(255, 247, 237, 0.8);
    border: 2px solid rgba(249, 115, 22, 0.5);
}

.marker-cluster-small div {
    background-color: rgba(253, 186, 116, 0.9);
}

.marker-cluster-medium {
    background-color: rgba(255, 251, 240, 0.8);
    border: 2px solid rgba(245, 158, 11, 0.5);
}

.marker-cluster-medium div {
    background-color: rgba(253, 230, 138, 0.9);
}

.marker-cluster-large {
    background-color: rgba(255, 247, 237, 0.8);
    border: 2px solid rgba(249, 115, 22, 0.8);
}

.marker-cluster-large div {
    background-color: rgba(253, 186, 116, 0.95);
}

.marker-cluster div {
    color: var(--text-primary);
    font-family: var(--font-family);
    font-weight: 700;
}

/* --- 💬 彈出視窗 (Popup) --- */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0;
    overflow: hidden;
    max-height: min(72dvh, 620px);
    max-height: min(72vh, 620px);
}

.leaflet-popup-content {
    margin: 0;
    min-width: 280px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* 內層：標題固定、內文區可捲動（長備註不撐爆手機視窗） */
.leaflet-popup-content .popup-inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    max-height: min(68dvh, 580px);
    max-height: min(68vh, 580px);
}

.leaflet-popup-content .popup-body-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
}

.popup-header {
    padding: 16px 16px 8px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

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

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

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

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

.popup-body p.popup-notes {
    display: block;
}

.popup-notes-text {
    display: block;
    margin-top: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.popup-body i {
    color: var(--gray-400);
    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: all var(--transition-fast);
    text-decoration: none;
    gap: 6px;
    white-space: nowrap;
}

/* 導航 — 主橘色實心 */
.nav-button {
    background-color: var(--primary);
    color: #FFFFFF;
}

.nav-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

/* 詳情 — 橘色外框 */
.details-button {
    background-color: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.details-button:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
}

/* 回報 — 淺橘底 */
.report-button {
    background-color: var(--primary-light);
    color: var(--primary);
    border: none;
}

.report-button:hover {
    background-color: var(--primary-muted);
    color: var(--primary-hover);
    transform: translateY(-1px);
}

/* --- 🔍 篩選控制面板 (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: all 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: var(--bg-secondary) !important;
    color: var(--primary);
}

/* 篩選內容 - 預設隱藏 */
.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 var(--border-light);
}

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

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

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

.filter-clear-btn:hover {
    background-color: var(--error);
    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: var(--bg-secondary);
    color: var(--text-primary);
}

/* 篩選選項 */
.filter-section h5 {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 16px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.filter-section h5 .section-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

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

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

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

.filter-label {
    font-size: 14px;
    color: var(--text-primary);
    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);
    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(59, 130, 246, 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-wrapper {
        max-height: min(78dvh, calc(100svh - 96px));
        max-height: min(78vh, calc(100vh - 96px));
    }

    .leaflet-popup-content .popup-inner {
        max-height: min(74dvh, calc(100svh - 112px));
        max-height: min(74vh, calc(100vh - 112px));
    }

    .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: 60px;
        left: 0;
        right: 0;
        bottom: auto;
        margin: 0 !important;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: 70vh;
        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;
    }
}

.leaflet-control-container:has(.filter-control-expanded) .leaflet-control-layers {
    display: none !important;
}

body:has(.filter-control-expanded) .locate-button {
    display: none !important;
}

/* ================================================
   📸 照片打卡功能
   ================================================ */

/* --- 相機按鈕 (Photo Checkin Button) --- */
.photo-checkin-button {
    position: absolute;
    bottom: 100px;
    right: 24px;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(249,115,22,0.4);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-checkin-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 24px rgba(249,115,22,0.5);
}

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

@media (max-width: 768px) {
    .photo-checkin-button {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        right: calc(12px + env(safe-area-inset-right, 0px));
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
}

/* --- 打卡模態框 --- */
.checkin-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.checkin-modal.active {
    pointer-events: all;
    opacity: 1;
}

.checkin-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.checkin-modal-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: min(480px, 100vw - 16px);
    max-height: min(92dvh, 92vh);
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
}

.checkin-modal.active .checkin-modal-content {
    transform: translateY(0);
}

@media (min-width: 480px) {
    .checkin-modal {
        align-items: center;
        padding: max(12px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    }
    .checkin-modal-content {
        border-radius: 20px;
        max-height: min(88dvh, 88vh);
        transform: translateY(20px) scale(0.97);
    }
    .checkin-modal.active .checkin-modal-content {
        transform: translateY(0) scale(1);
    }
}

.checkin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 2;
}

.checkin-modal-header h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkin-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.15s;
}

.checkin-close-btn:hover {
    background: var(--bg-tertiary);
}

.checkin-modal-body {
    padding: 0 0 20px;
}

/* --- 步驟容器 --- */
.checkin-step {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 20px;
}

/* --- 載入中 --- */
.checkin-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.checkin-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-secondary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: checkin-spin 0.8s linear infinite;
}

.checkin-spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--bg-secondary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: checkin-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* --- 照片預覽 --- */
.checkin-preview-wrap {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #000;
}

.checkin-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.checkin-preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
}

.checkin-photo-time {
    color: rgba(255,255,255,0.9);
    font-size: 12px;
}

/* --- 通知提示 --- */
.checkin-notice {
    margin: 12px 20px;
    padding: 10px 14px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 10px;
    color: #92400E;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.checkin-far-notice {
    margin: 0 0 10px;
    padding: 10px 12px;
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.25);
    border-radius: 10px;
    color: #991B1B;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}

/* --- 表單區塊 --- */
.checkin-section {
    padding: 16px 20px 0;
}

.checkin-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.checkin-char-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
}

/* --- 店家選擇器 --- */
.checkin-shop-selector {
    border: 1.5px solid var(--border-default);
    border-radius: 14px;
    overflow: hidden;
}

.checkin-loading-small {
    padding: 14px 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.checkin-matched-shop {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    gap: 12px;
}

.matched-shop-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.matched-shop-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.matched-shop-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matched-shop-distance {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.change-shop-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1.5px solid var(--primary);
    border-radius: 20px;
    background: transparent;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

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

.checkin-shop-list {
    border-top: 1px solid var(--border-default);
    padding: 8px 0;
}

.shop-list-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 10px;
    cursor: pointer;
    transition: background 0.1s;
    border-radius: 0;
}

.shop-list-item:hover {
    background: var(--bg-secondary);
}

.shop-list-item.selected {
    background: rgba(249, 115, 22, 0.06);
}

.shop-list-item input[type="radio"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.shop-list-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.shop-list-distance {
    font-size: 12px;
    color: var(--text-tertiary);
}

.shop-search-row {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 8px 12px;
    border-top: 1px dashed var(--border-default);
}

.shop-search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1.5px solid var(--border-default);
    border-radius: 10px 0 0 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    -webkit-appearance: none;
}

.shop-search-input:focus {
    border-color: var(--primary);
    background: var(--bg-primary);
}

.shop-search-submit {
    flex-shrink: 0;
    padding: 8px 14px;
    border: 1.5px solid var(--primary);
    border-left: none;
    border-radius: 0 10px 10px 0;
    background: var(--primary);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.shop-search-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- 搜尋候選 dropdown --- */
.shop-search-suggestions {
    margin: 0 12px;
    border: 1.5px solid var(--primary);
    border-top: none;
    border-radius: 0 0 10px 10px;
    background: var(--bg-primary);
    max-height: 220px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid var(--border-default);
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
}

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

.suggestion-item:hover,
.suggestion-item:active {
    background: rgba(249, 115, 22, 0.06);
}

.suggestion-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.suggestion-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.suggestion-address {
    font-size: 12px;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-empty {
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-tertiary);
}

.checkin-no-shop .shop-search-row,
.checkin-no-shop .shop-search-suggestions {
    align-self: stretch;
}

.checkin-no-shop .shop-search-row {
    padding: 0;
    border-top: none;
}

.checkin-no-shop .shop-search-suggestions {
    margin: 0;
}

.suggestion-distance {
    font-size: 12px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    margin-left: 8px;
}

.checkin-no-shop {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

.checkin-no-shop i {
    font-size: 28px;
}

/* --- 推薦選擇 --- */
.checkin-recommend-row {
    display: flex;
    gap: 10px;
}

.checkin-recommend-opt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border: 1.5px solid var(--border-default);
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    color: var(--text-secondary);
    background: var(--bg-primary);
}

.checkin-recommend-opt input[type="radio"] {
    display: none;
}

.checkin-recommend-opt i {
    font-size: 20px;
}

.checkin-recommend-opt:has(input:checked) {
    border-color: currentColor;
}

.checkin-recommend-opt.recommend:has(input:checked) {
    border-color: #22C55E;
    background: rgba(34, 197, 94, 0.08);
    color: #22C55E;
}

.checkin-recommend-opt.neutral:has(input:checked) {
    border-color: #8E8E93;
    background: rgba(142, 142, 147, 0.08);
    color: #8E8E93;
}

.checkin-recommend-opt.not-recommend:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

/* --- 文字框 --- */
.checkin-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px 14px;
    border: 1.5px solid var(--border-default);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    resize: none;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.15s;
    line-height: 1.5;
}

.checkin-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* --- 提交按鈕 --- */
.checkin-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: calc(100% - 40px);
    margin: 20px 20px 8px;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(249,115,22,0.3);
}

.checkin-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(249,115,22,0.4);
}

.checkin-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* --- 打卡成功提示 --- */
.checkin-success-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 10000;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    min-width: 280px;
    max-width: 90vw;
    overflow: hidden;
}

.checkin-success-toast.show {
    transform: translateX(-50%) translateY(0);
}

.checkin-success-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
}

.checkin-success-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.checkin-success-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.checkin-success-text strong {
    font-size: 14px;
    color: var(--text-primary);
}

.checkin-success-text span {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.checkin-success-link {
    flex-shrink: 0;
    padding: 6px 14px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.checkin-success-link:hover {
    opacity: 0.85;
}

/* --- 小型 Toast --- */
.photo-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    opacity: 0;
    z-index: 10001;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.photo-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.photo-toast-info {
    background: #333;
    color: white;
}

.photo-toast-error {
    background: var(--primary);
    color: white;
}

.photo-toast-success {
    background: #22C55E;
    color: white;
}

/* 🍜 篩選開關按鈕 */
.filter-control-toggle {
    z-index: 9999 !important;
    pointer-events: all !important;
    position: relative;
}

.filter-control-panel {
    z-index: 9998 !important;
}

.filter-control-toggle i {
    pointer-events: none;
    position: relative;
    z-index: 1;
}

.filter-control-toggle::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    pointer-events: none;
    display: none;
}

.filter-control-toggle {
    pointer-events: all !important;
    position: relative;
    z-index: 9999;
}

/* 🍜 篩選搜尋欄 */
.filter-search-section {
    padding: 0 0 12px 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 12px;
    position: relative;
}

.filter-search-input {
    width: 100%;
    padding: 10px 44px 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.search-btn.active {
    background: var(--primary);
    color: #ffffff;
}

.search-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-search-input:focus {
    border-color: var(--primary);
}

.filter-search-input::placeholder {
    color: var(--text-secondary);
}

/* 自動完成下拉 */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.autocomplete-item:hover {
    background-color: var(--primary-light);
}

.autocomplete-item .shop-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.autocomplete-item .shop-address {
    font-size: 12px;
    color: var(--text-secondary);
}

.autocomplete-no-results {
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
}

.filter-search-section {
    position: relative;
}

/* ============================================
   📋 勘誤回報浮動按鈕
   ============================================ */
.report-float-button {
    position: absolute;
    bottom: 168px;
    right: 24px;
    z-index: 1000;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.report-float-button:hover {
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 6px 24px rgba(245, 158, 11, 0.55);
}

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

@media (max-width: 768px) {
    .report-float-button {
        bottom: calc(128px + env(safe-area-inset-bottom, 0px));
        right: calc(12px + env(safe-area-inset-right, 0px));
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
}

/* ============================================
   📋 勘誤回報模態框
   ============================================ */
.report-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.report-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.report-modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: reportModalIn 0.25s ease;
}

@keyframes reportModalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.report-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-default);
    background: linear-gradient(135deg, var(--accent-light), var(--bg-primary));
    border-radius: 16px 16px 0 0;
}

.report-modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.report-modal-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.report-modal-close-btn:hover {
    background: var(--border-default);
    color: var(--text-primary);
}

.report-modal-body {
    padding: 20px;
}

/* 選擇模式提示 */
.report-mode-prompt {
    text-align: center;
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* 模式卡片 */
.report-mode-cards {
    display: flex;
    gap: 12px;
}

.report-mode-card {
    flex: 1;
    padding: 20px 14px;
    border: 2px solid var(--border-default);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    background: var(--bg-primary);
}

.report-mode-card:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.report-mode-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.report-mode-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
    color: var(--text-primary);
}

.report-mode-card p {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

@media (max-width: 480px) {
    .report-mode-cards {
        flex-direction: column;
    }
}

/* 返回按鈕 */
.report-back-btn {
    background: none;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    padding: 6px 12px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.report-back-btn:hover {
    background: var(--border-default);
    color: var(--text-primary);
}

.report-form-title {
    margin: 0 0 16px;
    font-size: 16px;
    color: var(--text-primary);
}

/* 店家搜尋 */
.shop-search-wrapper {
    position: relative;
}

#report-shop-search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
    color: var(--text-primary);
    background: var(--bg-primary);
}

#report-shop-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.shop-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
}

.shop-search-results .search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--border-default);
    transition: background 0.15s;
}

.shop-search-results .search-result-item:hover {
    background: var(--accent-light);
}

.shop-search-results .search-result-item:last-child {
    border-bottom: none;
}

.shop-search-results .no-match {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: center;
}

.shop-selected-info {
    margin-top: 8px;
    padding: 8px 12px;
    background: #F0FDF4;
    border-radius: 6px;
    font-size: 13px;
    color: #166534;
    display: none;
}

/* 表單通用 */
.report-modal-body .form-group {
    margin-bottom: 14px;
}

.report-modal-body .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.report-modal-body .form-group .required {
    color: var(--error);
}

.report-modal-body .form-group input[type="text"],
.report-modal-body .form-group input[type="email"],
.report-modal-body .form-group input[type="date"],
.report-modal-body .form-group select,
.report-modal-body .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.report-modal-body .form-group select:focus,
.report-modal-body .form-group input:focus,
.report-modal-body .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.report-modal-body .form-group textarea {
    resize: vertical;
    min-height: 70px;
}

/* 表單動作 */
.report-modal-body .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.report-btn-cancel {
    padding: 10px 20px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.report-btn-cancel:hover {
    background: var(--border-default);
}

.report-btn-submit {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.report-btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.report-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 完成訊息 */
.report-success {
    text-align: center;
    padding: 20px 0;
}

.report-success-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.report-success h2 {
    margin: 0 0 8px;
    font-size: 20px;
    color: var(--text-primary);
}

.report-success p {
    margin: 0 0 4px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.report-btn-close {
    margin-top: 20px;
    padding: 10px 30px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.report-btn-close:hover {
    background: var(--border-default);
}

/* 回報模態框 — 登入狀態列 */
.report-auth-bar {
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.3s;
}
.report-auth-bar a {
    text-decoration: underline;
}
.report-auth-user {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}
.report-auth-guest {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
}

/* 地圖首頁說明：收合時避開右下角按鈕與左下角圖資來源 */
body:has(.map-guide) .leaflet-bottom.leaflet-left {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}

.map-guide {
    position: absolute;
    left: max(12px, env(safe-area-inset-left));
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 1000;
    width: min(380px, calc(100vw - 88px));
    max-height: min(46vh, 420px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    color: #18181b;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    font-size: 15px;
    line-height: 1.65;
}

.map-guide summary {
    cursor: pointer;
    min-height: 44px;
    padding: 12px 14px;
    font-weight: 600;
    list-style: none;
    flex: 0 0 auto;
}

.map-guide summary::-webkit-details-marker {
    display: none;
}

.map-guide-body {
    padding: 0 14px 14px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.map-guide summary:focus-visible,
.map-guide a:focus-visible {
    outline: 2px solid #c2410c;
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .map-guide {
        width: min(240px, calc(100vw - 150px));
        max-height: 42vh;
        font-size: 15px;
    }

    .map-guide[open] {
        width: calc(100vw - 76px - env(safe-area-inset-left) - env(safe-area-inset-right));
    }

    .locate-button {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        right: calc(12px + env(safe-area-inset-right, 0px));
        width: 48px;
        height: 48px;
    }
}

.map-guide h1 {
    font-size: 18px;
    line-height: 1.35;
    margin: 0 0 8px;
}

.map-guide h2 {
    font-size: 15px;
    margin: 14px 0 8px;
}

.map-guide h3 {
    font-size: 14px;
    margin: 10px 0 4px;
}

.map-guide p {
    margin: 0 0 8px;
}

.map-guide a {
    color: #c2410c;
}