/* ═══ 小童主脑 · 专业深蓝控制台 ═══ */

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

:root {
  /* 主色调 */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  
  /* 侧边栏深色 */
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  
  /* 内容区 */
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  
  /* 状态色 */
  --green: #10b981;
  --green-light: #d1fae5;
  --red: #ef4444;
  --red-light: #fee2e2;
  --orange: #f59e0b;
  --orange-light: #fef3c7;
  
  /* 尺寸 */
  --sidebar-width: 240px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ═══ 页面切换 ═══ */
.page { display: none; }
.page.active { display: block; }

/* ═══ 登录页 ═══ */
#page-login {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}
#page-login.active { display: flex; }

.login-card {
  background: var(--card);
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 400px;
  width: 90%;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-icon { 
  font-size: 56px; 
  margin-bottom: 16px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.login-card h1 { 
  font-size: 26px; 
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.login-sub { 
  color: var(--text-secondary); 
  font-size: 14px; 
  margin-bottom: 32px;
}

.login-form { 
  display: flex; 
  flex-direction: column; 
  gap: 16px; 
}

.login-form input { 
  padding: 14px 16px; 
  font-size: 15px; 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  outline: none;
  transition: all 0.2s;
}

.login-form input:focus { 
  border-color: var(--primary); 
  box-shadow: 0 0 0 3px var(--primary-light);
}

.login-form .btn { 
  justify-content: center; 
  font-size: 15px; 
  padding: 14px; 
  border-radius: var(--radius);
}

.login-error { 
  color: var(--red); 
  font-size: 13px; 
  min-height: 20px;
  margin-top: 8px;
}

/* ═══ 主应用布局 ═══ */
#page-app {
  display: none;
}

#page-app.active {
  display: flex;
  min-height: 100vh;
}

/* ═══ 侧边栏 ═══ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.sidebar-logo-icon {
  font-size: 28px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
}

.nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--sidebar-text);
  font-size: 13px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* ═══ 主内容区 ═══ */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ═══ 顶部栏 ═══ */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.breadcrumb {
  font-size: 14px;
  color: var(--text-secondary);
}

.breadcrumb strong {
  color: var(--text);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar-time {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  padding: 6px 12px;
  border-radius: var(--radius);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s;
}

.btn-icon:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ═══ 内容区 ═══ */
.main-content {
  flex: 1;
  padding: 24px 32px;
  max-width: 1400px;
}

.page-section {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.page-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══ 页面标题区 ═══ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

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

/* ═══ 按钮 ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.btn-warning {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}

.btn-warning:hover {
  background: #d97706;
  border-color: #d97706;
  color: #fff;
}

.btn-success {
  background: #15803d;
  color: #fff;
  border-color: #16a34a;
}
.btn-success:hover {
  background: #16a34a;
  border-color: #15803d;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 部署级高危按钮：深红+描边突出危险感 */
.btn-deploy {
  background: #7f1d1d;
  color: #fff;
  border-color: #991b1b;
  font-weight: 600;
}
.btn-deploy:hover {
  background: #991b1b;
  border-color: #b91c1c;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
  color: #fff;
}

/* 部署级暂停弹窗特殊样式 */
.deploy-warning {
  text-align: left;
  max-width: 520px;
}
.deploy-warning h3 {
  color: #b91c1c;
  font-size: 18px;
  margin-bottom: 12px;
}
.deploy-warning code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
  color: #0f172a;
}
.deploy-warning .warn-text {
  color: #b91c1c;
  font-weight: 500;
}

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

.stat-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

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

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: var(--green-light); }
.stat-icon.orange { background: var(--orange-light); }
.stat-icon.red { background: var(--red-light); }

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

/* ═══ 内容卡片 ═══ */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 0;
}

/* ═══ 表格 ═══ */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  padding: 14px 24px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: #fafafa;
}

.table a {
  color: var(--primary);
  text-decoration: none;
}

.table a:hover {
  text-decoration: underline;
}

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

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-active {
  background: var(--green-light);
  color: #065f46;
}

.status-active::before {
  background: var(--green);
  animation: pulse-dot 2s infinite;
}

.status-suspended {
  background: var(--red-light);
  color: #991b1b;
}

.status-suspended::before {
  background: var(--red);
}

.status-expired {
  background: var(--orange-light);
  color: #92400e;
}

.status-expired::before {
  background: var(--orange);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 在线状态点 */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot-online {
  background: var(--green);
  animation: pulse-dot 2s infinite;
}

.dot-offline {
  background: var(--text-secondary);
}

/* ═══ 操作按钮组 ═══ */
.actions-cell {
  display: flex;
  gap: 8px;
}

/* ═══ 空状态 ═══ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state-desc {
  font-size: 14px;
}

/* ═══ 表单 ═══ */
.input, select.input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--card);
  outline: none;
  width: 100%;
  transition: all 0.2s;
}

.input:focus, select.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
  margin-bottom: 16px;
}

.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-row .hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ═══ 弹窗 ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ═══ 确认弹窗 ═══ */
.confirm-box {
  padding: 24px;
  text-align: center;
}

.confirm-box h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.confirm-box p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ═══ 代码块 ═══ */
.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 20px;
  border-radius: var(--radius);
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.script-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.script-picker label {
  font-weight: 500;
}

.script-picker select {
  width: 240px;
}

/* ═══ Toast ═══ */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  animation: slideInRight 0.3s ease-out;
  box-shadow: var(--shadow-lg);
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-success {
  background: var(--green);
  color: #fff;
}

.toast-error {
  background: var(--red);
  color: #fff;
}

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-wrapper {
    margin-left: 0;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}
