/* === 基础样式 === */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f3f4f6;
    --bg-card: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #4f46e5;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.12);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* === 登录页 === */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 400px;
    max-width: 90vw;
}
.login-header { text-align: center; margin-bottom: 30px; }
.login-header h1 { font-size: 24px; color: var(--primary); margin-bottom: 8px; }
.login-header p { font-size: 13px; color: var(--text-muted); }
.login-footer { text-align: center; margin-top: 20px; font-size: 12px; color: var(--text-muted); }

/* === 管理布局 === */
.admin-layout { display: flex; min-height: 100vh; }

/* === 侧边栏 === */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width .3s;
    overflow-y: auto;
}
.sidebar.collapsed { width: 60px; }
.sidebar-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-header h2 { font-size: 16px; white-space: nowrap; }
.sidebar.collapsed .sidebar-header h2 { display: none; }
.sidebar-toggle { background: none; border: none; color: var(--sidebar-text); cursor: pointer; font-size: 18px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    transition: all .2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,.05); }
.nav-item.active {
    background: rgba(79,70,229,.2);
    border-left-color: var(--sidebar-active);
    color: #fff;
}
.nav-icon { margin-right: 10px; font-size: 16px; }
.sidebar.collapsed .nav-item span:not(.nav-icon) { display: none; }
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-footer .btn { font-size: 12px; }

/* === 主内容 === */
.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 24px;
    min-height: 100vh;
    transition: margin-left .3s;
}
.sidebar.collapsed ~ .main-content { margin-left: 60px; }

/* === 页面标题 === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 600; }
.page-header .header-actions { display: flex; gap: 10px; }

/* === 统计卡片 === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; color: #3b82f6; }
.stat-icon.green { background: #d1fae5; color: #10b981; }
.stat-icon.orange { background: #fef3c7; color: #f59e0b; }
.stat-icon.purple { background: #ede9fe; color: #8b5cf6; }
.stat-icon.red { background: #fee2e2; color: #ef4444; }
.stat-info h3 { font-size: 24px; font-weight: 700; }
.stat-info p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* === 卡片 === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
}
.card-body { padding: 20px; }

/* === 表格 === */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table th, table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}
table tbody tr:hover { background: #f9fafb; }
table td { vertical-align: middle; }

/* === 按钮 === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { opacity: .9; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* === 表单 === */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .2s;
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* === 标签/徽章 === */
.badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 12px;
    border-radius: 20px;
    font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* === 搜索过滤 === */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: center;
}
.filter-bar input,
.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.filter-bar input { width: 200px; }
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--primary); }

/* === 分页 === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}
.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .5; cursor: not-allowed; }
.pagination .page-info { font-size: 13px; color: var(--text-muted); line-height: 34px; margin: 0 10px; }

/* === Toast === */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    padding: 12px 24px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    animation: slideIn .3s ease;
    pointer-events: none;
    max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === 模态框 === */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; }
.modal-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
}
.modal-box {
    position: relative;
    margin: 60px auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* === 响应式 === */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .sidebar-header h2,
    .sidebar .nav-item span:not(.nav-icon),
    .sidebar-footer { display: none; }
    .sidebar.expanded { width: 220px; }
    .sidebar.expanded .sidebar-header h2,
    .sidebar.expanded .nav-item span,
    .sidebar.expanded .sidebar-footer { display: flex; }
    .main-content { margin-left: 60px; }
    .form-row { flex-direction: column; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* === 工具类 === */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot.online { background: #10b981; }
.status-dot.offline { background: #ef4444; }
.status-dot.pending { background: #f59e0b; }

/* 转码类型标签 */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.tag-qr { background: #ede9fe; color: #6d28d9; }
.tag-barcode { background: #dbeafe; color: #1d4ed8; }
.tag-link { background: #d1fae5; color: #065f46; }
.tag-miniapp { background: #fef3c7; color: #92400e; }

/* 负载动画 */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.loading::after { content: '加载中...'; }
