/* ── CampAIgn Research Workbench -- Design System ────────────────────────── */

:root {
  /* Brand */
  --brand: #0028B8;
  --brand-dark: #001a7a;
  --brand-light: #e8f0fe;
  --brand-50: #f0f4ff;
  --accent: #FF4D6A;
  --accent-light: #fff0f3;

  /* Neutrals */
  --surface: #ffffff;
  --bg: #f5f6fa;
  --bg-hover: #eef0f6;
  --border: #e5e7eb;
  --border-light: #f0f1f5;
  --ink: #1a1a2e;
  --ink2: #4b5563;
  --ink3: #9ca3af;
  --ink4: #d1d5db;

  /* Semantic */
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #3b82f6;

  /* Layout */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-hover: 0 8px 24px rgba(0, 40, 184, 0.12);

  /* Transition */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;
  --duration-slow: 350ms;
}

/* ── Reset + Base ────────────────────────────────────────────────────────── */

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

html, body {
  height: 100%;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}

a:hover { color: var(--brand-dark); }

button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink3); }

/* ── Navbar ──────────────────────────────────────────────────────────────── */

.navbar {
  background: #fff;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0, 40, 184, 0.06);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-brand:hover { color: var(--ink); }

.navbar .logo {
  height: 32px;
  object-fit: contain;
}

.navbar .brand-text {
  color: var(--ink);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
}

.nav-pills {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink3);
  transition: all var(--duration) var(--ease);
  text-decoration: none;
  white-space: nowrap;
}

.nav-pill:hover {
  background: var(--bg-hover);
  color: var(--ink2);
}

.nav-pill.active {
  background: var(--brand);
  color: #fff;
}

.nav-pill.active:hover {
  background: var(--brand-dark);
  color: #fff;
}

.nav-pill iconify-icon {
  font-size: 16px;
}

.navbar .spacer { flex: 1; }

.navbar .user-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.user-name {
  color: var(--ink2);
  font-size: 14px;
  font-weight: 500;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink2);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
}

.btn-ghost:hover {
  background: var(--brand-light);
  color: var(--brand);
}

/* ── Page Container ──────────────────────────────────────────────────────── */

.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Status Bar ──────────────────────────────────────────────────────────── */

.status-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--success-light);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #059669;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

.pulse-dot-sm {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Section ─────────────────────────────────────────────────────────────── */

.section {
  margin-bottom: 36px;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header .subtitle {
  color: var(--ink3);
  font-size: 14px;
  margin-top: 4px;
}

/* ── Session Cards ───────────────────────────────────────────────────────── */

.sessions-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-card {
  background: var(--surface);
  border: 1.5px solid var(--success);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all var(--duration) var(--ease);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08);
}

.session-card:hover {
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.12);
}

.session-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.session-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.session-icon.running {
  background: var(--success-light);
  color: var(--success);
}

.session-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.session-meta {
  font-size: 13px;
  color: var(--ink3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink4);
}

.session-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Project Cards ───────────────────────────────────────────────────────── */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1.5px solid var(--border-light);
  transition: all var(--duration-slow) var(--ease);
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

.project-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.project-card:hover::before {
  opacity: 1;
}

.project-card.has-session {
  border-color: var(--success);
}

.project-card.has-session::before {
  background: linear-gradient(90deg, var(--success), #34d399);
  opacity: 1;
}

.project-card .card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.project-card .card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.project-card .card-body {
  min-width: 0;
}

.project-card .card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  letter-spacing: -0.2px;
}

.project-card .card-desc {
  font-size: 13px;
  color: var(--ink3);
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card .card-status {
  margin-bottom: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.running {
  background: var(--success-light);
  color: #059669;
}

.project-card .card-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.project-card .card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink3);
}

.card-action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink3);
  font-size: 16px;
  transition: all var(--duration) var(--ease);
  text-decoration: none;
  flex-shrink: 0;
}

.card-action-btn:hover {
  background: var(--brand-50);
  color: var(--brand);
}

.project-card .card-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 40, 184, 0.25);
}

.btn-primary:hover {
  background: var(--brand-dark);
  box-shadow: 0 4px 12px rgba(0, 40, 184, 0.35);
  transform: translateY(-1px);
  color: white;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink2);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-50);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}

.btn-danger-outline:hover {
  background: var(--danger-light);
}

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

/* ── Info Section ────────────────────────────────────────────────────────── */

.info-section {
  margin-top: 48px;
}

.info-card {
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  background: var(--brand-50);
  border: 1px solid var(--brand-light);
  border-radius: var(--radius-lg);
}

.info-card .info-icon {
  font-size: 22px;
  color: var(--brand);
  flex-shrink: 0;
  margin-top: 2px;
}

.info-card strong {
  font-size: 14px;
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}

.info-card p {
  font-size: 13px;
  color: var(--ink2);
  line-height: 1.5;
  margin: 0;
}

/* ── Empty State ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: var(--ink3);
  animation: fadeIn 0.5s var(--ease);
}

.empty-state .empty-icon {
  font-size: 64px;
  color: var(--ink4);
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink2);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

/* ── Loading ─────────────────────────────────────────────────────────────── */

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px;
  color: var(--ink3);
  font-size: 14px;
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--ink);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 400px;
  animation: slideInRight 0.3s var(--ease);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

.toast.removing {
  animation: slideOutRight 0.3s var(--ease) forwards;
}

/* ── Animations ──────────────────────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .projects-grid {
    grid-template-columns: 1fr;
  }

  .session-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .session-actions {
    width: 100%;
  }

  .session-actions .btn {
    flex: 1;
  }
}

@media (max-width: 768px) {
  .nav-pills {
    display: none;
  }
}

@media (max-width: 600px) {
  .page-container {
    padding: 20px 16px;
  }

  .navbar {
    padding: 0 16px;
  }

  .project-card .card-buttons {
    margin-left: 0;
    width: 100%;
  }

  .project-card .card-buttons .btn {
    flex: 1;
  }

  .project-card .card-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
