/* ============================================================
 * 模型库弹层（工具栏「模型」按钮弹出，按钮在「保存」左边）
 * 结构来自室内场景编辑器的模型库，配色沿用线上编辑器的深色主题
 * ============================================================ */
/* 注意：不复用 .con_list —— 那个类由 eventManager 用 .show()/.hide() 控制，
 * 会给元素打上 inline 的 display:block，把这里的 flex 布局顶掉。
 * 显示/隐藏由 modelLib.js 自己加 .ml-open，保持 flex。
 * 定位用 fixed：弹层挂在 body 上，而 #openbar 是 overflow:hidden，
 * 放进去会被裁掉；left/top 由 JS 按 #modelLibBtn 的实际坐标算。 */
.model-lib {
    display: none;
    position: fixed;
    top: 42px;
    left: 0;
    z-index: 1200;
    width: 342px;
    height: 552px;
    max-height: calc(100vh - 76px);
    background: #26292b;
    border-radius: 2px;
    box-shadow: 0 2px 8px #000;
    box-sizing: border-box;
    color: #ccc;
    font-size: 12px;
    line-height: 1.4;
    flex-direction: column;
    overflow: hidden;
}

.model-lib.ml-open {
    display: flex;
}

/* 工具栏「模型」按钮：弹层展开时给个底色，看得出是「按下去」的状态 */
#modelLibBtn.active {
    background: rgba(49, 137, 243, .18);
    border-radius: 2px;
    font-weight: bold;
}

/* ---------- 头部 ---------- */
.model-lib .ml-head {
    position: relative;
    flex: 0 0 auto;
    height: 38px;
    line-height: 38px;
    padding: 0 12px;
    background: #1f2224;
    border-bottom: 1px solid #111;
}

.model-lib .ml-head-title {
    color: #eaeaea;
    font-size: 13px;
}

.model-lib .ml-help {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 18px;
    height: 18px;
    line-height: 17px;
    text-align: center;
    border: 1px solid #5a6064;
    border-radius: 50%;
    color: #8b9298;
    font-size: 12px;
    cursor: help;
}

.model-lib .ml-help:hover {
    color: #3189f3;
    border-color: #3189f3;
}

/* ---------- 搜索行 ---------- */
.model-lib .ml-search {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #1b1e20;
}

.model-lib .ml-search input {
    flex: 1 1 auto;
    height: 28px;
    padding: 0 8px 0 26px;
    background: #1b1e20;
    border: 1px solid #3f4548;
    border-radius: 2px;
    color: #ccc;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
}

.model-lib .ml-search input:focus {
    border-color: #3189f3;
}

