/* ========================================
   StockLab - 全局样式
   深色科技风：#0f172a / #0c1222 + 蓝色强调
   ======================================== */

/* === CSS 变量 === */
:root {
  --bg-deep: #0c1222;
  --bg-main: #0f172a;
  --bg-card: #1a2332;
  --bg-card-hover: #1e293b;
  --bg-input: #1e293b;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-dark: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gradient-accent: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 30px rgba(59, 130, 246, 0.15);
  --radius: 8px;
  --radius-lg: 12px;
  --nav-height: 56px;
  --sidebar-width: 220px;
  --font-stack: 'SF Pro Display', -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
}

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

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-stack);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-light); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent); }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ========================================
   顶部导航栏
   ======================================== */
.top-nav {
  height: var(--nav-height);
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.nav-left { display: flex; align-items: center; gap: 12px; }
.nav-center { display: flex; align-items: center; gap: 10px; }
.nav-right { display: flex; align-items: center; gap: 16px; }

.nav-logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
}
.logo-emoji { font-size: 1.4em; }
.logo-text {
  font-size: 1.15em; font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.nav-breadcrumb { color: var(--text-secondary); font-size: 0.88em; }
.nav-back {
  color: var(--text-muted); font-size: 0.82em;
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.nav-back:hover { color: var(--accent-light); border-color: var(--accent); }
.nav-separator { color: var(--text-muted); font-size: 0.8em; }
.nav-admin-badge {
  color: var(--warning); font-size: 0.78em;
  padding: 2px 8px; border-radius: 4px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.nav-link { color: var(--text-muted); font-size: 0.82em; }
.nav-link:hover { color: var(--accent-light); }

/* === 用户菜单 === */
.user-menu { position: relative; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gradient-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85em; font-weight: 700; color: #fff;
  cursor: pointer; transition: transform 0.2s;
}
.user-avatar:hover { transform: scale(1.05); }

.user-dropdown {
  display: none; position: absolute; right: 0; top: 44px;
  width: 220px; background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  z-index: 200; overflow: hidden;
}
.user-dropdown.show { display: block; }

.dropdown-header { padding: 14px 16px; }
.dropdown-name { font-weight: 600; font-size: 0.92em; }
.dropdown-role { color: var(--text-muted); font-size: 0.78em; margin-top: 2px; }

.dropdown-divider { height: 1px; background: var(--border); }

.dropdown-item {
  display: block; padding: 10px 16px;
  color: var(--text); font-size: 0.85em;
  transition: background 0.15s;
}
.dropdown-item:hover { background: rgba(59, 130, 246, 0.08); }
.dropdown-logout { color: var(--danger); }
.dropdown-logout:hover { background: rgba(239, 68, 68, 0.08); }

/* ========================================
   登录页
   ======================================== */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
}

.login-container { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 2.5em; margin-bottom: 8px; }
.login-logo h1 {
  font-size: 1.6em; font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-subtitle { color: var(--text-muted); font-size: 0.85em; margin-top: 6px; }

/* === Flash Messages === */
.flash-messages { margin-bottom: 16px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 0.85em; margin-bottom: 8px;
}
.flash-error { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.flash-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.flash-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  color: var(--text-secondary); font-size: 0.85em; font-weight: 500;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 0.9em; font-family: var(--font-stack);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.form-group input::placeholder { color: var(--text-muted); }

.form-hint { display: block; color: var(--text-muted); font-size: 0.76em; margin-top: 4px; }

.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }

.btn-login {
  width: 100%; padding: 12px;
  background: var(--gradient-accent);
  color: #fff; border: none; border-radius: var(--radius);
  font-size: 0.95em; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s, transform 0.1s;
}
.btn-login:hover { opacity: 0.9; }
.btn-login:active { transform: scale(0.98); }

.btn-primary {
  padding: 10px 20px; background: var(--gradient-accent);
  color: #fff; border: none; border-radius: var(--radius);
  font-size: 0.88em; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  padding: 10px 20px; background: transparent;
  color: var(--text-secondary); border: 1px solid var(--border-light);
  border-radius: var(--radius); font-size: 0.88em;
  cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { color: var(--text); border-color: var(--accent); }

.btn-sm {
  padding: 4px 12px; font-size: 0.78em;
  border-radius: 5px; border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
}
.btn-edit { background: rgba(59, 130, 246, 0.1); color: var(--accent-light); border-color: rgba(59, 130, 246, 0.2); }
.btn-edit:hover { background: rgba(59, 130, 246, 0.2); }
.btn-delete { background: rgba(239, 68, 68, 0.1); color: var(--danger); border-color: rgba(239, 68, 68, 0.2); }
.btn-delete:hover { background: rgba(239, 68, 68, 0.2); }

.login-footer {
  text-align: center; margin-top: 20px;
  color: var(--text-muted); font-size: 0.76em;
}

/* === Toggle Switch === */
.toggle-switch { display: flex; align-items: center; gap: 10px; }
.toggle-switch input[type="checkbox"] {
  width: 40px; height: 22px; -webkit-appearance: none; appearance: none;
  background: var(--border-light); border-radius: 11px;
  position: relative; cursor: pointer; transition: background 0.2s;
}
.toggle-switch input[type="checkbox"]::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-muted); transition: all 0.2s;
}
.toggle-switch input[type="checkbox"]:checked { background: var(--accent); }
.toggle-switch input[type="checkbox"]:checked::after { left: 21px; background: #fff; }
.toggle-switch label { color: var(--text); font-size: 0.88em; cursor: pointer; }

/* ========================================
   应用大厅
   ======================================== */
.main-content {
  max-width: 1200px; margin: 0 auto; padding: 32px 24px;
}

.hub-header { margin-bottom: 28px; }
.hub-header h2 {
  font-size: 1.5em; font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hub-desc { color: var(--text-muted); font-size: 0.88em; margin-top: 4px; }

.app-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.app-card {
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none; color: inherit;
  transition: all 0.3s ease;
  position: relative; overflow: hidden;
}
.app-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--gradient-accent);
  opacity: 0; transition: opacity 0.3s;
}
.app-card:hover {
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}
.app-card:hover::before { opacity: 1; }

.app-card-icon { font-size: 2.5em; margin-bottom: 14px; }

.app-card-info { flex: 1; margin-bottom: 16px; }
.app-card-info h3 { font-size: 1.05em; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.app-card-info p { color: var(--text-muted); font-size: 0.82em; line-height: 1.5; }

.app-card-action {
  display: flex; align-items: center; gap: 6px;
  color: var(--accent-light); font-size: 0.85em; font-weight: 500;
}
.app-card-coming { opacity: 0.55; pointer-events: none; }
.coming-soon {
  color: var(--text-muted) !important; font-size: 0.8em !important;
  padding: 4px 12px; border: 1px dashed var(--border);
  border-radius: 6px;
}

@media (max-width: 900px) { .app-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .app-grid { grid-template-columns: 1fr; } }

/* ========================================
   管理后台
   ======================================== */
.page-admin { background: var(--bg-deep); }

.admin-layout {
  display: flex;
  min-height: calc(100vh - var(--nav-height));
}

.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-main);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
}

.sidebar-menu { display: flex; flex-direction: column; gap: 2px; }

.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  color: var(--text-secondary);
  font-size: 0.88em;
  text-decoration: none;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-item:hover {
  background: rgba(59, 130, 246, 0.06);
  color: var(--text);
}
.sidebar-item.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-light);
  border-left-color: var(--accent);
}
.sidebar-icon { font-size: 1.1em; }

