﻿/* ===== DESIGN SYSTEM ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-base: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-glass: rgba(15,23,42,0.035);
  --bg-glass-hover: rgba(15,23,42,0.07);
  --border: rgba(15,23,42,0.10);
  --border-hover: rgba(15,23,42,0.20);

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

  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-orange: #f97316;

  --glow-blue: 0 0 30px rgba(59,130,246,0.25);
  --glow-purple: 0 0 30px rgba(139,92,246,0.25);
  --glow-green: 0 0 30px rgba(16,185,129,0.25);

  --sidebar-w: 260px;
  --header-h: 70px;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== BACKGROUND EFFECTS ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(59,130,246,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(139,92,246,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(16,185,129,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ===== LAYOUT ===== */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ===== HEADER ===== */
.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 0 0;
  background: rgba(7,11,20,0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0;
  width: var(--sidebar-w);
  padding: 0 20px;
  border-right: 1px solid var(--border);
  height: 100%;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 20px rgba(139,92,246,0.4);
  flex-shrink: 0;
}

.brand-text {
  margin-left: 12px;
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-stats {
  display: flex;
  gap: 6px;
  flex: 1;
  padding: 0 24px;
}

.header-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: default;
  transition: var(--transition);
}

.header-stat:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
}

.stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.stat-dot.green { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.stat-dot.blue { background: var(--accent-blue); box-shadow: 0 0 8px var(--accent-blue); }
.stat-dot.amber { background: var(--accent-amber); box-shadow: 0 0 8px var(--accent-amber); }

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

.stat-label { font-size: 11px; color: var(--text-muted); }
.stat-value { font-size: 13px; font-weight: 700; color: var(--text-primary); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-settings {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-settings:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.api-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid;
  cursor: pointer;
  transition: var(--transition);
}

.api-badge.connected {
  background: rgba(16,185,129,0.1);
  border-color: rgba(16,185,129,0.3);
  color: var(--accent-green);
}

.api-badge.disconnected {
  background: rgba(244,63,94,0.1);
  border-color: rgba(244,63,94,0.3);
  color: var(--accent-rose);
}

/* ===== SIDEBAR ===== */
.app-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 10px;
  margin: 16px 0 8px;
}

.sidebar-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
  transition: var(--transition);
}

.nav-item:hover {
  background: var(--bg-glass);
  border-color: var(--border);
}

.nav-item.active {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
}

.nav-item.active::before {
  background: var(--dept-color, var(--accent-blue));
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item.active .nav-label { color: var(--text-primary); }

.nav-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg-glass);
  color: var(--text-muted);
  flex-shrink: 0;
}

.nav-item.active .nav-badge {
  background: var(--dept-color, var(--accent-blue));
  color: white;
  opacity: 0.9;
}

/* ===== MAIN CONTENT ===== */
.app-main {
  padding: 28px;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-h));
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 6px;
}

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

/* ===== OVERVIEW CARDS ===== */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.overview-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: default;
}

.overview-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.overview-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--card-accent, linear-gradient(90deg, #3b82f6, #8b5cf6));
}

.ov-icon {
  font-size: 24px;
  margin-bottom: 14px;
  display: block;
}

.ov-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

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

.ov-change {
  font-size: 11px;
  color: var(--accent-green);
  font-weight: 600;
  margin-top: 6px;
}

/* ===== DEPT SECTION ===== */
.dept-section {
  margin-bottom: 36px;
}

.dept-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.dept-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dept-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.dept-title { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.dept-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.dept-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
}

/* ===== AGENT GRID ===== */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

/* ===== AGENT CARD ===== */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.agent-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.agent-card.clickable:hover {
  border-color: var(--accent-blue);
  box-shadow: var(--glow-blue);
}

.agent-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.agent-icon {
  font-size: 22px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.agent-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.active { background: rgba(16,185,129,0.15); color: #059669; border: 1px solid rgba(16,185,129,0.3); }
.status-badge.building { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.status-badge.planned { background: rgba(148,163,184,0.1); color: #94a3b8; border: 1px solid rgba(148,163,184,0.2); }
.status-badge.coming-soon { background: rgba(148,163,184,0.1); color: #94a3b8; border: 1px solid rgba(148,163,184,0.2); }

/* ===== DEMO DATA BANNER (dashboard) ===== */
.demo-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(244,63,94,0.1);
  border: 1px solid rgba(244,63,94,0.4);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 12.5px;
  color: #e11d48;
  line-height: 1.6;
  margin-bottom: 18px;
}
.demo-banner .db-icon { font-size: 16px; flex-shrink: 0; line-height: 1.4; }
.demo-banner strong { color: #fecdd3; }

.real-banner-global {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.4);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 12.5px;
  color: #059669;
  line-height: 1.6;
  margin-bottom: 18px;
}
.real-banner-global .db-icon { font-size: 16px; flex-shrink: 0; line-height: 1.4; }
.real-banner-global strong { color: #a7f3d0; }

.phase-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg-glass);
  border-radius: 20px;
}

.agent-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
}

.agent-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

.agent-capabilities {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 14px;
}

.cap-tag {
  font-size: 10px;
  font-weight: 500;
  padding: 3px 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.agent-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.metric-item { text-align: center; }
.metric-value { font-size: 15px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.metric-label { font-size: 9px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

.launch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 12px;
  padding: 9px;
  background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(139,92,246,0.2));
  border: 1px solid rgba(99,102,241,0.4);
  border-radius: var(--radius-sm);
  color: #4f46e5;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.launch-btn:hover {
  background: linear-gradient(135deg, rgba(59,130,246,0.35), rgba(139,92,246,0.35));
  border-color: rgba(99,102,241,0.7);
  color: white;
  box-shadow: 0 0 20px rgba(99,102,241,0.3);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  transform: translateY(16px) scale(0.97);
  transition: var(--transition);
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

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

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.form-input::placeholder { color: var(--text-muted); }

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

.btn-primary {
  flex: 1;
  padding: 11px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(139,92,246,0.4);
}

.btn-secondary {
  padding: 11px 20px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

/* ===== 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); }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.fade-in { animation: fadeInUp 0.4s ease forwards; }

.agent-card { animation: fadeInUp 0.3s ease forwards; opacity: 0; }

/* ===== SEARCH BAR ===== */
.search-wrap {
  position: relative;
  margin-bottom: 28px;
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 18px 13px 46px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

/* ===== PHASE FILTER ===== */
.filter-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.filter-btn:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.filter-btn.active { background: rgba(59,130,246,0.2); border-color: rgba(59,130,246,0.5); color: #2563eb; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .overview-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
  .header-stats { display: none; }
}
