/* 實價登錄地圖樣式表 */

/* 重置和基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', 'PingFang TC', Arial, sans-serif;
    background-color: #f8f9fa;
    overflow-x: hidden;
}

/* 標題列樣式 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1001;
}

.header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* 控制項樣式 */
.controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.control-group label {
    font-size: 0.8rem;
    color: #f1f3f4;
    font-weight: 500;
    text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.control-group select, .control-group input {
    padding: 0.5rem 0.8rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    min-width: 120px;
}

.control-group select:hover, .control-group input:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.control-group select:focus, .control-group input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* 地圖容器 */
.map-container {
    position: relative;
    height: calc(100vh - 80px);
    width: 100%;
    overflow: hidden;
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* 地圖標記樣式 */
.price-marker {
    background: white;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #333;
    border: 2px solid #fff;
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
    position: relative;
    text-align: center;
    min-width: 60px;
    transition: all 0.2s ease;
}

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

.price-marker.high-price {
    background: #ff6b6b;
    color: white;
    border-color: #ff5252;
}

.price-marker.medium-price {
    background: #ffd93d;
    color: #333;
    border-color: #ffcc02;
}

.price-marker.low-price {
    background: #51cf66;
    color: white;
    border-color: #37b24d;
}

/* 全域禁用瀏覽器預設tooltip */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 完全禁用title屬性產生的tooltip */
*[title] {
    position: relative;
}

*[title]:hover:before,
*[title]:hover:after {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* 針對Leaflet元素禁用tooltip */
.leaflet-container,
.leaflet-container *,
.leaflet-marker-pane,
.leaflet-marker-pane *,
.leaflet-overlay-pane,
.leaflet-overlay-pane * {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}
.leaflet-popup-content-wrapper {
    background: rgba(255,255,255,0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
}

.leaflet-popup {
    z-index: 9999 !important; /* 設定為最高層級 */
}

.leaflet-popup-pane {
    z-index: 9999 !important; /* 確保彈窗容器在最上層 */
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
}

/* 隱藏彈窗箭頭，避免出現多餘的小方塊 */
.leaflet-popup-tip-container {
    display: none !important; /* 隱藏箭頭容器 */
}

.leaflet-popup-tip {
    display: none !important; /* 隱藏箭頭 */
}

/* 完全禁用所有可能的tooltip */
.leaflet-marker-icon,
.leaflet-div-icon,
.custom-marker,
.custom-transaction-marker, 
.custom-collateral-marker,
.price-marker,
.transaction-marker,
.collateral-marker {
    pointer-events: auto !important;
    cursor: pointer;
}

/* 禁用所有可能產生tooltip的屬性和偽元素 */
.leaflet-marker-icon::before,
.leaflet-marker-icon::after,
.leaflet-div-icon::before,
.leaflet-div-icon::after,
.custom-marker::before,
.custom-marker::after,
.custom-transaction-marker::before,
.custom-transaction-marker::after,
.custom-collateral-marker::before,
.custom-collateral-marker::after {
    display: none !important;
    content: none !important;
}

/* 移除所有可能的title顯示 */
[title]:hover::before,
[title]:hover::after {
    display: none !important;
}

/* 標記子元素也完全禁用tooltip */
.custom-marker *,
.custom-transaction-marker *,
.custom-collateral-marker *,
.price-marker *,
.transaction-marker *,
.collateral-marker * {
    pointer-events: auto !important;
    cursor: pointer;
}

.price-popup {
    padding: 16px;
    border-radius: 12px;
    background: transparent;
    position: relative;
    z-index: 10000; /* 確保內容在最上層 */
}

/* 確保所有彈窗類型都有最高層級 */
.custom-popup,
.transaction-popup,
.collateral-popup-wrapper {
    z-index: 9999 !important;
}

.price-popup h4 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

.price-popup .price {
    font-size: 1.4rem;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 8px;
    text-align: center;
}

.price-popup .details {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.price-popup .details div {
    margin-bottom: 4px;
}

/* 圖例樣式 */
.legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255,255,255,0.95);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
    z-index: 1000;
    min-width: 220px;
    border: 1px solid rgba(255,255,255,0.3);
}

.legend h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #2c3e50;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
    padding: 4px 0;
    transition: all 0.2s ease;
}

.legend-item:hover {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 6px;
    padding-left: 4px;
}

.legend-color {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 載入動畫 */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.95);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
    z-index: 2000;
    text-align: center;
    color: #2c3e50;
    font-weight: 500;
}

.loading::before {
    content: "";
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
    display: block;
}

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

/* 區域多邊形樣式 */
.area-polygon {
    fill-opacity: 0.6;
    stroke-width: 2;
    stroke: #fff;
    transition: all 0.3s ease;
}

.area-polygon:hover {
    fill-opacity: 0.8;
    stroke-width: 3;
    stroke: #333;
}

/* 地圖控制項覆寫 */
.leaflet-control-zoom {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.leaflet-control-zoom a {
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(10px);
    color: #333;
    font-weight: bold;
    transition: all 0.2s ease;
}

.leaflet-control-zoom a:hover {
    background: rgba(102, 126, 234, 0.9);
    color: white;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
    }
    
    .control-group {
        min-width: 140px;
    }
    
    .legend {
        bottom: 10px;
        right: 10px;
        left: 10px;
        min-width: auto;
        padding: 15px;
    }
    
    .legend-item {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }
    
    .legend-color {
        width: 20px;
        height: 20px;
        margin-right: 10px;
    }
    
    .map-container {
        height: calc(100vh - 120px);
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.3rem;
    }
    
    .controls {
        gap: 0.8rem;
    }
    
    .control-group select, .control-group input {
        min-width: 100px;
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
    
    .price-marker {
        font-size: 0.75rem;
        padding: 4px 8px;
        min-width: 50px;
    }
}

/* 擴展擔保品類別標記樣式 */
.collateral-marker {
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    color: white;
    text-align: center;
    border: 2px solid rgba(255,255,255,0.8);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    min-width: 60px;
    position: relative;
}

.collateral-marker:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

/* 住宅類型標記 */
.collateral-marker.house {
    background: linear-gradient(135deg, #2E8B57 0%, #3CB371 100%);
    border-color: #228B22;
}

.collateral-marker.house::before {
    content: "🏠";
    font-size: 14px;
    margin-right: 4px;
}

/* 餘屋標記 */
.collateral-marker.remaining {
    background: linear-gradient(135deg, #4169E1 0%, #6495ED 100%);
    border-color: #0000CD;
}

.collateral-marker.remaining::before {
    content: "🏘️";
    font-size: 14px;
    margin-right: 4px;
}

/* 土地標記 */
.collateral-marker.land {
    background: linear-gradient(135deg, #8B4513 0%, #CD853F 100%);
    border-color: #A0522D;
}

.collateral-marker.land::before {
    content: "🗺️";
    font-size: 14px;
    margin-right: 4px;
}

/* 廠房標記 */
.collateral-marker.factory {
    background: linear-gradient(135deg, #696969 0%, #808080 100%);
    border-color: #2F4F4F;
}

.collateral-marker.factory::before {
    content: "🏭";
    font-size: 14px;
    margin-right: 4px;
}

/* 商辦標記 */
.collateral-marker.office {
    background: linear-gradient(135deg, #FF6347 0%, #FF7F50 100%);
    border-color: #DC143C;
}

.collateral-marker.office::before {
    content: "🏢";
    font-size: 14px;
    margin-right: 4px;
}

/* 餐廳標記 */
.collateral-marker.restaurant {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border-color: #FF8C00;
}

.collateral-marker.restaurant::before {
    content: "🍽️";
    font-size: 14px;
    margin-right: 4px;
}

/* 店面標記 */
.collateral-marker.store {
    background: linear-gradient(135deg, #FF69B4 0%, #FF1493 100%);
    border-color: #DC143C;
}

.collateral-marker.store::before {
    content: "🏪";
    font-size: 14px;
    margin-right: 4px;
}

/* 擔保品詳細資訊彈窗 */
.collateral-popup {
    padding: 18px;
    border-radius: 12px;
    background: transparent;
    min-width: 320px;
    font-family: 'Microsoft JhengHei', Arial, sans-serif;
}

.collateral-popup h4 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 6px;
}

.collateral-popup .customer-info {
    background: rgba(52, 152, 219, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    margin-bottom: 12px;
}

.collateral-popup .customer-name {
    font-size: 1.0rem;
    font-weight: bold;
    color: #2980b9;
}

.collateral-popup .customer-id {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.collateral-popup .price-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(46, 204, 113, 0.1);
    border-radius: 6px;
    border-left: 4px solid #27ae60;
}

.collateral-popup .unit-price {
    text-align: center;
}

.collateral-popup .unit-price .label {
    font-size: 0.8rem;
    color: #7f8c8d;
    display: block;
}

.collateral-popup .unit-price .value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #e74c3c;
}

.collateral-popup .total-price .label {
    font-size: 0.8rem;
    color: #7f8c8d;
    display: block;
}

.collateral-popup .total-price .value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #27ae60;
}

.collateral-popup .property-details {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.6;
}

.collateral-popup .property-details .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px dotted #eee;
}

.collateral-popup .property-details .detail-row:last-child {
    border-bottom: none;
}

.collateral-popup .property-details .label {
    color: #34495e;
    font-weight: 600;
    margin-right: 10px;
}

.collateral-popup .property-details .value {
    color: #2c3e50;
}

.collateral-popup .collateral-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
    background: #3498db;
}

.collateral-popup .notes {
    margin-top: 10px;
    padding: 8px;
    background: rgba(241, 196, 15, 0.1);
    border-left: 4px solid #f1c40f;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #7f8c8d;
    font-style: italic;
}

.collateral-popup .location-info {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 8px;
}

/* 擔保品類別圖例 */
.collateral-legend {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-size: 12px;
    max-width: 200px;
}

.collateral-legend h4 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 14px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 4px;
}

.collateral-legend .legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    padding: 2px 0;
}

.collateral-legend .legend-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(255,255,255,0.8);
}

/* 詳細交易彈窗樣式 */
.transaction-popup {
    padding: 16px;
    border-radius: 12px;
    background: transparent;
    min-width: 280px;
}

.transaction-popup h4 {
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 1.0rem;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.transaction-popup .community {
    color: #7f8c8d;
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-style: italic;
}

.transaction-popup .price-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 6px;
    border-left: 4px solid #3498db;
}

.transaction-popup .unit-price {
    font-size: 1.2rem;
    font-weight: bold;
    color: #e74c3c;
}

.transaction-popup .total-price {
    font-size: 0.9rem;
    color: #7f8c8d;
}

.transaction-popup .property-details {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.6;
}

.transaction-popup .property-details div {
    margin-bottom: 4px;
    padding: 2px 0;
    border-bottom: 1px dotted #eee;
}

.transaction-popup .property-details div:last-child {
    border-bottom: none;
}

.transaction-popup .property-details strong {
    color: #34495e;
    font-weight: 600;
    margin-right: 5px;
}