/* ===== 全局重置 & 布局 ===== */
html,
body,
#c {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

/* ===== 加载进度条 ===== */
#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
    color: #fff;
    padding: 24px 40px;
    border-radius: 16px;
    z-index: 1000;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 220px;
    transition: opacity 0.5s ease;
}
#loading .spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #4fc3f7;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 14px;
    vertical-align: middle;
    flex-shrink: 0;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
#loading .status-text {
    vertical-align: middle;
    font-size: 17px;
    letter-spacing: 0.5px;
}
#loading .progress-bar {
    margin-top: 14px;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.10);
    overflow: hidden;
    width: 100%;
}
#loading .progress-bar .fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: linear-gradient(90deg, #4fc3f7, #29b6f6);
    transition: width 0.4s ease;
}
#loading .progress-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 6px;
}

/* ===== 信息面板 ===== */
#infoPanel {
    position: absolute;
    top: 20px;
    left: 20px;
    max-width: 360px;
    min-width: 200px;
    background: rgba(20, 22, 35, 0.94);
    backdrop-filter: blur(12px);
    color: #f0f0f0;
    border-left: 4px solid #4fc3f7;
    border-radius: 12px;
    padding: 18px 22px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
    z-index: 1001;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    opacity: 0;
    transform: translateY(-10px);
    font-size: 14px;
    line-height: 1.6;
}
#infoPanel.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
#infoPanel .title {
    font-size: 19px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 2px;
    padding-right: 28px;
}
#infoPanel .divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 8px 0;
}
#infoPanel .desc {
    color: #c8d0d8;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
}
#infoPanel .close-btn {
    position: absolute;
    top: 6px;
    right: 10px;
    background: none;
    border: none;
    color: #8899aa;
    font-size: 22px;
    cursor: pointer;
    pointer-events: auto;
    transition: 0.2s;
    line-height: 1;
}
#infoPanel .close-btn:hover {
    color: #fff;
}
.info-row {
    margin-top: 3px;
    font-size: 14px;
    color: #c8d0d8;
}
.info-row .label {
    color: #8899aa;
    margin-right: 6px;
}
.info-row .value {
    color: #e0e8f0;
}

/* ===== 顶部居中搜索栏 ===== */
#searchBar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1006;
    display: flex;
    gap: 6px;
    background: rgba(40, 45, 65, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    padding: 4px 6px 4px 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    min-width: 260px;
    max-width: 80%;
    transition: all 0.2s ease;
}
#searchBar input {
    flex: 1;
    background: transparent;
    border: none;
    color: #f0f0f0;
    font-size: 15px;
    padding: 8px 0;
    outline: none;
    font-family: inherit;
    min-width: 60px;
}
#searchBar input::placeholder {
    color: #8899aa;
}
#searchBar button {
    background: none;
    border: none;
    color: #f0f0f0;
    cursor: pointer;
    font-size: 18px;
    padding: 0 10px;
    transition: 0.2s;
    line-height: 1;
    border-radius: 20px;
}
#searchBar button:hover {
    color: #4fc3f7;
    background: rgba(255,255,255,0.05);
}

/* ===== 搜索结果列表 ===== */
#searchResults {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1007;
    background: rgba(20, 22, 35, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    max-height: 320px;
    min-width: 260px;
    max-width: 80%;
    overflow-y: auto;
    padding: 4px 0;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
    display: none;
    pointer-events: auto;
}
#searchResults.active {
    display: block;
}
#searchResults .result-item {
    padding: 8px 18px;
    cursor: pointer;
    color: #e8ecf0;
    font-size: 14px;
    transition: 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#searchResults .result-item:last-child {
    border-bottom: none;
}
#searchResults .result-item:hover {
    background: rgba(79, 195, 247, 0.15);
    color: #4fc3f7;
}
#searchResults .result-item .name {
    font-weight: 500;
}
#searchResults .result-item .sub {
    color: #8899aa;
    font-size: 12px;
    margin-left: 12px;
}
#searchResults .no-result {
    padding: 16px 18px;
    color: #8899aa;
    text-align: center;
    font-size: 14px;
}
#searchResults::-webkit-scrollbar {
    width: 6px;
}
#searchResults::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
}
#searchResults::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* ===== 工具栏（右侧） ===== */
#toolbar {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
#toolbar button {
    pointer-events: auto;
    background: rgba(40, 45, 65, 0.92);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f0f0f0;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 110px;
    text-align: left;
    font-family: inherit;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}
#toolbar button .icon {
    font-size: 18px;
    line-height: 1;
}
#toolbar button:hover {
    background: rgba(60, 70, 100, 0.92);
    border-color: #6fc3df;
}
#toolbar button.active {
    background: rgba(30, 144, 255, 0.65);
    border-color: #4fc3f7;
    box-shadow: 0 0 28px rgba(79, 195, 247, 0.18);
}

/* ===== 下载下拉 ===== */
#downloadPanel {
    position: absolute;
    top: 100px;
    right: 20px;
    background: rgba(40, 45, 65, 0.96);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 10px;
    padding: 6px 0;
    z-index: 1003;
    display: none;
    flex-direction: column;
    min-width: 150px;
    box-shadow: 0 8px 36px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}
#downloadPanel.active {
    display: flex;
}
#downloadPanel .sub-label {
    font-size: 12px;
    color: #8899aa;
    padding: 6px 20px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
#downloadPanel button {
    background: none;
    border: none;
    color: #f0f0f0;
    padding: 10px 20px;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: 0.15s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
}
#downloadPanel button:hover {
    background: rgba(79, 195, 247, 0.15);
    color: #4fc3f7;
}

