/* ============================================================
   RDFZ 校园3D展示 - 全局样式表
   ============================================================ */

/* ---------- Reset & Base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: #1a1a2e;
    color: #eee;
    -webkit-user-select: none;
    user-select: none;
}

/* ---------- 加载画面 ---------- */
#loading-screen {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0f0f1a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.6s ease-out;
}
#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.15);
    border-top-color: #4fc3f7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-screen p {
    font-size: 18px;
    letter-spacing: 2px;
    color: #aaa;
}

/* ---------- 3D 画布容器 ---------- */
#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 1;
}
#canvas-container canvas {
    display: block;
}

/* ---------- 控制面板 ---------- */
#control-panel {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10;
    background: rgba(20, 20, 40, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 18px 22px;
    min-width: 240px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

#control-panel h2 {
    font-size: 18px;
    margin-bottom: 12px;
    font-weight: 600;
    letter-spacing: 1px;
}

.controls-hint {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
    font-size: 13px;
    color: #aaa;
}
.controls-hint span {
    display: block;
}

#control-panel button {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    padding: 10px 16px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: #ddd;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s;
    letter-spacing: 1px;
}
#control-panel button:hover {
    background: rgba(79, 195, 247, 0.2);
    border-color: #4fc3f7;
    color: #fff;
}

/* ---------- 帧率显示（FPS）- 位于控制面板底部 ---------- */
#fps-display {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    color: #4fc3f7;
    font-size: 13px;
    font-family: 'Consolas', 'Courier New', monospace;
    text-align: center;
    letter-spacing: 1px;
    border: 1px solid rgba(79, 195, 247, 0.2);
    transition: color 0.3s;
}
/* 低帧率警告：当 FPS 低于 30 时变色提示 */
#fps-display.low-fps {
    color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.3);
}

/* ---------- 悬浮标签（手动投影方案） ---------- */
.landmark-label {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    background: rgba(10, 10, 30, 0.88);
    color: #fff;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 1px;
    white-space: nowrap;
    border: 1px solid rgba(79, 195, 247, 0.45);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
    /* transform 由 JavaScript 动态设置，不在 CSS 中定义 */
    /* 使用 will-change 提示浏览器优化性能 */
    will-change: transform;
}
.landmark-label:hover {
    background: rgba(79, 195, 247, 0.25);
    border-color: #4fc3f7;
    color: #fff;
    box-shadow: 0 6px 24px rgba(79, 195, 247, 0.3);
}

/* ---------- 详情弹窗 ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: rgba(25, 25, 50, 0.95);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 0; /* 移除内边距，由左右子面板自行管理 */
    max-width: 1600px; /* 弹窗最大宽度（大屏更宽） */
    width: 96%; /* 几乎铺满整个页面宽度，仅留极小边距 */
    /* max-height 只设上限不设下限，内容少时弹窗不会撑高；加 min-height 保证一定撑到目标高度 */
    min-height: 88vh;
    max-height: 92vh; /* 几乎占满视口高度 */
    overflow: hidden; /* 左右面板各自滚动 */
    box-shadow: 0 16px 48px rgba(0,0,0,0.6);
    position: relative;
    animation: modalIn 0.35s ease;
    display: flex; /* 左右弹性布局 */
    flex-direction: row;
}
@keyframes modalIn {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 22px;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    line-height: 32px;
    text-align: center;
    z-index: 110; /* 确保在弹窗内容之上 */
}
.modal-close:hover { background: rgba(255, 80, 80, 0.6); }

.modal-image {
    width: 100%;
    height: 200px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 18px;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.modal-image .placeholder-icon {
    font-size: 60px;
    opacity: 0.5;
}

.modal-content h2 {
    font-size: 22px;
    margin-bottom: 8px;
    letter-spacing: 1px;
}
.modal-content > p {
    font-size: 15px;
    color: #bbb;
    line-height: 1.7;
    margin-bottom: 12px;
}
.modal-info {
    font-size: 13px;
    color: #999;
    line-height: 1.6;
}

/* ========== 弹窗左侧：3D模型预览区域 ========== */
.modal-left {
    width: 55%; /* 左侧占55%宽度（模型预览为主要内容，给更多空间） */
    min-width: 320px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.1); /* 分隔线 */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2); /* 深色背景衬托3D模型 */
    position: relative;
    overflow: hidden;
    border-radius: 16px 0 0 16px; /* 左侧圆角 */
}

