* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f5f5f5;
    overflow: hidden; /* 防止滾動 */
}

/* 當面板在行動裝置上打開時，為 body 添加此類 */
body.panel-is-open {
    overflow: hidden;
}

/* 头部导航 */
.header {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: white;
    padding: 6px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(238, 90, 36, 0.4);
}

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.3);
}

/* 主要内容区 */
.main-container {
    display: flex;
    height: calc(100vh - 58px); /* 減去頭部高度 */
    position: relative;
}

/* 左侧控制面板 */
.control-panel {
    width: 350px;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    transition: transform 0.3s ease-in-out;
    z-index: 1000;
    position: relative; /* 為了關閉按鈕的定位 */
}

.control-section {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.control-section:last-child {
    border-bottom: none;
}

.control-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-section h3::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, #ff6b6b, #ee5a24);
    border-radius: 2px;
}

/* 地圖/圖層選擇器 */
.map-provider-selector, .layer-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.map-provider-label, .layer-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    padding: 8px;
    border: 1px solid #eee;
    border-radius: 6px;
    transition: background-color 0.2s;
}
.layer-label:has(input:checked) {
    background-color: #fff3cd;
    border-color: #ffd700;
}
.map-provider-label input[type="radio"], .layer-label input[type="radio"] {
    margin-right: 8px;
    transform: scale(1.2);
}

.search-box {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.search-box:focus {
    outline: none;
    border-color: #ff6b6b;
}

.measurement-mode {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mode-btn.active {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border-color: #ee5a24;
}

.toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 20px 0;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 25px;
    background: #ddd;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.active {
    background: #ff6b6b;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2.5px;
    left: 2.5px;
    transition: transform 0.3s;
}

.toggle-switch.active::after {
    transform: translateX(25px);
}

/* 测量结果显示 */
.result-box {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-top: 15px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.result-label {
    color: #666;
    font-size: 14px;
}

.result-value {
    font-weight: bold;
    color: #333;
    font-size: 16px;
    text-align: right;
}

.result-highlight {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 1px solid #ffd700;
}

/* 地图容器 */
.map-container {
    flex: 1;
    position: relative;
    background: #e0e0e0;
    overflow: hidden;
}

.map-container.crosshair-mode {
    cursor: crosshair !important;
}

#map {
    width: 100%;
    height: 100%;
    background-color: #eee;
}

#map.crosshair-mode,
#map.crosshair-mode .leaflet-grab {
    cursor: crosshair !important;
}

/* Leaflet Marker Label樣式 */
.leaflet-marker-label {
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #aaa;
    border-radius: 5px;
    color: #333;
    font-weight: bold;
    text-align: center;
    line-height: 28px;
    font-size: 18px;
}


/* 风水罗盘覆盖层 */
.compass-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 401; /* 比Leaflet的控件高 */
    display: flex;
    justify-content: center;
    align-items: center;
}

.compass-overlay.hidden {
    display: none;
}

.compass-container {
    position: relative;
    width: min(90vw, 90vh - 70px);
    height: min(90vw, 90vh - 70px);
    max-width: 600px;
    max-height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.compass-image {
    width: 100%;
    height: 100%;
    opacity: 0.7;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

.reference-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1px;
    height: 100%;
    transform-origin: center center; 
    transform: translate(-50%, -50%) rotate(0deg);
    z-index: 2;
}

.reference-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    background: red;
    transform: translateX(-50%);
}

.reference-line::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 50%;
    width: 20px;
    height: 2px;
    background: red;
    transform: translateX(-50%);
}

.line-arrow {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 12px solid red;
    filter: drop-shadow(0 0 1px rgba(0,0,0,0.5));
}

/* 中心十字准星 */
.center-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 3;
}

.center-crosshair::before,
.center-crosshair::after {
    content: '';
    position: absolute;
    background: #333;
    opacity: 0.8;
}

.center-crosshair::before {
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    transform: translateY(-50%);
}

.center-crosshair::after {
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    transform: translateX(-50%);
}

.center-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: #333;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 4;
}


/* 移动端菜单按钮 */
.mobile-menu-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px; 
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1200;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s, transform 0.3s;
}

body.panel-is-open .mobile-menu-btn {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}

/* 面板關閉按鈕 */
.close-panel-btn {
    display: none; /* 預設在桌面版隱藏 */
    position: absolute;
    top: 10px;
    right: 15px;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: #888;
    font-size: 24px;
    line-height: 30px;
    cursor: pointer;
    z-index: 1600;
}

.close-panel-btn:hover {
    color: #333;
}

/* 预约表单 */
.appointment-form {
    display: none;
}

.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-size: 14px;
}

.form-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-input:focus {
    outline: none;
    border-color: #ff6b6b;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.submit-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(238, 90, 36, 0.4);
}

.loader {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #ff6b6b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2000;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 控制項說明文字樣式 */
.control-note {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
    line-height: 1.4;
}

/* 全螢幕模式下的樣式 */
.main-container:-webkit-full-screen { height: 100%; }
.main-container:-moz-full-screen { height: 100%; }
.main-container:-ms-fullscreen { height: 100%; }
.main-container:fullscreen { height: 100%; }

/* 在全螢幕模式下，隱藏頭部和行動裝置按鈕 */
body:has(.main-container:fullscreen) .header,
body:has(.main-container:fullscreen) .mobile-menu-btn {
    display: none;
}

/* 地圖內嵌控件樣式 */
.map-controls-container {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 401; /* 與羅盤同級，高於地圖瓦片 */
    display: flex;
    flex-direction: column;
    gap: 1px; /* 按鈕之間留1px的縫隙 */
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    overflow: hidden; /* 確保圓角生效 */
}

.map-control-btn {
    width: 36px;
    height: 36px;
    border: none;
    background-color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    transition: background-color 0.2s, color 0.2s;
}

.map-control-btn:hover {
    background-color: #f0f0f0;
}

.map-control-btn.active {
    background-color: #3385ff;
    color: white;
}

.map-control-btn svg {
    pointer-events: none; /* 讓點擊事件穿透SVG到按鈕 */
}

/* 全螢幕圖示切換 */
.fullscreen-icon-exit {
    display: none;
}
body.is-fullscreen .fullscreen-icon-enter {
    display: none;
}
body.is-fullscreen .fullscreen-icon-exit {
    display: block;
}


/* 響應式設計 (Responsive Design) */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 10px;
    }
    
    .control-panel {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1500;
        width: 300px; 
    }
    
    .control-panel.show {
        transform: translateX(0);
    }
    
    .mobile-menu-btn {
        display: flex; 
    }

    .close-panel-btn {
        display: block; /* 在行動裝置上顯示關閉按鈕 */
    }
}
