/* 重置樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 設定body和html為滿版 */
html, body {
    height: 100%;
    overflow: hidden;
    font-family: Arial, sans-serif;
}

/* Logo 樣式 */
.logo-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 2000;
    transition: all 0.3s ease;
}

.logo-container:hover {
    transform: translateY(-2px);
}

.logo-link {
    display: block;
    text-decoration: none;
}

.logo {
    height: 40px;
    width: auto;
    display: block;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

/* 背景模糊層 */
.background-blur {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('images/map.webp');
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.8);
    z-index: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

/* 地圖容器 - 滿版顯示 */
.map-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background-color: #f0f0f0;
    transform: translateZ(0); /* 啟用硬體加速 */
    backface-visibility: hidden;
    z-index: 1;
}

/* 電腦版樣式調整 */
@media (min-width: 992px) {
    .background-blur {
        opacity: 1;
    }

    .map-container {
        background-color: transparent;
        cursor: default; /* 取消拖曳手勢 */
    }

    .map-container.dragging {
        cursor: default;
    }
    
    /* 隱藏底部提示 */
    #bottomTooltip {
        display: none !important;
    }
}

/* 當拖曳時改變游標 */
.map-container.dragging {
    cursor: grabbing;
}

/* 地圖包裝器 */
.map-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    transition: none;
    will-change: transform;
    transform-origin: 0 0;
}

/* 地圖圖片 */
.map-image {
    display: block;
    width: 5600px; /* 保持原始尺寸 */
    height: 4200px; /* 保持原始尺寸 */
    transform: scale(0.5); /* 使用scale縮放到50% */
    transform-origin: 0 0; /* 從左上角開始縮放 */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* 禁用圖片的預設拖曳行為 */
.map-image {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* 標記容器 */
.markers-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* 標記樣式 */
.marker {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 10;
    /* 確保觸控事件正常工作 */
    touch-action: manipulation;
}

.marker:hover {
    transform: scale(1.1);
    z-index: 20;
}

.marker:hover img {
    filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.8)) 
            drop-shadow(0 0 25px rgba(255, 215, 0, 0.6)) 
            drop-shadow(0 0 35px rgba(255, 215, 0, 0.4));
    transition: filter 0.3s ease;
}

.marker img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* 確保觸控事件正常工作 */
    touch-action: manipulation;
}

/* Tooltip樣式 */
.tooltip {
    position: absolute;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 350px;
    width: auto;
    min-width: 280px;
    overflow: hidden;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    /* 確保觸控事件正常工作 */
    touch-action: manipulation;
}

.tooltip.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Tooltip 箭頭 */
.tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
    z-index: 1001;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

/* 當 tooltip 顯示在下方時，箭頭指向上方 */
.tooltip.tooltip-bottom::before {
    top: auto;
    bottom: -8px;
    border-bottom: none;
    border-top: 8px solid white;
}

.tooltip.tooltip-bottom::after {
    top: auto;
    bottom: -10px;
    border-bottom: none;
    border-top: 10px solid rgba(0, 0, 0, 0.1);
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.tooltip-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.tooltip-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    /* 確保觸控事件正常工作 */
    touch-action: manipulation;
}

.tooltip-close:hover {
    background-color: #e9ecef;
}

.tooltip-content {
    padding: 16px;
}

.tooltip-address {
    margin: 0 0 12px 0;
    color: #666;
    font-size: 13px;
    line-height: 1.4;
}

.tooltip-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tooltip-button {
    padding: 6px 12px;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    /* 確保觸控事件正常工作 */
    touch-action: manipulation;
}

.tooltip-button:hover {
    background: #0056b3;
}

.tooltip-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 響應式設計 - 手機版 */
@media (max-width: 768px) {
    .map-container {
        touch-action: none;
    }
    
    /* 手機版地圖縮放調整 - 顯示更大範圍 */
    .map-image {
        transform: scale(0.25); /* 手機版縮放到25%，顯示更大範圍 */
    }
    
    /* 手機版 Logo 調整 */
    .logo-container {
        top: 15px;
        left: 15px;
    }
    
    .logo {
        height: 32px;
    }
    
    /* 手機版 Tooltip 調整 */
    .tooltip {
        max-width: calc(100vw - 20px);
        min-width: 280px;
        font-size: 14px;
    }
    
    
    .tooltip-header {
        padding: 12px;
    }
    
    .tooltip-content {
        padding: 12px;
        text-align: center;
    }

    .tooltip-address {
        font-size: 14px;
        margin-bottom: 12px;
        text-align: center;
    }
    
    .tooltip-buttons {
        gap: 8px;
        justify-content: center;
    }
    
    /* 手機版載入提示調整 */
    .loading-content {
        padding: 30px 20px;
        margin: 0 20px;
    }
    
    .loading-spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
        margin-bottom: 15px;
    }
    
    .loading-text {
        font-size: 14px;
    }
}

/* 載入動畫 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-width: 300px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-text {
    margin: 0;
    font-size: 16px;
    color: #333;
    font-weight: 500;
}


/* 底部提示工具提示 */
.bottom-tooltip {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.5s ease-out;
    pointer-events: none;
    user-select: none;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 手機版底部提示調整 */
@media (max-width: 768px) {
    .bottom-tooltip {
        bottom: 15px;
        font-size: 13px;
        padding: 10px 16px;
        max-width: calc(100vw - 40px);
        text-align: center;
    }
}

/* 右側照片展示區塊 */
.photo-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.photo-panel.active {
    right: 0;
}

.photo-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.photo-panel-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.photo-panel-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.photo-panel-close:hover {
    background: #e9ecef;
    color: #333;
}

.photo-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.photo-gallery {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.photo-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.photo-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.photo-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.photo-item:hover img {
    transform: scale(1.05);
}

/* 照片遮罩層 */
.photo-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.photo-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 手機版照片面板調整 */
@media (max-width: 768px) {
    .photo-panel {
        width: 100vw;
        right: -100vw;
    }
    
    .photo-panel-header {
        padding: 15px;
    }
    
    .photo-panel-title {
        font-size: 16px;
    }
    
    .photo-panel-content {
        padding: 15px;
    }
    
    .photo-gallery {
        gap: 12px;
    }
}

/* 全螢幕照片模態框 */
.fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.fullscreen-modal.active {
    opacity: 1;
    visibility: visible;
}

.fullscreen-modal-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    font-size: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 3001;
}

.fullscreen-close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* 手機版全螢幕modal調整 */
@media (max-width: 768px) {
    .fullscreen-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .fullscreen-modal-content {
        max-width: 98vw;
        max-height: 98vh;
    }
}