/* ============================================
   XS Admin - 商务风格后台管理系统
   ============================================ */

:root {
    --sidebar-bg: #1b2a3d;
    --sidebar-hover: #243447;
    --sidebar-active: #2c4058;
    --sidebar-width: 220px;
    --topbar-height: 56px;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #eff6ff;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #6366f1;
    --info-light: #eef2ff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --bg-page: #f1f5f9;
    --bg-card: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
    --radius-sm: 4px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-page);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ========== Layout ========== */
.admin-layout { display: flex; height: 100vh; overflow: hidden; }

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #c8d6e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: all 0.3s;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-brand {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.sidebar-brand .logo {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
}
.sidebar-brand .logo span { color: var(--primary); }
.sidebar-brand .version {
    font-size: 11px;
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 10px;
    color: #8899aa;
}

.sidebar-nav { flex: 1; padding: 8px 0; }

.nav-section {
    padding: 16px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #5a7a94;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 9px 20px;
    color: #a0b4c4;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13.5px;
    border-left: 3px solid transparent;
    user-select: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #d4e0ea; }
.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: var(--primary);
}
.nav-item .nav-icon {
    width: 20px;
    text-align: center;
    margin-right: 10px;
    font-size: 14px;
    flex-shrink: 0;
}
.nav-item .nav-label { flex: 1; }
.nav-item .nav-arrow {
    font-size: 10px;
    transition: transform 0.25s;
    color: #5a7a94;
}
.nav-item.expanded .nav-arrow { transform: rotate(90deg); }

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0,0,0,0.15);
}
.nav-submenu.show { max-height: 600px; }
.nav-submenu .nav-item {
    padding: 7px 20px 7px 53px;
    font-size: 13px;
    border-left: none;
}
.nav-submenu .nav-item:hover { background: rgba(255,255,255,0.05); }
.nav-submenu .nav-item.active {
    background: rgba(59,130,246,0.15);
    color: #fff;
    border-left: none;
}

/* ========== Main Area ========== */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ========== Topbar ========== */
.topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-breadcrumb { font-size: 14px; color: var(--text-secondary); }
.topbar-breadcrumb .current { color: var(--text-primary); font-weight: 500; }
.topbar-breadcrumb .sep { margin: 0 8px; color: var(--text-light); }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-link {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.topbar-link:hover { color: var(--primary); background: var(--primary-light); }
.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: var(--bg-page);
    border-radius: 20px;
    font-size: 13px;
}
.topbar-user .avatar {
    width: 28px; height: 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}