/* ===== 关于弹窗 ===== */
#modalOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}
#modalOverlay.active {
    display: flex;
    pointer-events: auto;
}
#modalBox {
    background: rgba(28, 32, 48, 0.97);
    color: #e8ecf0;
    max-width: 600px;
    width: 92%;
    max-height: 80vh;
    border-radius: 16px;
    padding: 28px 32px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
    border-left: 6px solid #4fc3f7;
    position: relative;
    overflow-y: auto;
    font-family: inherit;
    line-height: 1.8;
    pointer-events: auto;
}
#modalBox h2 {
    margin-top: 0;
    color: #fff;
    font-weight: 500;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
}
#modalBox .close-modal {
    position: absolute;
    top: 10px;
    right: 16px;
    background: none;
    border: none;
    color: #8899aa;
    font-size: 28px;
    cursor: pointer;
    transition: 0.2s;
    line-height: 1;
}
#modalBox .close-modal:hover {
    color: #fff;
}
#modalBox .content {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 15px;
    color: #c8d0d8;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 12px;
    margin-top: 8px;
}
#modalBox .content::-webkit-scrollbar {
    width: 6px;
}
#modalBox .content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
}
#modalBox .content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* ===== Toast ===== */
#toast {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(6px);
    color: #f0f0f0;
    padding: 10px 28px;
    border-radius: 30px;
    font-size: 14px;
    z-index: 3000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
#toast.show {
    opacity: 1;
}

/* ===== 隐藏 Cesium 底部 ===== */
.cesium-viewer-bottom {
    display: none !important;
}

/* ===== 统计浮层（左下角） ===== */
#stats {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1004;
    background: rgba(20, 22, 35, 0.85);
    backdrop-filter: blur(6px);
    color: #e0e8f0;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    border-left: 3px solid #4fc3f7;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    user-select: none;
    display: flex;
    gap: 16px;
    line-height: 1.6;
}
#stats span {
    display: inline;
}
#stats .num {
    color: #4fc3f7;
    font-weight: 500;
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
    #searchBar {
        top: 10px;
        min-width: 180px;
        padding: 2px 4px 2px 12px;
        border-radius: 20px;
    }
    #searchBar input {
        font-size: 13px;
        padding: 6px 0;
    }
    #searchBar button {
        font-size: 15px;
        padding: 0 6px;
    }
    #searchResults {
        top: 60px;
        min-width: 160px;
        max-height: 240px;
    }
    #searchResults .result-item {
        font-size: 13px;
        padding: 6px 14px;
    }

    /* 手机端信息面板下移到 60px */
    #infoPanel {
        top: auto;
        bottom: 60px;
        left: 12px;
        right: 12px;
        max-width: none;
        min-width: unset;
        padding: 14px 16px;
        font-size: 13px;
        border-left-width: 3px;
    }
    #infoPanel .title {
        font-size: 16px;
        padding-right: 24px;
    }
    #infoPanel .close-btn {
        font-size: 20px;
        top: 4px;
        right: 6px;
    }

    #toolbar {
        top: 12px;
        right: 12px;
        gap: 8px;
        flex-direction: column;
        align-items: flex-end;
    }
    #toolbar button {
        min-width: 60px;
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 6px;
        gap: 4px;
    }
    #toolbar button .icon {
        font-size: 16px;
    }
    @media (max-width: 420px) {
        #toolbar button .btn-text {
            display: none;
        }
        #toolbar button {
            min-width: 44px;
            padding: 8px 10px;
            justify-content: center;
        }
        #toolbar button .icon {
            margin: 0;
        }
        #searchBar {
            min-width: 120px;
            padding: 2px 4px 2px 8px;
        }
        #searchBar input {
            font-size: 12px;
            min-width: 40px;
        }
        #searchResults {
            min-width: 120px;
            max-height: 180px;
        }
    }
    #downloadPanel {
        right: 12px;
        top: 80px;
        min-width: 120px;
    }
    #downloadPanel button {
        padding: 8px 16px;
        font-size: 13px;
    }
    #loading {
        padding: 18px 24px;
        font-size: 16px;
        max-width: 80%;
        min-width: unset;
    }
    #loading .spinner {
        width: 22px;
        height: 22px;
        margin-right: 10px;
        flex-shrink: 0;
    }
    #toast {
        font-size: 12px;
        padding: 8px 16px;
        bottom: 20px;
        white-space: normal;
        max-width: 80%;
        text-align: center;
    }
    #stats {
        font-size: 12px;
        padding: 4px 12px;
        bottom: 20px;
        left: 12px;
        gap: 12px;
    }

    @media (orientation: portrait) {
        /* 竖屏下保持 60px */
        #infoPanel {
            bottom: 60px;
        }
        #modalOverlay {
            padding: 0;
            align-items: center;
        }
        #modalBox {
            width: 85%;
            max-width: 85%;
            padding: 24px 28px;
            margin: 0 auto;
            border-radius: 16px;
        }
    }
    @media (orientation: landscape) {
        #infoPanel {
            bottom: auto;
            top: 12px;
        }
        #modalOverlay {
            padding: 3vh 5vw;
        }
        #modalBox {
            width: 92%;
            max-width: 600px;
        }
    }
}
@media (min-width: 641px) and (max-width: 1024px) {
    #toolbar button {
        min-width: 90px;
        padding: 8px 14px;
        font-size: 13px;
    }
    #infoPanel {
        max-width: 300px;
        padding: 14px 18px;
    }
    #searchBar {
        min-width: 220px;
    }
    #searchResults {
        min-width: 220px;
    }
}