/* ============================================================
   兴华科技-落朵机器人 — 管理后台 Dashboard 样式
   版本: v2026.07.19
   ============================================================ */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --info: #0891b2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 240px;
  --header-h: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Login Page === */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1e40af 100%);
  position: relative; overflow: hidden;
}
.login-container::before {
  content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 70%, rgba(255,255,255,0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 30%, rgba(255,255,255,0.05) 0%, transparent 50%);
  animation: bgFloat 20s ease-in-out infinite;
}
@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-2%, -2%); }
}

.login-card {
  background: white; border-radius: 16px; padding: 48px 40px;
  width: 420px; max-width: 90vw; position: relative; z-index: 1;
  box-shadow: 0 25px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .icon {
  width: 64px; height: 64px; background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 16px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px; color: white; margin-bottom: 12px;
}
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--gray-800); }
.login-logo .brand { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600; color: var(--gray-700);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-300);
  border-radius: var(--radius); font-size: 15px; transition: all .2s;
  background: var(--gray-50);
}
.form-group input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
  background: white;
}
.login-btn {
  width: 100%; padding: 12px; background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white; border: none; border-radius: var(--radius); font-size: 16px;
  font-weight: 600; cursor: pointer; transition: all .2s; margin-top: 8px;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.4); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.login-error {
  background: #fef2f2; color: var(--danger); padding: 10px 14px;
  border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; display: none;
}
.login-info { text-align: center; margin-top: 20px; font-size: 12px; color: var(--gray-400); }

/* === Layout === */
.app-layout { display: flex; min-height: 100vh; }

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-w); background: var(--gray-900); color: white;
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0;
  bottom: 0; z-index: 100; transition: transform .3s;
}
.sidebar-header {
  padding: 20px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-header .brand-name { font-size: 16px; font-weight: 700; }
.sidebar-header .brand-ver { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.sidebar-nav .nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--gray-500); padding: 16px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--gray-400);
  transition: all .15s; margin-bottom: 2px; border: none; background: none; width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active { background: var(--primary); color: white; font-weight: 600; }
.nav-item .nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer {
  padding: 12px; border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-footer .user-info { font-size: 12px; color: var(--gray-400); padding: 8px; }
.sidebar-footer .logout-btn {
  width: 100%; padding: 8px; border: 1px solid rgba(255,255,255,.2);
  background: transparent; color: var(--gray-400); border-radius: 6px;
  cursor: pointer; font-size: 13px; transition: all .15s;
}
.sidebar-footer .logout-btn:hover { background: rgba(255,255,255,.1); color: white; }

/* === Main Content === */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

/* === Top Bar === */
.top-bar {
  height: var(--header-h); background: white; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.top-bar h2 { font-size: 18px; font-weight: 700; }
.top-bar .status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; animation: pulse 2s infinite;
}
.top-bar .status-dot.online { background: var(--success); }
.top-bar .status-dot.offline { background: var(--danger); animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* === Content Area === */
.content-area { padding: 24px; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* === Cards === */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.stat-card {
  background: white; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-lg); }
.stat-card .stat-label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin: 6px 0; }
.stat-card .stat-sub { font-size: 12px; color: var(--gray-400); }
.stat-card .stat-icon {
  float: right; font-size: 32px; opacity: .2; margin-top: -8px;
}

/* === Tables === */
.data-table {
  width: 100%; border-collapse: collapse; background: white;
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.data-table th {
  background: var(--gray-50); padding: 12px 16px; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--gray-200);
}
.data-table td {
  padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--gray-100);
}
.data-table tr:hover td { background: var(--gray-50); }
.data-table .badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-paused { background: #fef3c7; color: #92400e; }
.badge-stopped { background: #fee2e2; color: #991b1b; }
.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-dev { background: #dbeafe; color: #1e40af; }
.badge-operator { background: #e0f2fe; color: #0369a1; }
.badge-viewer { background: #f3f4f6; color: #4b5563; }

/* === Section Header === */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.section-header h3 { font-size: 16px; font-weight: 700; }

/* === Buttons === */
.btn {
  padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s; border: none; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: white; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--gray-400); background: var(--gray-50); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* === Log viewer === */
.log-viewer {
  background: var(--gray-900); color: #e5e7eb; border-radius: var(--radius);
  padding: 16px; max-height: 500px; overflow-y: auto; font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px; line-height: 1.8;
}
.log-entry { display: flex; gap: 12px; }
.log-entry .log-time { color: var(--gray-500); white-space: nowrap; }
.log-entry .log-level { font-weight: 700; width: 50px; text-align: center; }
.log-level.INFO { color: #60a5fa; }
.log-level.WARN { color: #fbbf24; }
.log-level.ERROR { color: #f87171; }
.log-level.CRITICAL { color: #ef4444; }

/* === Modal === */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: white; border-radius: 12px; padding: 24px; width: 480px; max-width: 90vw;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 16px; font-size: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* === Toast === */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 300;
  padding: 12px 20px; border-radius: var(--radius); font-size: 14px;
  color: white; box-shadow: var(--shadow-lg); animation: slideIn .3s ease-out;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .card-grid { grid-template-columns: 1fr; }
}

/* === Architecture Diagram === */
.arch-diagram {
  background: white; border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); text-align: center;
}
.arch-nodes { display: flex; align-items: center; justify-content: center; gap: 40px; flex-wrap: wrap; }
.arch-node {
  border: 2px solid var(--gray-200); border-radius: 12px; padding: 16px 24px;
  min-width: 140px; transition: all .2s;
}
.arch-node.local { border-color: var(--primary); background: var(--primary-light); }
.arch-node.cloud { border-color: #7c3aed; background: #f5f3ff; }
.arch-node .node-name { font-weight: 700; font-size: 14px; }
.arch-node .node-ip { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.arch-node .node-spec { font-size: 10px; color: var(--gray-400); }
.arch-arrow { font-size: 24px; color: var(--gray-400); }

/* === API Console === */
#api-method option[value="GET"] { color: #1e40af; }
#api-method option[value="POST"] { color: #166534; }
#api-method option[value="PUT"] { color: #92400e; }
#api-method option[value="DELETE"] { color: #991b1b; }
#api-method option[value="PATCH"] { color: #5b21b6; }

#api-quick-btns .btn { font-family: 'Fira Code', monospace; font-size: 11px; }

#api-resp-body { transition: all .2s; }
#api-resp-body:empty::after { content: '等待请求...'; color: #6b7280; }

.api-badge-get { background: #dbeafe; color: #1e40af; }
.api-badge-post { background: #dcfce7; color: #166534; }
.api-badge-put { background: #fef3c7; color: #92400e; }
.api-badge-delete { background: #fee2e2; color: #991b1b; }
.api-badge-ws { background: #ede9fe; color: #5b21b6; }
