/* ========== 全局变量 ========== */
:root {
    /* 新拟态基底 */
    --bg-color: #e0e5ec;
    --shadow-light: #ffffff;
    --shadow-dark: #a3b1c6;
    
    /* 玻璃拟态 */
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-bg-deep: rgba(255, 255, 255, 0.65);
    
    /* 主题色 */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* 文本 */
    --text-main: #374151;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    
    /* 尺寸 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    /* 过渡 */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== 基础重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ========== 玻璃拟态卡片 ========== */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 
        8px 8px 16px var(--shadow-dark),
        -8px -8px 16px var(--shadow-light);
    transition: var(--transition);
}

.glass-card:hover {
    transform: translateY(-6px) scale(1.005);
    box-shadow: 
        12px 12px 24px var(--shadow-dark),
        -12px -12px 24px var(--shadow-light);
}

/* ========== 新拟态按钮 ========== */
.neo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-color);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 
        5px 5px 10px var(--shadow-dark),
        -5px -5px 10px var(--shadow-light);
    transition: var(--transition);
    user-select: none;
}

.neo-btn:hover {
    color: var(--primary);
    transform: translateY(-2px);
}

.neo-btn:active {
    box-shadow: 
        inset 5px 5px 10px var(--shadow-dark),
        inset -5px -5px 10px var(--shadow-light);
    transform: translateY(0);
}

.neo-btn-primary {
    background: linear-gradient(145deg, var(--primary-light), var(--primary));
    color: #fff;
    box-shadow: 
        5px 5px 10px var(--shadow-dark),
        -5px -5px 10px var(--shadow-light);
}

.neo-btn-primary:hover {
    color: #fff;
    filter: brightness(1.1);
}

.neo-btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.neo-btn-danger {
    color: var(--danger);
}

/* ========== 新拟态输入框 ========== */
.neo-input {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-color);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    box-shadow: 
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
    transition: var(--transition);
}

.neo-input:focus {
    box-shadow: 
        inset 4px 4px 8px var(--shadow-dark),
        inset -4px -4px 8px var(--shadow-light);
    border-color: var(--primary);
}

textarea.neo-input {
    resize: vertical;
    min-height: 100px;
    font-family: "Consolas", "Monaco", monospace;
    line-height: 1.5;
}

/* ========== 登录页 ========== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 40px 36px;
}

.login-title {
    text-align: center;
    margin-bottom: 30px;
}

.login-title h1 {
    font-size: 24px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.login-title p {
    color: var(--text-secondary);
    font-size: 13px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.login-btn {
    width: 100%;
    height: 44px;
    font-size: 15px;
    margin-top: 10px;
}

/* ========== 后台布局 ========== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    padding: 20px 16px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    border-radius: 0;
    border-left: none;
    border-top: none;
    border-bottom: none;
}

.sidebar-logo {
    padding: 10px 12px 24px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.5);
    margin-bottom: 20px;
}

.sidebar-logo h2 {
    font-size: 18px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 6px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    color: var(--primary);
    box-shadow: 
        inset 3px 3px 6px var(--shadow-dark),
        inset -3px -3px 6px var(--shadow-light);
}

.sidebar-menu a .icon {
    margin-right: 10px;
    width: 18px;
    text-align: center;
}

/* 主内容区 */
.main-wrapper {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 顶部栏 */
.topbar {
    height: 60px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 99;
    border-radius: 0;
    border-top: none;
    border-right: none;
    border-left: none;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* 内容主体 */
.main-content {
    flex: 1;
    padding: 24px 30px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ========== 数据统计卡片 ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 24px;
}

.stat-card .stat-num {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ========== 通用表格 ========== */
.table-wrapper {
    padding: 20px;
    margin-bottom: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.5);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(255,255,255,0.3);
}

/* ========== 工具类 ========== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-10 { gap: 10px; }
.gap-16 { gap: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.w-full { width: 100%; }

/* ========== 组件编辑：工具栏与标签页 ========== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.5);
    align-items: center;
}

.toolbar-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toolbar-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-right: 4px;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.5);
}

.tab-item {
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.tab-item.active {
    color: var(--primary);
    background: rgba(255,255,255,0.3);
    box-shadow: inset 0 -2px 0 var(--primary);
}

.tab-pane {
    display: none;
    height: 100%;
}

.tab-pane.active {
    display: block;
}

.code-editor {
    width: 100%;
    height: 400px;
    padding: 12px;
    border: none;
    border-radius: var(--radius-md);
    background: #f1f5f9;
    color: #1e293b;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    outline: none;
    box-shadow: 
        inset 2px 2px 5px var(--shadow-dark),
        inset -2px -2px 5px var(--shadow-light);
}

/* ========== 预览容器 ========== */
.preview-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.5);
    margin-bottom: 12px;
}

.preview-header-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.preview-frame {
    flex: 1;
    width: 100%;
    border: none;
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: 
        inset 2px 2px 8px rgba(0,0,0,0.05),
        inset -2px -2px 8px rgba(255,255,255,0.8);
    min-height: 400px;
}

/* ========== 左右分栏布局 ========== */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1200px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
}

/* ========== 表单栅格 ========== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-grid .form-full {
    grid-column: 1 / -1;
}

/* ========== 标签复选组 ========== */
.tag-check-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-color);
    box-shadow: 
        inset 2px 2px 5px var(--shadow-dark),
        inset -2px -2px 5px var(--shadow-light);
}