/* 3D模型预览的 canvas 容器（由 JS 动态创建） */
.modal-model-preview {
    width: 100%;
    height: 100%;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 无模型时的占位提示 - 绝对定位于左侧容器内，避免错位到弹窗外 */
.modal-model-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #888;
    pointer-events: none; /* 不阻挡canvas的鼠标事件 */
    z-index: 5;
}
.modal-model-placeholder .placeholder-icon {
    font-size: 64px;
    opacity: 0.3;
}
.modal-model-placeholder .placeholder-text {
    font-size: 14px;
    opacity: 0.5;
}

/* 模型加载中提示 */
.modal-model-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    color: #aaa;
    font-size: 14px;
}
.modal-model-loading .spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
    margin-bottom: 0;
    margin-right: 10px;
}

/* ========== 弹窗右侧：图片和文字介绍 ========== */
.modal-right {
    width: 45%; /* 右侧占45%宽度（左侧模型预览为主，右侧为辅助信息） */
    flex-shrink: 1;
    padding: 28px 32px; /* 稍微增大右内边距 */
    overflow-y: auto; /* 内容过长时滚动 */
    max-height: 92vh; /* 与弹窗高度一致 */
}

/* 右侧中的图片区域 */
.modal-right .modal-image {
    width: 100%;
    height: 160px; /* 略小于原来的高度 */
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-right .modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.modal-right .modal-image .placeholder-icon {
    font-size: 48px;
    opacity: 0.5;
}

/* 右侧文字样式 - 调大字号以利用弹窗的更大空间 */
.modal-right h2 {
    font-size: 24px;
    margin-bottom: 10px;
    letter-spacing: 1px;
}
.modal-right > p {
    font-size: 16px;
    color: #bbb;
    line-height: 1.7;
    margin-bottom: 10px;
}
.modal-right .modal-info {
    font-size: 14px;
    color: #999;
    line-height: 1.6;
}

/* ---------- 响应式 ---------- */
@media (max-width: 700px) {
    #control-panel {
        top: 8px;
        left: 8px;
        padding: 12px 16px;
        min-width: 180px;
    }
    /* 小屏幕下弹窗改为上下布局 */
    .modal-content {
        flex-direction: column;
        max-width: 95%;
    }
    .modal-content {
        width: 95%;
    }
    .modal-left {
        width: 100%;
        height: 250px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 16px 16px 0 0;
    }
    .modal-model-preview {
        min-height: 250px;
    }
    .modal-right {
        width: 100%;
        max-height: 55vh;
        padding: 20px 16px;
    }
    .modal-close {
        top: 6px;
        right: 8px;
    }
}

/* ============================================================
   开发者面板样式 - 用于调整建筑物标签坐标
   ============================================================ */

/* 开发者面板容器 */
#dev-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 20;
    background: rgba(20, 20, 40, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 100, 100, 0.3);
    border-radius: 14px;
    padding: 16px 18px;
    width: 320px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: none; /* 默认隐藏，按快捷键显示 */
}
#dev-panel.visible {
    display: block;
}

#dev-panel h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #ff6b6b;
    font-weight: 600;
    letter-spacing: 1px;
    text-align: center;
}

#dev-panel .dev-hint {
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
    text-align: center;
    line-height: 1.5;
}

/* 每个地标的坐标编辑区 */
.dev-landmark-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.dev-landmark-item .landmark-name {
    font-size: 13px;
    font-weight: 500;
    color: #ddd;
    margin-bottom: 6px;
}

.dev-landmark-item .coord-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.dev-landmark-item .coord-row label {
    font-size: 11px;
    color: #999;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.dev-landmark-item .coord-row input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 12px;
    font-family: 'Consolas', monospace;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.dev-landmark-item .coord-row input:focus {
    border-color: #4fc3f7;
}

/* 开发者面板按钮 */
#dev-panel .dev-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

#dev-panel .dev-actions button {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #ddd;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.25s;
}

#dev-panel .dev-actions button:hover {
    background: rgba(79, 195, 247, 0.2);
    border-color: #4fc3f7;
    color: #fff;
}

#dev-panel .dev-actions button.danger:hover {
    background: rgba(255, 80, 80, 0.2);
    border-color: #ff5050;
    color: #ff6b6b;
}

/* 导出文本区域 */
#dev-panel .dev-export-area {
    width: 100%;
    height: 80px;
    margin-top: 10px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    color: #aaa;
    font-size: 11px;
    font-family: 'Consolas', monospace;
    resize: vertical;
    outline: none;
}
