@charset "UTF-8";

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft JhengHei", "微軟正黑體", Arial, sans-serif;
}

body {
    overflow: hidden;
}

/* Map Container */
#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* 桌機版縮放控制按鈕 - 放在公司行號面板旁 */
.leaflet-control-zoom {
    position: fixed !important;
    left: 355px !important;
    top: 145px !important;
    border: none !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2) !important;
    border-radius: 8px !important;
}

.leaflet-control-zoom a {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
    background-color: white !important;
    color: #333 !important;
}

.leaflet-control-zoom a:hover {
    background-color: #4CAF50 !important;
    color: white !important;
}

/* Floating Search Panel */
#floating-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    width: 320px;
    max-width: 90vw;
}

#county-select {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.search-container {
    display: flex;
    gap: 5px;
}

#search-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.search-button {
    padding: 10px 15px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.search-button:hover {
    background-color: #45a049;
}

/* Company List Panel (獨立面板，與 floating-panel 間距 15px) */
#company-list-container {
    position: absolute;
    top: 145px;
    left: 10px;
    bottom: 20px;
    z-index: 1000;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    width: 320px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
}

.list-header {
    font-weight: bold;
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
    background: #f5f5f5;
    padding: 10px;
    border-radius: 6px;
    margin: 0 0 10px 0;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

#company-list {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
}

.company-item {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 10px;
    transition: background-color 0.2s ease;
}

.company-item:hover {
    background-color: #e8f5e9;
}

.company-item:last-child {
    border-bottom: none;
}

.company-item .cat-icon {
    width: 20px;
    flex-shrink: 0;
    font-size: 16px;
    text-align: center;
    margin-top: 2px;
}

.company-item .company-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.company-item .name {
    font-weight: bold;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-item .business {
    font-size: 11px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* Alerts */
#alert-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 5px;
    z-index: 1000;
    display: none;
    font-size: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 80%;
}

/* Cluster Info Popup */
.cluster-info {
    background-color: white;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    max-width: 350px;
    font-size: 14px;
    line-height: 1.4;
}

.cluster-info h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 8px;
    margin-bottom: 10px;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
}

.cluster-info p {
    margin: 8px 0;
}

.cluster-info a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: bold;
    font-size: 18px;
    display: block;
    margin-bottom: 8px;
}

.cluster-info a:hover {
    text-decoration: underline;
}

/* Popup 吸引點擊按鈕 */
.popup-action {
    margin-top: 15px;
    padding-top: 10px;
    text-align: center;
}

.popup-link-btn {
    display: inline-block !important;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white !important;
    padding: 8px 16px !important;
    border-radius: 20px;
    font-size: 14px !important;
    font-weight: bold;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
    transition: all 0.3s ease;
}

.popup-link-btn:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.5);
    text-decoration: none !important;
}

.popup-link-btn i {
    margin-right: 5px;
}

.cuscat-tag {
    display: inline-block;
    background-color: #2196F3;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin-top: 8px;
}

/* Company name label below marker (clickable) */
.company-label {
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    cursor: pointer;
    text-align: center;
    transform: translateX(-50%);
    left: 50% !important;
}

.company-label:hover {
    background-color: #4CAF50;
    color: white;
    border-color: #45a049;
}

/* Loading Spinner */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 8px;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-align: center;
    border: 2px solid #4CAF50;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Map Controls */
.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.control-button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 5px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.control-button:hover {
    background-color: #e9ecef;
}

.control-button:last-child {
    margin-bottom: 0;
}

/* Debug Panel */
.debug-panel {
    position: absolute;
    top: 180px; /* Position below map controls */
    right: 0;
    bottom: 50px; /* Space for status bar */
    left: auto;
    z-index: 900;
    background: rgba(255, 255, 255, 0.98);
    padding: 10px;
    border-radius: 0;
    font-size: 12px;
    width: 350px;
    max-width: 90vw;
    max-height: none;
    overflow-y: auto;
    display: block;
    border-left: 1px solid #ccc;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
}

/* Status Indicators */
.company-count {
    position: absolute;
    top: 10px;
    right: 150px;
    z-index: 1000;
    background: rgba(76, 175, 80, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
}

.api-status {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(255, 193, 7, 0.9);
    color: #333;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

/* 右下角位置資訊 (測試用) */
/* 右下角位置資訊 (測試用) - 已隱藏
.location-info {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(33, 150, 243, 0.95);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    max-width: 200px;
    line-height: 1.4;
    display: none; 
} */

/* Responsive Design */
@media (max-width: 768px) {
    /* 手機版縮放控制 - 放在公司行號面板上方 */
    .leaflet-control-zoom {
        position: fixed !important;
        left: 10px !important;
        top: auto !important;
        bottom: 170px !important;
        right: auto !important;
        z-index: 1001 !important;
    }
    
    .leaflet-control-zoom a {
        width: 32px !important;
        height: 32px !important;
        line-height: 32px !important;
        font-size: 16px !important;
    }
    
    /* 搜尋面板：單行水平排列 */
    #floating-panel {
        width: calc(100% - 20px);
        left: 10px;
        right: 10px;
        top: 10px;
        padding: 8px;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 5px;
    }
    
    #floating-panel #county-select {
        width: auto;
        min-width: 70px;
        max-width: 80px;
        padding: 8px 4px;
        margin-bottom: 0;
        font-size: 14px;
        flex-shrink: 0;
    }
    
    #floating-panel .search-container {
        flex: 1;
        display: flex;
        gap: 5px;
        min-width: 0;
    }
    
    #floating-panel #search-input {
        flex: 1;
        padding: 8px;
        font-size: 14px;
        min-width: 0;
    }
    
    #floating-panel .search-button {
        padding: 8px 12px;
        font-size: 14px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* 手機版公司行號：改為底部固定面板 */
    #company-list-container {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        background: white;
        border-top: 2px solid #4CAF50;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        z-index: 1100;
        max-height: 40vh;
        max-width: 100%;
        transition: max-height 0.3s ease;
    }
    
    #company-list-container.collapsed {
        max-height: 50px;
    }
    
    #company-list-container .list-header {
        padding: 12px 15px;
        margin: 0;
        background: linear-gradient(135deg, #4CAF50, #45a049);
        color: white;
        font-size: 14px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        border-radius: 14px 14px 0 0;
    }
    
    #company-list-container .list-header::after {
        content: '▼';
        font-size: 12px;
        transition: transform 0.3s ease;
    }
    
    #company-list-container.collapsed .list-header::after {
        transform: rotate(180deg);
    }
    
    #company-list {
        max-height: calc(40vh - 50px);
        overflow-y: auto;
        padding: 5px 0;
    }
    
    #company-list-container.collapsed #company-list {
        display: none;
    }
    
    .company-item {
        padding: 12px 15px;
        font-size: 14px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .company-item .name {
        font-size: 15px;
    }
    
    .company-item .business {
        font-size: 13px;
    }
    
    .company-item:active {
        background-color: #e8f5e9;
    }
    
    .company-item .cat-dot {
        width: 12px;
        height: 12px;
    }
    
    .map-controls {
        top: auto;
        bottom: 10px;
        right: 10px;
    }
    
    .debug-panel {
        bottom: 60px;
        max-width: calc(100% - 20px);
    }
    
    .company-count {
        top: 80px;
        left: 10px;
        right: auto;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .api-status {
        top: 80px;
        right: 10px;
        bottom: auto;
        font-size: 11px;
        padding: 6px 10px;
    }
    
    /* 地圖下方留空間給公司行號 */
    #map {
        bottom: 50px;
    }
}
