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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #13131a;
  --bg-tertiary: #1a1a24;
  --bg-card: #1f1f2e;
  --border: #2a2a3a;
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.2);
  --red: #ef4444;
  --yellow: #f59e0b;
  --purple: #a855f7;
  --blue: #3b82f6;
  --cyan: #06b6d4;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  padding-bottom: 40px;
}

.app {
  display: flex;
  min-height: calc(100vh - 40px);
}

.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: calc(100vh - 40px);
  left: 0;
  top: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  white-space: nowrap;
}

.logo {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4));
  flex-shrink: 0;
}

.brand {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav {
  flex: 1;
  padding: 16px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  justify-content: flex-start;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 12px rgba(99, 102, 241, 0.2);
}

/* Read-only indicator on nav items */
.nav-item.read-only::after {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--yellow);
  margin-left: auto;
  flex-shrink: 0;
}

/* Page-level read-only mode */
.page-read-only button:not(.toast-close):not(.nav-item),
.page-read-only input:not([type="search"]),
.page-read-only textarea,
.page-read-only select,
.page-read-only .action-btn,
.page-read-only .btn {
  pointer-events: none;
  opacity: 0.5;
}

.nav-section-header {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
  padding: 16px 16px 6px; margin-top: 4px;
  user-select: none;
}
.nav-section-header:first-child { margin-top: 0; }

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

.nav-item .icon svg,
.nav-item [data-lucide] {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.75;
  flex-shrink: 0;
}

.nav-text {
  display: inline;
}

.main {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  max-width: 100%;
  overflow-x: hidden;
}

