/* ========================================
   万家坊账号管理系统 v2.0 - 企业级样式
   ======================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: #f0f2f5;
    color: #1a2332;
    line-height: 1.6;
    font-size: 14px;
}

/* ===== 角色控制 ===== */
.admin-only { display: none !important; }
body.is-admin .admin-only { display: revert !important; }
body.is-admin .nav-item.admin-only { display: flex !important; }
body.is-admin #adminToolbar { display: inline-flex; gap: 8px; }
body.is-admin .checkbox-cell.admin-only { display: table-cell !important; }

/* ===== 布局 ===== */
.app-layout { display: flex; width: 100%; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
    width: 250px; flex-shrink: 0;
    background: linear-gradient(180deg, #1a2332 0%, #0f1729 100%);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 1000;
}
.sidebar-logo {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo .logo-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #4e5de4, #6c7aff);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(78,93,228,0.3);
}
.sidebar-logo .logo-icon svg { width: 22px; height: 22px; stroke: #fff; fill: none; }
.sidebar-logo .logo-text { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: 0.5px; }
.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 8px;
    color: rgba(255,255,255,0.6);
    text-decoration: none; font-size: 14px;
    cursor: pointer; transition: all 0.2s ease;
    margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); }
.nav-item.active {
    background: linear-gradient(135deg, rgba(78,93,228,0.25), rgba(78,93,228,0.1));
    color: #fff; font-weight: 500;
}
.nav-item svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.sidebar-user {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user .user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #4e5de4, #6c7aff);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-user .user-avatar svg { width: 18px; height: 18px; color: #fff; stroke: currentColor; }
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 14px; font-weight: 600; color: #fff; }
.sidebar-user .user-role { font-size: 11px; color: rgba(255,255,255,0.45); }
.sidebar-user .logout-btn {
    width: 32px; height: 32px; border-radius: 8px;
    border: none; background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.45); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease; flex-shrink: 0;
}
.sidebar-user .logout-btn:hover { background: rgba(239,68,68,0.2); color: #ef4444; }
.sidebar-user .logout-btn svg { width: 16px; height: 16px; }

.main-content { flex: 1; margin-left: 250px; width: calc(100% - 250px); display: flex; flex-direction: column; }

/* ===== 页面头部 ===== */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 24px 32px 0;
}
.page-header h2 {
    font-size: 22px; font-weight: 600; color: #1a2332;
    letter-spacing: -0.3px;
}
.page-header .header-actions { display: flex; gap: 8px; align-items: center; }

