/* ============================================================
   ApiGateway 管理面板样式
   参考风格：深色侧边栏 + 白色内容区 + 现代卡片
   ============================================================ */

/* ---------- 全局 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}

a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 登录页 ---------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 48px 40px;
    width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card .logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1e1b4b;
    margin-bottom: 4px;
}

.login-card .logo p {
    color: #6b7280;
    font-size: 14px;
}

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

.login-card label {
    display: block;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
    font-size: 13px;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    outline: none;
}

.login-card input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.login-card .btn-login {
    width: 100%;
    padding: 12px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-card .btn-login:hover { background: #4338ca; }
.login-card .btn-login:disabled { background: #9ca3af; cursor: not-allowed; }

.login-card .error-msg {
    color: #ef4444;
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    display: none;
}

/* ---------- 主布局 ---------- */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- 侧边栏（深色） ---------- */
.sidebar {
    width: 260px;
    background: #1e1b4b;
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-header h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-header p {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
    letter-spacing: 1px;
    padding: 16px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}

.nav-item.active {
    background: #4f46e5;
    color: #fff;
    font-weight: 500;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.sidebar-footer .user-name {
    font-size: 13px;
    font-weight: 500;
}

.sidebar-footer .user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
}

.btn-logout {
    margin-top: 12px;
    width: 100%;
    padding: 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-logout:hover {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.4);
    color: #fca5a5;
}

/* ---------- 主内容区 ---------- */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
}

/* ---------- 页头 ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.page-header p {
    color: #6b7280;
    font-size: 13px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover { background: #4338ca; }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-outline {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-outline:hover { background: #f9fafb; border-color: #9ca3af; }

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.btn-danger:hover { background: #fecaca; }

.btn-success {
    background: #dcfce7;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.btn-success:hover { background: #bbf7d0; }

/* ---------- 统计卡片 ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
}

.stat-card .stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-top: 4px;
    letter-spacing: -1px;
}

.stat-card .stat-value.green { color: #16a34a; }
.stat-card .stat-value.red { color: #dc2626; }
.stat-card .stat-value.blue { color: #4f46e5; }

/* ---------- 表格卡片 ---------- */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    margin-bottom: 28px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.card-body { padding: 0; }
.card-body.padded { padding: 24px; }

/* ---------- 表格 ---------- */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: #f9fafb;
    padding: 12px 24px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e5e7eb;
}

.table td {
    padding: 14px 24px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f9fafb; }

/* ---------- 状态标签 ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-online {
    background: #dcfce7;
    color: #16a34a;
}

.badge-offline {
    background: #fee2e2;
    color: #dc2626;
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.badge-online .badge-dot { background: #16a34a; }
.badge-offline .badge-dot { background: #dc2626; }

/* ---------- 操作按钮组 ---------- */
.action-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.action-group button, .action-group a {
    font-size: 12px;
    text-decoration: none;
}

/* ---------- 通讯日志 ---------- */
.trace-record {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.trace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.trace-method {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    font-family: monospace;
}

.trace-method.GET { background: #dbeafe; color: #2563eb; }
.trace-method.POST { background: #dcfce7; color: #16a34a; }
.trace-method.PUT { background: #fef3c7; color: #d97706; }
.trace-method.DELETE { background: #fee2e2; color: #dc2626; }

.trace-path {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    color: #111827;
    font-weight: 500;
}

.trace-meta {
    font-size: 12px;
    color: #6b7280;
}

.trace-body {
    margin-top: 8px;
}

.trace-body pre {
    background: #1e1b4b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'SF Mono', Monaco, monospace;
    overflow-x: auto;
    max-height: 200px;
    line-height: 1.5;
}

.trace-toggle {
    font-size: 12px;
    color: #4f46e5;
    cursor: pointer;
    border: none;
    background: none;
    font-weight: 500;
}

/* ---------- 模块筛选 ---------- */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-bar select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.filter-bar select:focus {
    border-color: #4f46e5;
}

/* ---------- 弹窗 ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    width: 480px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #111827;
}

.modal .form-group {
    margin-bottom: 10px;
}

.modal label {
    display: block;
    font-weight: 500;
    font-size: 13px;
    color: #374151;
    margin-bottom: 6px;
}

.modal input, .modal select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.modal input:focus, .modal select:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
}

.empty-state svg { margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

/* ---------- 通知 ---------- */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: #16a34a; color: #fff; }
.toast.error { background: #dc2626; color: #fff; }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr; }
}
