/* ============================================
   后台管理样式
   ============================================ */

/* ============================================
   登录页
   ============================================ */
.admin-login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d1b4e 100%);
}
.admin-login-box {
    background: #fff;
    border-radius: 16px;
    padding: 48px 40px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.admin-login-box h1 { text-align: center; margin-bottom: 8px; font-size: 24px; }
.admin-login-box .sub { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }
.back-link { display: block; text-align: center; margin-top: 20px; color: var(--text-muted); text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--primary); }

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

.admin-sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #cbd5e1;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 50;
}
.sidebar-logo {
    padding: 22px 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-nav {
    padding: 12px 0;
    display: flex;
    flex-direction: column;
}
.sidebar-nav a {
    padding: 12px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all .2s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-nav a.active {
    background: rgba(102,126,234,0.15);
    color: #fff;
    border-left-color: var(--primary);
}

.admin-main {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
}

/* ============================================
   顶栏
   ============================================ */
.admin-topbar {
    background: #fff;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.admin-info { font-size: 14px; color: var(--text-muted); margin-right: 8px; }

/* ============================================
   通用卡片和内容
   ============================================ */
.admin-content { padding: 28px; }
.admin-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.admin-card h3 { font-size: 16px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border); color: var(--text); }

.admin-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.admin-form .form-actions { margin-top: 16px; display: flex; gap: 12px; }

/* ============================================
   工具栏
   ============================================ */
.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.admin-toolbar .toolbar-title { font-size: 16px; font-weight: 600; }
.admin-toolbar .toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 列表勾选列 */
.admin-table .check-col { width: 38px; text-align: center; }
.admin-table .check-col input { width: auto; margin: 0; cursor: pointer; }
.search-form { display: flex; gap: 8px; }
.search-form input {
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    width: 260px;
}
.search-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

/* ============================================
   表格
   ============================================ */
.admin-table th, .admin-table td { font-size: 13px; padding: 10px 12px; }
.admin-table code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #475569;
}

/* ============================================
   统计卡片
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #dcfce7; }
.stat-icon.orange { background: #fed7aa; }
.stat-icon.purple { background: #ede9fe; }
.stat-info strong { display: block; font-size: 24px; font-weight: 700; }
.stat-info span { color: var(--text-muted); font-size: 13px; }

.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ============================================
   分页
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}
.page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    transition: all .2s;
}
.page-num:hover { border-color: var(--primary); color: var(--primary); }
.page-num.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ============================================
   移动端汉堡按钮 & 侧边抽屉菜单
   ============================================ */
.admin-menu-toggle {
    display: none;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 19px;
    line-height: 1.2;
    color: var(--text);
    cursor: pointer;
}
.admin-menu-toggle:active { background: var(--bg); }

/* 遮罩 */
.admin-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    z-index: 60;
}
.admin-mask.show { display: block; }

/* 侧边抽屉 */
.admin-mobile-menu {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    max-width: 78%;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #cbd5e1;
    overflow-y: auto;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 6px 0 24px rgba(0,0,0,.2);
}
.admin-mobile-menu.open { transform: translateX(0); }

.admin-mobile-menu .mm-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 14px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.admin-mobile-menu .mm-logo { font-size: 17px; font-weight: 700; color: #fff; }
.admin-mobile-menu .mm-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}
.admin-mobile-menu .mm-close:hover { color: #fff; }

.admin-mobile-menu a,
.admin-mobile-menu .mm-logout {
    display: block;
    width: 100%;
    padding: 13px 20px;
    text-align: left;
    font-size: 15px;
    font-family: inherit;
    color: #94a3b8;
    text-decoration: none;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all .2s;
}
.admin-mobile-menu a:hover,
.admin-mobile-menu .mm-logout:hover { background: rgba(255,255,255,.05); color: #fff; }
.admin-mobile-menu a.active {
    color: #fff;
    background: rgba(102,126,234,.15);
    border-left-color: var(--primary);
    font-weight: 600;
}
.admin-mobile-menu .mm-divider { height: 8px; background: rgba(255,255,255,.04); }

/* ============================================
   标签页
   ============================================ */
.admin-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    background: #fff;
    padding: 6px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.admin-tab {
    border: none;
    background: transparent;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .2s;
}
.admin-tab:hover { color: var(--primary); background: rgba(102,126,234,.08); }
.admin-tab.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}
.admin-tab-panel[hidden] { display: none; }

/* 开关关闭时隐藏的参数区 */
.toggle-params[hidden] { display: none; }
.toggle-params {
    padding-top: 6px;
    border-top: 1px dashed var(--border);
}
.checkbox-group { display: flex; gap: 18px; flex-wrap: wrap; padding: 6px 0; }
.checkbox-item { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.checkbox-item input { width: auto; margin: 0; }

/* 用户列表头像 */
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.user-avatar-sm-default {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

/* 解析接口列表 */
.parse-api-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.parse-api-head h4 { font-size: 15px; font-weight: 600; }
.form-tip { display: block; margin: 0 0 14px; color: var(--text-muted); font-size: 13px; line-height: 1.6; }

/* 生成卡密结果弹窗 */
.cards-textarea {
    width: 100%;
    min-height: 180px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.9;
    resize: vertical;
    margin-bottom: 14px;
}
.cards-textarea:focus { outline: none; border-color: var(--primary); }

/* ============================================
   响应式
   ============================================ */
@media (max-width: 1024px) {
    /* 桌面侧栏收起，改用顶栏汉堡按钮 + 侧边抽屉 */
    .admin-sidebar { display: none; }
    .admin-main { margin-left: 0; }
    .topbar-right { display: none; }
    .admin-menu-toggle { display: inline-flex; align-items: center; }
    .admin-mobile-menu { display: flex; }
    .admin-topbar { padding: 0 16px; }
}

@media (max-width: 768px) {
    .admin-content { padding: 16px; }
    .admin-card { padding: 18px; }
    /* 表格独立横向滚动，卡片标题保持固定 */
    .admin-card .table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    .admin-form .form-row { grid-template-columns: 1fr; }
    .search-form { width: 100%; }
    .search-form input { width: 100%; }
    .stats-grid { grid-template-columns: 1fr; gap: 12px; }
    .stat-card { padding: 16px; }
    .admin-table { font-size: 13px; }
    .admin-table th, .admin-table td { padding: 9px 10px; }
    .admin-toolbar { flex-direction: column; align-items: stretch; }
    .quick-actions .btn { flex: 1; }
    .pagination { flex-wrap: wrap; }
    /* 标签过多时横向滚动 */
    .admin-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .admin-tab { flex: 0 0 auto; white-space: nowrap; padding: 9px 14px; }
}