/* ===== 统计卡片 ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px; padding: 20px 32px;
}
.stat-card {
    background: #fff; border-radius: 12px;
    padding: 20px 22px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    transition: all 0.25s ease;
    border: 1px solid rgba(0,0,0,0.04);
}
.stat-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    transform: translateY(-1px);
}
.stat-card .stat-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card .stat-icon svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; }
.stat-card .stat-icon.blue { background: linear-gradient(135deg, #4e5de4, #6c7aff); box-shadow: 0 4px 12px rgba(78,93,228,0.25); }
.stat-card .stat-icon.green { background: linear-gradient(135deg, #2ab57d, #34d399); box-shadow: 0 4px 12px rgba(42,181,125,0.25); }
.stat-card .stat-icon.orange { background: linear-gradient(135deg, #ff9f43, #fbbf24); box-shadow: 0 4px 12px rgba(255,159,67,0.25); }
.stat-card .stat-icon.red { background: linear-gradient(135deg, #ef4444, #f87171); box-shadow: 0 4px 12px rgba(239,68,68,0.25); }
.stat-card .stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #a78bfa); box-shadow: 0 4px 12px rgba(139,92,246,0.25); }
.stat-card .stat-info { flex: 1; min-width: 0; }
.stat-card .stat-label { font-size: 12px; color: #6b7280; margin-bottom: 4px; font-weight: 500; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: #1a2332; line-height: 1.2; }

/* ===== 工具栏 ===== */
.toolbar { padding: 0 32px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar .search-box { flex: 1; min-width: 220px; max-width: 340px; position: relative; }
.toolbar .search-box input {
    width: 100%; padding: 9px 16px 9px 40px;
    border: 1px solid #e5e7eb; border-radius: 8px;
    font-size: 13px; color: #1a2332; background: #fff;
    outline: none; transition: all 0.2s ease;
}
.toolbar .search-box input:focus {
    border-color: #4e5de4;
    box-shadow: 0 0 0 3px rgba(78,93,228,0.12);
}
.toolbar .search-box input::placeholder { color: #9ca3af; }
.toolbar .search-box .search-icon {
    position: absolute; left: 14px; top: 50%;
    transform: translateY(-50%); color: #9ca3af;
    width: 16px; height: 16px;
}
.toolbar select {
    padding: 9px 14px; border: 1px solid #e5e7eb; border-radius: 8px;
    font-size: 13px; color: #374151; background: #fff;
    outline: none; cursor: pointer; transition: border-color 0.2s;
}
.toolbar select:focus { border-color: #4e5de4; box-shadow: 0 0 0 3px rgba(78,93,228,0.12); }

/* ===== 按钮 ===== */
.btn {
    padding: 9px 18px; border-radius: 8px;
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e5e7eb;
    background: #fff; color: #374151;
    display: inline-flex; align-items: center; gap: 6px;
    white-space: nowrap;
    user-select: none;
}
.btn:hover { background: #f9fafb; border-color: #d1d5db; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }
.btn-primary {
    background: linear-gradient(135deg, #4e5de4, #6c7aff);
    color: #fff; border-color: transparent;
    box-shadow: 0 2px 8px rgba(78,93,228,0.25);
}
.btn-primary:hover { background: linear-gradient(135deg, #3d4bd6, #5b6bf2); border-color: transparent; box-shadow: 0 4px 14px rgba(78,93,228,0.35); }
.btn-success {
    background: linear-gradient(135deg, #2ab57d, #34d399);
    color: #fff; border-color: transparent;
    box-shadow: 0 2px 8px rgba(42,181,125,0.25);
}
.btn-success:hover { background: linear-gradient(135deg, #219a6a, #2cc48a); border-color: transparent; box-shadow: 0 4px 14px rgba(42,181,125,0.35); }
.btn-danger { color: #ef4444; border-color: #fce4e4; background: #fff5f5; }
.btn-danger:hover { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn-warning {
    background: linear-gradient(135deg, #ff9f43, #fbbf24);
    color: #fff; border-color: transparent;
    box-shadow: 0 2px 8px rgba(255,159,67,0.25);
}
.btn-warning:hover { background: linear-gradient(135deg, #f0901a, #fbb624); border-color: transparent; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ===== 表格容器 ===== */
.table-container {
    margin: 0 32px; flex: 1; overflow: auto;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.table-container::-webkit-scrollbar { width: 6px; height: 6px; }
.table-container::-webkit-scrollbar-track { background: transparent; }
.table-container::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.table-container::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { position: sticky; top: 0; z-index: 10; }
thead th {
    background: #f8fafc;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600; font-size: 12px;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: #4e5de4; }
thead th .sort-icon { display: inline-block; margin-left: 4px; color: #d1d5db; }
thead th .sort-icon.active { color: #4e5de4; }
tbody tr { transition: background 0.15s ease; }
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: #f0f4ff; }
tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151; vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody td .cell-actions { display: flex; gap: 6px; }

/* ===== 状态标签 ===== */
.status-tag {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
    gap: 4px;
}
.status-active { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.status-registering { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.status-disabled { background: #f3f4f6; color: #6b7280; border: 1px solid #d1d5db; }
.status-frozen { background: #f3e8ff; color: #7c3aed; border: 1px solid #e9d5ff; }
.status-warning { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.status-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* ===== 在线状态圆点 ===== */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-online { background: #10b981; box-shadow: 0 0 8px rgba(16,185,129,0.5); }
.dot-offline { background: #d1d5db; }

/* ===== 分页 ===== */
.pagination-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 12px 12px;
}
.pagination-bar .page-info { font-size: 12px; color: #6b7280; }
.pagination-bar .page-controls { display: flex; gap: 4px; align-items: center; }
.pagination-bar .page-btn {
    padding: 5px 12px;
    border: 1px solid #e5e7eb; border-radius: 6px;
    background: #fff; color: #374151;
    font-size: 12px; cursor: pointer; transition: all 0.15s ease;
}
.pagination-bar .page-btn:hover:not(:disabled) { background: #f9fafb; border-color: #d1d5db; }
.pagination-bar .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-bar .page-btn.active { background: #4e5de4; color: #fff; border-color: #4e5de4; }

/* ===== 弹窗 ===== */
.modal-overlay {
    display: none; position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: #fff; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 520px; max-width: 92%; max-height: 85vh;
    overflow: hidden;
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-box.wide { width: 720px; }
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-24px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #f3f4f6;
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: #1a2332; margin: 0; }
.modal-close {
    background: none; border: none;
    color: #9ca3af; font-size: 24px; cursor: pointer;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; transition: all 0.15s ease;
    line-height: 1;
}
.modal-close:hover { background: #f3f4f6; color: #374151; }
.modal-body { padding: 24px; overflow-y: auto; max-height: calc(85vh - 130px); }

/* ===== 导入方式切换 ===== */
.import-tabs { display: flex; gap: 0; }
.import-tab {
    background: none; border: none; padding: 8px 20px;
    font-size: 13px; font-weight: 500; color: #6b7280;
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: all 0.15s ease; border-radius: 0;
}
.import-tab:hover { color: #4e5de4; }
.import-tab.active { color: #4e5de4; border-bottom-color: #4e5de4; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #f3f4f6;
}

/* ===== 表单 ===== */
.form-row { margin-bottom: 18px; }
.form-row label {
    display: block; font-size: 13px; font-weight: 500;
    color: #374151; margin-bottom: 6px;
}
.form-row input, .form-row select, .form-row textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px; color: #1a2332;
    background: #fff; outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    border-color: #4e5de4;
    box-shadow: 0 0 0 3px rgba(78,93,228,0.12);
}
.form-row textarea { min-height: 70px; resize: vertical; }
.form-row .form-hint { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

/* ===== 消息提示 ===== */
.toast {
    position: fixed; top: 20px; right: 20px; z-index: 9999;
    padding: 14px 22px; border-radius: 10px;
    font-size: 14px; font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 420px;
    display: flex; align-items: center; gap: 8px;
}
.toast.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.toast.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.toast.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== 复选框 ===== */
.checkbox-cell { width: 40px; text-align: center; }
.checkbox-cell input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: #4e5de4; }

/* ===== 空状态 ===== */
.empty-state {
    text-align: center; padding: 48px 20px; color: #9ca3af;
}
.empty-state svg { width: 56px; height: 56px; stroke: #d1d5db; margin-bottom: 14px; }
.empty-state p { font-size: 14px; }

/* ===== 滚动条 ===== */
.main-content .scroll-area { flex: 1; overflow-y: auto; min-height: 0; }
.main-content .scroll-area::-webkit-scrollbar { width: 6px; }
.main-content .scroll-area::-webkit-scrollbar-track { background: transparent; }
.main-content .scroll-area::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.main-content .scroll-area::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===== 代码块（IP等） ===== */
code {
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #4e5de4;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}

/* ===== 响应式 ===== */
@media (max-width: 992px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; width: calc(100% - 220px); }
    .stats-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; }
    .stats-row { grid-template-columns: 1fr 1fr; padding: 12px 16px; }
    .page-header, .toolbar { padding-left: 16px; padding-right: 16px; }
    .table-container { margin: 0 16px; }
    .form-grid { grid-template-columns: 1fr; }
}