.model-lib .ml-search-icon {
    position: absolute;
    left: 18px;
    top: 16px;
    width: 12px;
    height: 12px;
    pointer-events: none;
    opacity: .55;
    /* 放大镜：圆 + 手柄 */
    background:
        radial-gradient(circle at 5px 5px, transparent 3px, #aaa 3px, #aaa 4.2px, transparent 4.2px),
        linear-gradient(45deg, transparent 43%, #aaa 43%, #aaa 57%, transparent 57%);
    background-size: 12px 12px, 5px 5px;
    background-position: 0 0, 8px 8px;
    background-repeat: no-repeat;
}

.model-lib .ml-upload-entry {
    flex: 0 0 auto;
    margin-left: 8px;
    padding: 0 10px;
    height: 28px;
    line-height: 26px;
    border: 1px solid #3189f3;
    border-radius: 2px;
    color: #3189f3;
    cursor: pointer;
    user-select: none;
}

.model-lib .ml-upload-entry:hover {
    background: #3189f3;
    color: #fff;
}

/* ---------- 主体：左分类 + 右列表 ---------- */
.model-lib .ml-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.model-lib .ml-cats {
    flex: 0 0 auto;
    width: 66px;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: #212426;
    border-right: 1px solid #1b1e20;
    box-sizing: border-box;
    overflow-y: auto;
}

.model-lib .ml-cat {
    padding: 9px 0 7px;
    text-align: center;
    color: #9aa1a6;
    cursor: pointer;
    user-select: none;
}

.model-lib .ml-cat svg {
    display: block;
    width: 20px;
    height: 20px;
    margin: 0 auto 3px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.4;
}

.model-lib .ml-cat:hover {
    color: #d6dadd;
}

.model-lib .ml-cat.act {
    color: #3189f3;
    background: #2b3033;
}

.model-lib .ml-cat-name {
    font-size: 11px;
    word-break: keep-all;
}

.model-lib .ml-main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 6px 10px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* ---------- 二级分类（手风琴） ---------- */
.model-lib .ml-group {
    margin-bottom: 2px;
}

.model-lib .ml-group-title {
    display: flex;
    align-items: center;
    height: 30px;
    padding: 0 4px 0 8px;
    color: #c9ced2;
    cursor: pointer;
    user-select: none;
    border-radius: 2px;
}

.model-lib .ml-group-title:hover {
    background: #2e3336;
}

.model-lib .ml-group-title .ml-gname {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-lib .ml-group-title .ml-arrow {
    flex: 0 0 auto;
    width: 0;
    height: 0;
    margin-left: 6px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #7c848a;
    transition: transform .15s;
}

.model-lib .ml-group.open .ml-group-title .ml-arrow {
    transform: rotate(180deg);
}

.model-lib .ml-group-body {
    display: none;
    padding: 2px 0 6px;
}

.model-lib .ml-group.open .ml-group-body {
    display: block;
}

/* ---------- 模型网格 ---------- */
.model-lib .ml-grid {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.model-lib .ml-model {
    position: relative;
    width: calc((100% - 12px) / 3);
    margin: 0 6px 6px 0;
    height: 74px;
    background: #2f3437;
    border: 1px solid #3a4043;
    border-radius: 2px;
    cursor: pointer;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.model-lib .ml-model:nth-child(3n) {
    margin-right: 0;
}

.model-lib .ml-model:hover {
    border-color: #3189f3;
    background: #34393c;
}

/* 选中的那一个：留在面板里做反馈，用户想改选直接点别的 */
.model-lib .ml-model.picked {
    border-color: #3189f3;
    box-shadow: 0 0 0 1px #3189f3 inset;
    background: #2b3745;
}

.model-lib .ml-model img {
    max-width: 92%;
    max-height: 92%;
    pointer-events: none;
}

/* 缩略图缺失时用模型名兜底（服务端有个别模型只有 gltf 没有 png） */
.model-lib .ml-model.no-img::after {
    content: attr(data-name);
    padding: 4px 6px;
    color: #9aa1a6;
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
    word-break: break-all;
    max-height: 100%;
    overflow: hidden;
}

.model-lib .ml-model .ml-mname {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1px 3px;
    background: rgba(0, 0, 0, .6);
    color: #d6dadd;
    font-size: 11px;
    line-height: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-lib .ml-more {
    display: block;
    width: 100%;
    height: 26px;
    line-height: 24px;
    margin: 2px 0 4px;
    background: none;
    border: 1px dashed #454b4f;
    border-radius: 2px;
    color: #8b9298;
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

.model-lib .ml-more:hover {
    border-color: #3189f3;
    color: #3189f3;
}

/* ---------- 个人上传 ---------- */
.model-lib .ml-upload-tip {
    padding: 0 4px 8px;
}

.model-lib .ml-upload-btn {
    display: block;
    width: 100%;
    height: 34px;
    line-height: 32px;
    background: #2b3033;
    border: 1px dashed #4b5257;
    border-radius: 2px;
    color: #3189f3;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
}

.model-lib .ml-upload-btn:hover {
    border-color: #3189f3;
    background: #30363a;
}

.model-lib .ml-upload-tip p {
    margin: 8px 2px 0;
    color: #7c848a;
    line-height: 1.6;
}

/* ---------- 空态 / 提示 ---------- */
.model-lib .ml-empty {
    padding: 40px 10px;
    text-align: center;
    color: #7c848a;
}

/* 搜索词被自动放宽时的说明条（「汽车」没有匹配，已按「车」显示） */
.model-lib .ml-search-note {
    margin: 0 0 6px;
    padding: 6px 9px;
    background: #3a2f14;
    border: 1px solid #55431c;
    border-radius: 2px;
    color: #f0cd8a;
    font-size: 12px;
    line-height: 1.5;
}

.model-lib .ml-empty .ml-empty-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 0 12px;
    height: 26px;
    line-height: 24px;
    border: 1px solid #3189f3;
    border-radius: 2px;
    color: #3189f3;
    cursor: pointer;
}

/* ---------- 底部统计 ---------- */
.model-lib .ml-foot {
    position: relative;
    flex: 0 0 auto;
    height: 32px;
    line-height: 32px;
    padding: 0 10px;
    background: #1f2224;
    border-top: 1px solid #111;
    color: #9aa1a6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-lib .ml-foot .ml-picked {
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-lib .ml-foot .ml-picked .ml-picked-hint {
    margin-left: 6px;
    color: #6f777d;
}

.model-lib .ml-foot .ml-picked.has {
    color: #9aa1a6;
}

.model-lib .ml-foot .ml-picked b {
    color: #6fb3ff;
    font-weight: normal;
}

/* ============================================================
 * 模型上传弹窗（layer 内容）
 * ============================================================ */
.ml-upload-dlg {
    padding: 14px 16px 6px;
    color: #ccc;
    font-size: 12px;
}

.ml-upload-dlg .mlz-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.ml-upload-dlg .mlz-label {
    flex: 0 0 auto;
    width: 66px;
    text-align: right;
    padding-right: 10px;
    color: #9aa1a6;
}

.ml-upload-dlg .mlz-label .req {
    color: #f56c6c;
}

.ml-upload-dlg .mlz-ctrl {
    flex: 1 1 auto;
    min-width: 0;
}

.ml-upload-dlg input[type=text],
.ml-upload-dlg select {
    width: 100%;
    height: 30px;
    padding: 0 8px;
    background: #1b1e20;
    border: 1px solid #3f4548;
    border-radius: 2px;
    color: #ccc;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
}

.ml-upload-dlg input[type=text]:focus,
.ml-upload-dlg select:focus {
    border-color: #3189f3;
}

.ml-upload-dlg .mlz-drop {
    display: block;
    padding: 18px 12px;
    background: #1b1e20;
    border: 1px dashed #4b5257;
    border-radius: 2px;
    text-align: center;
    color: #8b9298;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.ml-upload-dlg .mlz-drop:hover,
.ml-upload-dlg .mlz-drop.over {
    border-color: #3189f3;
    background: #1f262b;
}

.ml-upload-dlg .mlz-drop .mlz-drop-main {
    color: #cfd4d8;
    font-size: 13px;
    line-height: 22px;
}

.ml-upload-dlg .mlz-drop .mlz-drop-main em {
    color: #3189f3;
    font-style: normal;
}

.ml-upload-dlg .mlz-file {
    display: none;
    margin-top: 6px;
    color: #3189f3;
    word-break: break-all;
}

.ml-upload-dlg .mlz-rules {
    margin: 0 0 10px 76px;
    padding: 8px 10px;
    background: #1f2224;
    border-radius: 2px;
    color: #8b9298;
    line-height: 1.7;
}

.ml-upload-dlg .mlz-rules b {
    color: #cfd4d8;
    font-weight: normal;
}

.ml-upload-dlg .mlz-rules .warn {
    color: #f0a742;
}

.ml-upload-dlg .mlz-footer {
    padding: 6px 0 10px;
    text-align: right;
}

.ml-upload-dlg .mlz-btn {
    display: inline-block;
    min-width: 76px;
    height: 30px;
    line-height: 28px;
    padding: 0 14px;
    border-radius: 2px;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    user-select: none;
}

.ml-upload-dlg .mlz-btn.cancel {
    border: 1px solid #4b5257;
    color: #b9bfc3;
}

.ml-upload-dlg .mlz-btn.cancel:hover {
    border-color: #6e7478;
}

.ml-upload-dlg .mlz-btn.ok {
    margin-left: 8px;
    background: #3189f3;
    border: 1px solid #3189f3;
    color: #fff;
}

.ml-upload-dlg .mlz-btn.ok:hover {
    background: #1f7ae8;
}

.ml-upload-dlg .mlz-btn.disabled {
    opacity: .6;
    cursor: not-allowed;
}