.admin-main {
  flex: 1; padding: 24px 28px;
  overflow-y: auto;
}

.admin-flash { margin-bottom: 16px; }

.admin-page-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.admin-page-header h2 { font-size: 1.2em; font-weight: 600; }
.page-desc { color: var(--text-muted); font-size: 0.82em; }

/* === Admin Table === */
.admin-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  color: var(--text-muted); font-weight: 500;
  text-align: left; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82em;
  background: rgba(0, 0, 0, 0.15);
}
.admin-table td {
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  font-size: 0.88em;
}
.admin-table tr:hover { background: rgba(59, 130, 246, 0.04); }
.admin-table tr:last-child td { border-bottom: none; }

.table-actions { display: flex; gap: 6px; }

/* === Badges === */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 4px; font-size: 0.78em; font-weight: 500;
}
.badge-admin { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.badge-user { background: rgba(59, 130, 246, 0.1); color: var(--accent-light); }
.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); margin-left: 6px; }

/* === Modal === */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 500;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px; width: 90%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.05em; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,0.05); border: none;
  color: var(--text-muted); font-size: 1.2em;
  cursor: pointer; transition: all 0.2s;
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: var(--text); }

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

/* === Admin Form Card === */
.admin-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* === LLM 测试 === */
.test-result {
  margin-top: 16px; padding: 12px 16px;
  border-radius: var(--radius); font-size: 0.85em;
}
.test-result.testing { background: rgba(59, 130, 246, 0.08); color: var(--accent-light); border: 1px solid rgba(59, 130, 246, 0.2); }
.test-result.success { background: rgba(16, 185, 129, 0.08); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.test-result.error { background: rgba(239, 68, 68, 0.08); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }

/* === 预设按钮 === */
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.preset-btn {
  background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  text-align: center; cursor: pointer; transition: all 0.2s;
}
.preset-btn:hover { border-color: var(--accent); background: rgba(59, 130, 246, 0.05); }
.preset-name { font-size: 0.88em; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.preset-url { font-size: 0.72em; color: var(--text-muted); }

/* === 系统信息 === */
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.info-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: rgba(255,255,255,0.02);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.info-label { color: var(--text-muted); font-size: 0.82em; }
.info-value { font-weight: 600; font-size: 0.88em; }

@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .admin-main { padding: 16px; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr; }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .top-nav { padding: 0 12px; }
  .nav-center { display: none; }
  .main-content { padding: 20px 16px; }
}