/* ========== Content Area ========== */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ========== Page Header ========== */
.page-header {
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.page-header p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========== Card ========== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

/* ========== Stats Grid ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.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: var(--primary-light); }
.stat-icon.green { background: var(--success-light); }
.stat-icon.orange { background: var(--warning-light); }
.stat-icon.purple { background: var(--info-light); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 2px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: var(--success); }

/* ========== Grid ========== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 1200px) { .grid-2 { grid-template-columns: 1fr; } }

/* ========== Data Table ========== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    white-space: nowrap;
}
.data-table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ========== Badge ========== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #b45309; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-secondary { background: #f1f5f9; color: var(--text-secondary); }

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* ========== Form ========== */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: #fff;
    transition: border-color 0.2s;
    outline: none;
    line-height: 1.5;
    text-align: left;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
select.form-control { 
    height: 36px; 
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
textarea.form-control { min-height: 80px; resize: vertical; padding: 10px 12px; }

.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.form-inline {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.form-inline .form-control { width: auto; }

/* ========== Config Table ========== */
.config-table { width: 100%; border-collapse: collapse; }
.config-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}
.config-table td:first-child {
    width: 180px;
    min-width: 180px;
    font-weight: 500;
    color: #555;
    background: #fafbfc;
    text-align: right;
    padding-right: 20px;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
}
.config-table td:last-child {
    white-space: normal;
}
.config-table tr:last-child td { border-bottom: none; }
.config-table tbody tr:hover td { background: #f8f9fb; }

/* ========== Config Tabs ========== */
.config-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
    padding: 12px 16px;
    background: #1b2a3d;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.config-tab {
    padding: 10px 20px;
    background: rgba(255,255,255,0.1);
    color: #a0b4c4;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}
.config-tab:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}
.config-tab.active {
    background: #3b82f6;
    color: #fff;
}

.config-panel {
    display: none;
    background: #fff;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 20px;
}
.config-panel.active {
    display: block;
}

.config-section {
    background: #f5f6fa;
    color: #444;
    padding: 12px 20px;
    font-weight: 600;
    font-size: 14px;
    border-radius: var(--radius-sm);
    margin-top: 24px;
    border-left: 3px solid #adb5bd;
}
.config-section:first-child { margin-top: 0; }

/* ========== Toolbar ========== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ========== Pagination ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination .info { border: none; color: var(--text-light); font-size: 12px; }

/* ========== Quick Actions ========== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
}
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
}
.quick-action:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.qa-icon { font-size: 24px; }
.qa-label { font-size: 12px; color: var(--text-secondary); }

/* ========== Sys Info ========== */
.sys-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.sys-info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.sys-info-item:nth-child(odd) { padding-right: 24px; }
.sys-info-item:nth-child(even) { padding-left: 24px; border-left: 1px solid var(--border); }
.sys-info-item .label { color: var(--text-secondary); }
.sys-info-item .value { color: var(--text-primary); font-weight: 500; }

/* ========== Progress Bar ========== */
.progress-bar-wrap { background: #f1f5f9; border-radius: 6px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 6px; transition: width 0.6s ease; }
.cat-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.cat-item:last-child { border-bottom: none; }
.cat-name { width: 80px; font-size: 13px; color: var(--text-primary); font-weight: 500; flex-shrink: 0; }
.cat-bar { flex: 1; }
.cat-count { width: 60px; text-align: right; font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }

/* ========== Alert ========== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--info-light); color: #3730a3; border: 1px solid #c7d2fe; }

/* ========== Action Links ========== */
.action-link {
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}
.action-link:hover { text-decoration: underline; }
.action-link.danger { color: var(--danger); }

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1b2a3d 0%, #2c4058 50%, #1b2a3d 100%);
}
.login-card {
    width: 400px;
    background: rgba(255,255,255,0.97);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { font-size: 32px; font-weight: 700; color: var(--sidebar-bg); }
.login-logo span { color: var(--primary); }
.login-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 20px;
    border: 1px solid #fecaca;
}
.login-form .form-group { margin-bottom: 20px; }
.btn-login {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-login:hover { background: var(--primary-dark); }
.login-footer { text-align: center; margin-top: 24px; font-size: 13px; }
.login-footer a { color: var(--text-secondary); }

/* ========== Power Table ========== */
.power-table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 13px;
}
.power-table th, .power-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    vertical-align: middle;
}
.power-table thead th {
    background: #1b2a3d;
    color: #a0b4c4;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
    border: none;
}
.power-table thead th:first-child {
    text-align: left;
    padding-left: 20px;
    border-radius: var(--radius-sm) 0 0 0;
}
.power-table thead th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}
.power-table tbody tr:hover td { 
    background: #f8f9fb; 
}
.power-table tbody tr:last-child td { 
    border-bottom: none; 
}
.power-table tbody td:first-child { 
    text-align: left; 
    background: #fafbfc; 
    font-weight: 500; 
    color: #444;
    padding-left: 20px;
}
.power-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ========== Form Actions ========== */
.form-actions {
    padding: 20px;
    text-align: center;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.form-actions .btn {
    padding: 10px 32px;
    font-size: 14px;
}

/* ========== Loading ========== */
.content-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-light);
}
.spinner-sm {
    width: 24px; height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Utility ========== */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-light) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.nowrap { white-space: nowrap; }

/* ========== Scrollbar ========== */
.content-area::-webkit-scrollbar { width: 6px; }
.content-area::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.content-area::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ========== Modal ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-content {
    background: #fff;
    border-radius: var(--radius);
    width: 700px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}
.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; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