.tag-check-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 13px;
}

/* ========== 单选组 ========== */
.radio-group {
    display: flex;
    gap: 20px;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* ========== 组件卡片网格 ========== */
.component-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.component-card {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.component-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.component-card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}

.component-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.component-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.component-tag {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    color: #fff;
    background: var(--primary);
}

.component-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.5);
    font-size: 12px;
    color: var(--text-light);
}

.component-card-actions {
    display: flex;
    gap: 10px;
}

/* 筛选栏 */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar .neo-input {
    width: auto;
    min-width: 200px;
}

/* ========== 详情页布局 ========== */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.detail-title h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 6px;
}

.detail-title .desc {
    color: var(--text-secondary);
    font-size: 13px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 20px;
}

.detail-meta .meta-item {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

/* 代码展示块 */
.code-block {
    position: relative;
}

.code-block .copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

.code-display {
    width: 100%;
    height: 420px;
    padding: 14px;
    border: none;
    border-radius: var(--radius-md);
    background: #f1f5f9;
    color: #1e293b;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    outline: none;
    box-shadow: 
        inset 2px 2px 5px var(--shadow-dark),
        inset -2px -2px 5px var(--shadow-light);
    white-space: pre;
    overflow: auto;
}

/* 备注块 */
.remark-box {
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(99, 102, 241, 0.05);
    border-left: 3px solid var(--primary);
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.remark-box h4 {
    color: var(--primary);
    font-size: 13px;
    margin-bottom: 6px;
}

/* 移动端适配 */
/* ========== 响应式移动端适配 ========== */
@media (max-width: 1024px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* 侧边栏：改为抽屉式 */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
        width: 240px;
    }
    .sidebar.mobile-show {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .main-content {
        padding: 16px;
    }
    
    /* 顶部菜单按钮 */
    .mobile-menu-btn {
        display: inline-flex !important;
    }
    
    /* 统计卡片 */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-card .stat-num {
        font-size: 24px;
    }
    
    /* 组件网格 */
    .component-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
    
    /* 表单左右布局改为上下 */
    .flex.gap-16 {
        flex-direction: column;
    }
    .glass-card[style*="width: 360px"] {
        width: 100% !important;
    }
    
    /* 表格横向滚动 */
    .table-wrapper {
        overflow-x: auto;
    }
    .data-table {
        min-width: 600px;
    }
    
    /* 工具栏换行 */
    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .toolbar-group {
        width: 100%;
        flex-wrap: wrap;
    }
    
    /* 代码编辑器高度减小 */
    .code-editor, .code-display {
        height: 300px;
    }
    
    /* 详情页头部 */
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .component-grid {
        grid-template-columns: 1fr;
    }
    .filter-bar .neo-input {
        width: 100%;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 12px;
    border: none;
    background: var(--bg-color);
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}

/* 遮罩层 */
.mobile-mask {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 199;
}
.mobile-mask.show {
    display: block;
}

/* ========== 顶部成功提示条 ========== */
.flash-msg {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 12px;
    z-index: 9999;
    animation: slideDown 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.flash-msg.success {
    background: rgba(16, 185, 129, 0.95);
    color: #fff;
}
.flash-msg.error {
    background: rgba(239, 68, 68, 0.95);
    color: #fff;
}
@keyframes slideDown {
    from { top: -50px; opacity: 0; }
    to { top: 20px; opacity: 1; }
}

/* 修复表格移动端横向溢出 */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-wrapper .data-table {
    width: max-content;
    min-width: 100%;
}

@media (max-width: 768px) {
    .glass-card.table-wrapper {
        padding: 12px;
    }
    .data-table th,
    .data-table td {
        padding: 10px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* 全局禁止横向溢出 */
body {
    overflow-x: hidden;
}

/* 玻璃卡片最大宽度限制 */
.glass-card {
    max-width: 100%;
    box-sizing: border-box;
}

/* 修复flex容器内按钮溢出：用flex:1替代width:100% */
.flex.gap-10 .neo-btn.w-full {
    width: auto !important;
    flex: 1;
}

/* 移动端所有固定宽度表单卡片自适应 */
@media (max-width: 768px) {
    .glass-card[style*="width: 360px"],
    .glass-card[style*="width: 400px"],
    .glass-card[style*="width: 500px"],
    .glass-card[style*="width: 600px"] {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* 颜色选择器行自适应 */
    .form-group .flex.gap-10 {
        flex-wrap: nowrap;
    }
    .form-group .flex.gap-10 .neo-input {
        flex: 1;
        min-width: 0;
    }

    /* 表格容器强制宽度限制，内部滚动 */
    .table-wrapper {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-wrapper .data-table {
        width: max-content;
        min-width: 100%;
    }

    /* 仪表盘统计卡片优化 */
    .stats-grid {
        gap: 12px;
    }
    .stat-card {
        padding: 16px;
        min-width: 0;
    }
}
/* 表格长文本单行省略 */
.td-ellipsis {
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .td-ellipsis {
        max-width: 145px;
    }
}
@media (max-width: 480px) {
    .td-ellipsis {
        max-width: 80px;
    }
}