.page {
  display: none;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.card {
  background: linear-gradient(135deg, rgba(31, 31, 46, 0.8), rgba(31, 31, 46, 0.95));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15), 0 0 32px rgba(99, 102, 241, 0.1);
  transform: translateY(-2px);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.grid {
  display: grid;
  gap: 24px;
}

.grid-6 {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
  align-items: stretch;
}

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

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

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.metric-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric.green .metric-value {
  color: var(--green);
  text-shadow: 0 0 20px var(--green-glow);
}

.metric.accent .metric-value {
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}


.toolbar {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.chip:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.chip.active {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-box:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-card);
}


.agent-badge {
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  white-space: nowrap;
}
.agent-badge.agent-hunter { background: #3b82f6; }
.agent-badge.agent-finisher { background: #f59e0b; }
.agent-badge.agent-keeper { background: #8b5cf6; }
.agent-badge.agent-jade { background: #6366f1; }
.agent-badge.agent-alfred { background: #f59e0b; }
.agent-badge.agent-plume { background: #ec4899; }
.agent-badge.agent-news { background: #10b981; }
.agent-badge.agent-alex { background: #3b82f6; }
.agent-badge.agent-crm { background: #6366f1; }
.agent-badge.agent-qualifier { background: #06b6d4; }
.agent-badge.agent-main { background: #8b5cf6; }
.agent-badge.agent-default { background: #71717a; }

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.agent-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 12px rgba(99, 102, 241, 0.15);
}
.agent-card.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
}

.feed-content {
  color: var(--text-primary);
  line-height: 1.5;
  word-wrap: break-word;
}

.feed-time {
  color: var(--text-muted);
  font-size: 11px;
}

.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 12px;
  color: var(--text-muted);
  z-index: 200;
  font-family: 'JetBrains Mono', monospace;
}

.status-bar-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-bar-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green-glow);
  animation: pulse 2s ease-in-out infinite;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 16px;
  margin-bottom: 8px;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.mb-24 { margin-bottom: 24px; }

/* Mobile Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100vw;
    height: auto;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    flex-direction: row;
    padding: 0;
    z-index: 150;
  }
  .sidebar-header {
    display: none;
  }
  .nav {
    flex-direction: row;
    padding: 0;
    overflow-x: auto;
    width: 100%;
    justify-content: space-around;
  }
  .nav-item {
    flex-direction: column;
    padding: 8px 12px;
    margin: 0;
    gap: 4px;
    min-width: 60px;
  }
  .nav-item .icon {
    font-size: 20px;
  }
  .nav-text {
    opacity: 1;
    font-size: 10px;
  }
  .main {
    margin-left: 0;
    margin-bottom: 80px;
    padding: 16px;
  }
  .page-title {
    font-size: 24px;
  }
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr !important;
  }
  .system-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .table-header, .table-row {
    grid-template-columns: 24px 1fr 60px 80px !important;
    font-size: 11px;
  }
  .table-cell:nth-child(n+5) {
    display: none;
  }
  .sessions-table {
    overflow-x: auto;
  }
  .status-bar {
    font-size: 10px;
    padding: 0 12px;
    height: 32px;
    bottom: 52px;
  }
  .status-bar-section {
    gap: 8px;
  }
  .feed-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: 100%;
  }
}

/* Keyboard shortcuts overlay */
.shortcuts-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.shortcuts-overlay.active {
  display: flex;
}
.shortcuts-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
}
.shortcut-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.shortcut-key {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-tertiary);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}


/* Toast notifications — glass moderne */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(15, 15, 25, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 280px;
  position: relative;
  overflow: hidden;
  pointer-events: auto;
}

.toast.success {
  border-left: 3px solid #10b981;
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.12), 0 0 0 1px rgba(16, 185, 129, 0.08);
}

.toast.warning {
  border-left: 3px solid #f59e0b;
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.12), 0 0 0 1px rgba(245, 158, 11, 0.08);
}

.toast.info {
  border-left: 3px solid #6366f1;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.12), 0 0 0 1px rgba(99, 102, 241, 0.08);
}

.toast.error {
  border-left: 3px solid #ef4444;
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.12), 0 0 0 1px rgba(239, 68, 68, 0.08);
}

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.toast.success .toast-icon { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.toast.warning .toast-icon { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.toast.info .toast-icon { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.toast.error .toast-icon { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-message {
  font-size: 13px;
  font-weight: 600;
  color: #f4f4f5;
  line-height: 1.4;
}

.toast-submessage {
  font-size: 12px;
  color: #a1a1aa;
  margin-top: 2px;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #71717a;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.toast-close:hover {
  color: #f4f4f5;
  background: rgba(255, 255, 255, 0.08);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  border-radius: 0 0 0 14px;
  animation: toastProgress var(--toast-duration, 4s) linear forwards;
}
.toast.success .toast-progress { background: #10b981; }
.toast.warning .toast-progress { background: #f59e0b; }
.toast.info .toast-progress { background: #6366f1; }
.toast.error .toast-progress { background: #ef4444; }

.toast.fade-out {
  animation: toastSlideOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(40px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastSlideOut {
  to {
    opacity: 0;
    transform: translateX(40px) scale(0.96);
  }
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* Sections */
.nav-group { display: none; flex: 1; flex-direction: column; }
.nav-group.active { display: flex; }


/* Page Notes */
.page-notes-btn {
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.page-notes-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* === WhatsApp Settings === */
.wa-state { display: none; }

.wa-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}

.wa-status-dot--green {
  background: var(--green);
  box-shadow: 0 0 6px var(--green-glow);
}

.wa-status-dot--orange {
  background: var(--yellow);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.3);
  animation: waPulse 2s ease-in-out infinite;
}

.wa-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.wa-info-grid .wa-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wa-info-grid .wa-info-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.wa-info-grid .wa-info-value {
  font-size: 14px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

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

/* ============================================
   Sidebar collapsible navigation (Session 1)
   ============================================ */

/* === SPACE TABS === */
.space-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0;
  flex-shrink: 0;
}
.space-tab {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  user-select: none;
}
.space-tab:hover {
  color: var(--text-primary);
}
.space-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* === COLLAPSIBLE SECTIONS === */
.nav-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  margin-top: 4px;
}
.nav-section-title:hover {
  color: var(--text-primary);
}
.nav-section-chevron {
  font-size: 10px;
  transition: transform 0.2s;
  display: inline-block;
  width: 12px;
}
.nav-section-title.collapsed .nav-section-chevron {
  transform: rotate(-90deg);
}

/* Quand une section est collapsed, masquer le nav-group suivant */
.nav-section-title.collapsed + .nav-group {
  display: none !important;
}
