/* ==========================================
   WeCom Push Gateway — Light Glassmorphism UI
   ========================================== */

:root {
  --bg-app: #f4f7f6; /* Fallback */
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.07);
  
  --bg-input: rgba(255, 255, 255, 0.8);
  --bg-hover: rgba(255, 255, 255, 0.9);
  
  --border: rgba(148, 163, 184, 0.2);
  --border-focus: #3b82f6;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --accent-bg: rgba(59, 130, 246, 0.1);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);

  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  /* Premium light gradient background */
  background: 
    radial-gradient(circle at 15% 50%, rgba(200, 235, 255, 0.6) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(225, 215, 255, 0.6) 0%, transparent 50%),
    #e2e8f0;
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---- Glassmorphism Utility ---- */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.text-gradient {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Lucide Icon adjustments */
.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  vertical-align: middle;
}
.icon-xl {
  width: 48px;
  height: 48px;
  stroke-width: 1.5;
}

/* ---- Screens ---- */
.screen { display: none; opacity: 0; transition: opacity var(--transition); }
.screen.active { display: block; opacity: 1; }

/* ---- Login ---- */
#login-screen {
  display: none;
  min-height: 100vh;
  justify-content: center;
  align-items: center;
  /* Enhanced animated background for login */
  background: 
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.2), transparent 40%),
    radial-gradient(circle at bottom right, rgba(139, 92, 246, 0.2), transparent 40%),
    #f8fafc;
}
#login-screen.active { display: flex; }

.login-card {
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 420px;
  max-width: 90vw;
  text-align: center;
}
.login-logo { margin-bottom: 16px; }
.login-card h1 { font-size: 26px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.login-subtitle { color: var(--text-secondary); margin-bottom: 32px; font-size: 15px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 20px; text-align: left; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.form-group small {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--accent-bg);
}
textarea { resize: vertical; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  transition: all var(--transition);
  gap: 8px;
}
.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  background: var(--glass-bg);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: rgba(0,0,0,0.1);
}
.btn-danger {
  background: var(--error-bg);
  color: var(--error);
}
.btn-danger:hover {
  background: var(--error);
  color: #fff;
}
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-full { width: 100%; }

.error-msg {
  color: var(--error);
  background: var(--error-bg);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 16px;
  border-left: 4px solid var(--error);
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 64px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-family: 'Outfit', sans-serif; font-size: 18px; font-weight: 700; color: var(--text-primary); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { font-size: 14px; font-weight: 500; color: var(--text-secondary); }

/* ---- Layout ---- */
.layout {
  display: flex;
  min-height: calc(100vh - 64px);
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar {
  width: 240px;
  margin: 24px;
  border-radius: var(--radius-lg);
  padding: 16px 8px;
  flex-shrink: 0;
  align-self: flex-start;
  position: sticky;
  top: 88px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.nav-item.active {
  color: var(--accent);
  background: var(--accent-bg);
}
.nav-item.active .lucide {
  stroke: var(--accent);
}

.content {
  flex: 1;
  padding: 24px;
}

/* ---- Pages ---- */
.page { display: none; animation: fadeIn 0.4s ease forwards; }
.page.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page h2 { font-size: 28px; margin-bottom: 32px; color: var(--text-primary); }
.page h3 { font-size: 18px; margin: 32px 0 16px; color: var(--text-primary); }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.page-header h2 { margin-bottom: 0; }

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}
.stat-card {
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(31, 38, 135, 0.1); }
.stat-icon {
  position: absolute;
  top: 24px;
  right: 24px;
  color: var(--accent);
  opacity: 0.2;
}
.stat-icon .lucide { width: 48px; height: 48px; }
.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 42px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 8px;
}
.stat-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ---- Card List ---- */
.card-list { display: flex; flex-direction: column; gap: 16px; }

.agent-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}
.agent-card:hover { 
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 8px 24px rgba(31, 38, 135, 0.05);
}
.agent-info { flex: 1; }
.agent-name { 
  font-family: 'Outfit', sans-serif;
  font-weight: 600; 
  font-size: 16px; 
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-meta { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.agent-url {
  font-size: 12px;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  background: var(--accent-bg);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-top: 8px;
}
.agent-actions { display: flex; gap: 12px; }

.status-dot {
  display: inline-block;
  color: var(--text-muted);
}
.status-dot.ok { color: var(--success); }
.status-dot.err { color: var(--error); }
.status-dot.warn { color: var(--warning); }

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal.show { opacity: 1; pointer-events: auto; }
.modal-content {
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 480px;
  max-width: 90vw;
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal.show .modal-content { transform: translateY(0); }
.modal-content h3 { margin-top: 0; margin-bottom: 24px; color: var(--text-primary); }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 32px; }

/* ---- Log List (dashboard) ---- */
.log-list { display: flex; flex-direction: column; gap: 8px; }

.log-entry {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  font-size: 13px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  transition: background var(--transition);
}
.log-entry:hover { background: rgba(255, 255, 255, 0.8); }
.log-time { color: var(--text-muted); font-family: 'Courier New', monospace; white-space: nowrap; }
.log-agent {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.log-type { color: var(--text-secondary); font-weight: 500; min-width: 70px; }
.log-to { color: var(--text-secondary); min-width: 50px; }
.log-status { display: flex; align-items: center; }
.log-status.success { color: var(--success); }
.log-status.error { color: var(--error); }
.log-content { color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Log Table (logs page) ---- */
.log-table-wrap { 
  border-radius: var(--radius-lg); 
  overflow: hidden;
  border: 1px solid var(--border);
}
.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.log-table th {
  text-align: left;
  padding: 16px;
  background: rgba(255, 255, 255, 0.4);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.log-table td {
  padding: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  vertical-align: middle;
  color: var(--text-primary);
}
.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td { background: rgba(255, 255, 255, 0.6); }

/* ---- Config Form ---- */
.config-form { max-width: 540px; }
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* ---- Result Box ---- */
.result-box {
  margin-top: 24px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
}
.result-box.success { border-left: 4px solid var(--success); }
.result-box.error { border-left: 4px solid var(--error); }

/* ---- Docs ---- */
.docs-content { max-width: 800px; }
.docs-content pre {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin-bottom: 24px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
}
.docs-content code {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  color: var(--accent-hover);
}
.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 32px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius);
  overflow: hidden;
}
.doc-table th, .doc-table td {
  padding: 12px 16px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.doc-table th {
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-secondary);
  font-weight: 600;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2000;
}
.toast {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast .lucide { width: 20px; height: 20px; }

@keyframes slideIn {
  from { transform: translateX(100%) scale(0.9); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { 
    width: auto; 
    margin: 16px; 
    position: static;
    display: flex;
    overflow-x: auto;
  }
  .nav-item { padding: 8px 16px; white-space: nowrap; }
  .nav-item .nav-text { display: none; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
}
