/* ========================================
   MocNest 样式
   ======================================== */

:root {
    --primary: #ff4000;
    --primary-dark: #d83600;
    --accent: #5f25ba;
    --bg: #0a0a12;
    --surface: #141420;
    --surface-hover: #1d1d2e;
    --text: #e8e8f0;
    --text-muted: #9a9ab0;
    --border: #2a2a3e;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
    --glow: 0 0 12px rgba(255,64,0,.25);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== 首页 ========== */

.home-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.admin-entry {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: .8rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: .3rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all .15s;
}
.admin-entry:hover { color: var(--primary); border-color: var(--primary); }

.logo-area { text-align: center; margin-bottom: 3rem; }
.logo-area h1 { font-size: 3rem; margin-bottom: .25rem; }
.logo-area .subtitle { color: var(--text-muted); font-size: 1.1rem; }

.entry-area {
    display: flex;
    gap: 2rem;
    margin-bottom: 3rem;
}

.entry-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 2.5rem 3rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: all .2s;
    min-width: 200px;
}
.entry-card:hover {
    border-color: var(--primary);
    box-shadow: var(--glow);
    transform: translateY(-2px);
}
.entry-icon { font-size: 3rem; }
.entry-label { font-size: 1.25rem; font-weight: 600; }
.entry-desc { font-size: .875rem; color: var(--text-muted); }

.icp-footer {
    position: fixed;
    bottom: 1rem;
    left: 0;
    right: 0;
    text-align: center;
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: .8rem;
    line-height: 1.6;
}

/* ========== 按钮 ========== */

.btn {
    display: inline-block;
    padding: .5rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    background: var(--surface);
    color: var(--text);
    transition: all .15s;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--glow); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-block { display: block; width: 100%; }
.btn-danger { color: #ff6b6b; border-color: #ff6b6b; }
.btn-danger:hover { background: rgba(255,107,107,.12); }

/* ========== 顶部导航 ========== */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.top-bar .back-link { text-decoration: none; color: var(--text-muted); font-size: .9rem; }
.top-bar .page-title { font-size: 1.1rem; font-weight: 600; }
.top-bar-right { min-width: 80px; }

/* ========== MOC 展示页 ========== */

.model-layout {
    display: flex;
    height: calc(100vh - 52px);
}
.viewer-main {
    flex: 1;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.viewer-placeholder, .viewer-loaded {
    text-align: center;
    font-size: 1.1rem;
}
.viewer-placeholder p:first-child, .viewer-loaded p:first-child { font-size: 3rem; margin-bottom: .5rem; }

.model-sidebar {
    width: 320px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.5rem;
}
.model-sidebar h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.model-search {
    width: 100%;
    padding: .5rem .75rem;
    margin-bottom: .75rem;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
}
.model-search::placeholder { color: var(--text-muted); }
.model-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--glow);
}
.model-item-title mark.hl {
    background: transparent;
    color: var(--primary);
    font-weight: 600;
}

.model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .5rem;
}
.model-item-info { display: flex; align-items: center; gap: .5rem; }
.model-item-cover {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}
.model-item-actions { display: flex; gap: .25rem; }

.type-badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 99px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    font-size: .8rem;
}

/* ========== 登录页 ========== */

.login-container {
    max-width: 380px;
    margin: 5rem auto;
    text-align: center;
}
.login-container h1 { margin-bottom: 2rem; }
.login-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: left;
}
.login-back { margin-top: 1rem; }
.login-back a { color: var(--text-muted); text-decoration: none; font-size: .9rem; }

/* ========== 表单 ========== */

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .25rem; font-weight: 500; font-size: .9rem; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"] {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
}
.form-group input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-error { color: #ff6b6b; font-size: .85rem; margin-bottom: .75rem; }
.form-msg { padding: .5rem; border-radius: var(--radius); margin-bottom: .75rem; font-size: .85rem; }
.form-msg-error { background: rgba(255,107,107,.12); color: #ff6b6b; }
.form-msg-success { background: rgba(46,204,113,.12); color: #2ecc71; }

/* ========== 后台管理 ========== */

.admin-container { max-width: 1000px; margin: 0 auto; padding: 1.5rem; }
.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.admin-section h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.file-table { width: 100%; border-collapse: collapse; }
.file-table th, .file-table td {
    padding: .75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}
.file-table th { font-weight: 600; color: var(--text-muted); font-size: .8rem; }
.file-table .file-actions { display: flex; gap: .25rem; }
.file-table .file-date { color: var(--text-muted); font-size: .8rem; white-space: nowrap; }

.cover-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--bg);
}

.empty-hint { color: var(--text-muted); text-align: center; padding: 2rem 0; }

/* ========== 响应式 ========== */

/* 平板及以下 */
@media (max-width: 1024px) {
    .model-sidebar { width: 280px; }
}

/* 手机 */
@media (max-width: 768px) {
    /* 首页 */
    .entry-area { flex-direction: column; }
    .logo-area h1 { font-size: 2rem; }
    .logo-area { margin-bottom: 2rem; }
    .entry-card { padding: 2rem; min-width: 180px; }
    .entry-icon { font-size: 2.5rem; }
    .admin-entry { top: .5rem; right: .75rem; font-size: .75rem; padding: .25rem .6rem; }

    /* MOC 展示页：改为上下布局 */
    .model-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }
    .viewer-main {
        height: 50vh;
        min-height: 320px;
        flex: none;
    }
    .model-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        padding: 1rem;
        overflow-y: visible;
    }
    .model-item { padding: .6rem; }
    .model-item-actions .btn { padding: .25rem .5rem; font-size: .75rem; }
    /* 搜索框：16px 防止 iOS 聚焦自动缩放，加大触控区域 */
    .model-search { font-size: 1rem; padding: .6rem .75rem; }

    /* 顶部栏 */
    .top-bar { padding: .5rem 1rem; }
    .top-bar .page-title { font-size: 1rem; }

    /* 后台管理 */
    .admin-container { padding: 1rem; }
    .admin-section { padding: 1rem; }
    .form-row { flex-direction: column; gap: 0; }

    /* 表格：手机隐藏部分列 */
    .file-table th:nth-child(1),
    .file-table td:nth-child(1),
    .file-table th:nth-child(4),
    .file-table td:nth-child(4) {
        display: none;
    }
    .file-table th, .file-table td { padding: .5rem; font-size: .85rem; }
    .file-table .file-actions { flex-direction: column; gap: .25rem; }

    /* 登录页 */
    .login-container { margin: 3rem auto; padding: 0 1rem; }

    /* 上传表单按钮 */
    .upload-form .btn { width: 100%; }
}

/* 超小屏 */
@media (max-width: 400px) {
    .entry-card { min-width: 150px; padding: 1.5rem; }
    .viewer-main { height: 45vh; }
}
