/* Feuille de style globale, utilisee partout */
/* Variables CSS, dark mode, reset minimal, typographie, classes utilitaires */
/* Interdiction formelle d'ecrire des styles specifiques, utiliser des composants ou des pages */

/* === Variables CSS === */
:root {
  /* Couleurs principales */
  --color-bg: #0f0f13;
  --color-bg-secondary: #1a1a24;
  --color-bg-tertiary: #23233a;
  --color-bg-hover: #2a2a42;
  --color-bg-active: #32325a;

  /* Surfaces (cartes, modales, panels) */
  --color-surface: #1a1a24;
  --color-surface-raised: #23233a;
  --color-surface-overlay: #2a2a42;

  /* Texte */
  --color-text: #e4e4ed;
  --color-text-secondary: #9999b3;
  --color-text-muted: #66667a;
  --color-text-inverse: #0f0f13;

  /* Accent / Primaire */
  --color-primary: #6c5ce7;
  --color-primary-hover: #7c6ef7;
  --color-primary-active: #5a4bd4;
  --color-primary-muted: rgba(108, 92, 231, 0.15);

  /* Statuts semantiques */
  --color-success: #00d68f;
  --color-success-muted: rgba(0, 214, 143, 0.15);
  --color-warning: #ffaa00;
  --color-warning-muted: rgba(255, 170, 0, 0.15);
  --color-error: #ff3d71;
  --color-error-muted: rgba(255, 61, 113, 0.15);
  --color-info: #0095ff;
  --color-info-muted: rgba(0, 149, 255, 0.15);

  /* Statuts de session (Instalink.SessionState) */
  --color-status-pending: #9999b3;
  --color-status-running: #0095ff;
  --color-status-paused: #ffaa00;
  --color-status-standby: #a78bfa;
  --color-status-interrupted: #ff3d71;
  --color-status-stopped: #ff3d71;
  --color-status-completed: #00d68f;

  /* Etapes du funnel (Lead.LeadFunnelStep) */
  --color-funnel-discovered: #6b7280;
  --color-funnel-discovered-bg: rgba(107, 114, 128, 0.15);
  --color-funnel-dm: #0095ff;
  --color-funnel-dm-bg: rgba(0, 149, 255, 0.15);
  --color-funnel-response: #ffaa00;
  --color-funnel-response-bg: rgba(255, 170, 0, 0.15);
  --color-funnel-qualified: #f97316;
  --color-funnel-qualified-bg: rgba(249, 115, 22, 0.15);
  --color-funnel-call: #a78bfa;
  --color-funnel-call-bg: rgba(167, 139, 250, 0.15);
  --color-funnel-sell: #00d68f;
  --color-funnel-sell-bg: rgba(0, 214, 143, 0.15);

  /* Bordures */
  --color-border: #2a2a3d;
  --color-border-hover: #3d3d5c;
  --color-border-focus: var(--color-primary);

  /* Espacements */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Bordures arrondies */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Ombres */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  /* Typographie */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  /* Z-index */
  --z-sidebar: 100;
  --z-overlay: 200;
  --z-modal: 300;
  --z-toast: 400;
  --z-tooltip: 500;

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;

  /* DataTable */
  --table-row-height: 48px;
  --table-header-height: 44px;

  /* Wizard */
  --wizard-max-width: 640px;
}

/* === Reset CSS === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow: hidden;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  color: var(--color-primary-hover);
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--color-text);
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  outline: none;
  transition: border-color var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--color-border-focus);
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

/* === Typographie === */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.2;
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

/* === Classes utilitaires === */
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }
.text-info { color: var(--color-info); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.hidden { display: none !important; }

/* === Scrollbar custom === */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-bg-hover);
}

/* === Bouton primaire (base, reutilisable) === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.btn-primary:active {
  background-color: var(--color-primary-active);
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-text);
}

.btn-danger {
  background-color: var(--color-error);
  color: #fff;
}

.btn-danger:hover {
  background-color: #e6365f;
}

.btn-icon {
  padding: var(--space-sm);
  min-width: 36px;
  min-height: 36px;
}

.btn-sm {
  padding: 2px var(--space-sm);
  font-size: var(--font-size-xs);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-md);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* === Badges / Tags === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.4;
  cursor: default;
}

.badge-clickable {
  cursor: pointer;
  transition: filter var(--transition-fast);
}

.badge-clickable:hover {
  filter: brightness(1.2);
}

/* Badges funnel */
.badge-discovered { color: var(--color-funnel-discovered); background: var(--color-funnel-discovered-bg); }
.badge-dm { color: var(--color-funnel-dm); background: var(--color-funnel-dm-bg); }
.badge-response { color: var(--color-funnel-response); background: var(--color-funnel-response-bg); }
.badge-qualified { color: var(--color-funnel-qualified); background: var(--color-funnel-qualified-bg); }
.badge-call { color: var(--color-funnel-call); background: var(--color-funnel-call-bg); }
.badge-sell { color: var(--color-funnel-sell); background: var(--color-funnel-sell-bg); }

/* === Cards statistiques === */
.stat-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  transition: border-color var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--color-border-hover);
}

.stat-card-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.stat-card-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
}

.stat-card-trend {
  font-size: var(--font-size-xs);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-card-trend.up { color: var(--color-success); }
.stat-card-trend.down { color: var(--color-error); }

/* === Grilles de stats === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

/* === Animations === */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in-up {
  animation: fadeInUp 250ms ease;
}

.icon-spin {
  animation: spin 1s linear infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* === Inline edit === */
.inline-edit {
  cursor: pointer;
  padding: 2px var(--space-xs);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  min-height: 28px;
  display: flex;
  align-items: center;
}

.inline-edit:hover {
  border-color: var(--color-border);
  background-color: var(--color-bg-secondary);
}

.inline-edit.editing {
  border-color: var(--color-border-focus);
  background-color: var(--color-bg-secondary);
  cursor: text;
}

.inline-edit-input {
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: inherit;
  font-family: inherit;
  width: 100%;
  outline: none;
  padding: 0;
}

/* === Page layout === */
.page {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  height: 100%;
}

.page-toolbar {
  flex-shrink: 0;
}

/* === Section deroulante (accordeon) === */
.collapsible-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  user-select: none;
  transition: color var(--transition-fast);
}

.collapsible-header:hover {
  color: var(--color-text);
}

.collapsible-header .icon-chevron {
  transition: transform var(--transition-fast);
  width: 16px;
  height: 16px;
}

.collapsible-header.open .icon-chevron {
  transform: rotate(180deg);
}

.collapsible-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--transition-normal);
}

.collapsible-content.open {
  max-height: 1000px;
}

/* === Wizard steps === */
.wizard-container {
  max-width: var(--wizard-max-width);
  margin: 0 auto;
}

.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.wizard-step-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--color-bg-tertiary);
  transition: background var(--transition-fast);
}

.wizard-step-dot.active {
  background: var(--color-primary);
}

.wizard-step-dot.completed {
  background: var(--color-success);
}

.wizard-step-line {
  width: 40px;
  height: 2px;
  background: var(--color-bg-tertiary);
}

.wizard-step-line.completed {
  background: var(--color-success);
}

/* Boutons de choix type wizard (2 gros carres) */
.wizard-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.wizard-choice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xl);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  text-align: center;
}

.wizard-choice-card:hover {
  border-color: var(--color-primary-muted);
  background: var(--color-surface-raised);
}

.wizard-choice-card.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-muted);
}

.wizard-choice-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.wizard-choice-card .choice-icon {
  width: 48px;
  height: 48px;
  color: var(--color-primary);
}

.wizard-choice-card .choice-icon svg {
  width: 48px;
  height: 48px;
}

.wizard-choice-card .choice-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text);
}

.wizard-choice-card .choice-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* === Overlay / Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 150ms ease;
}

.modal-window {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: fadeInUp 200ms ease;
  z-index: var(--z-modal);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.modal-body {
  flex: 1;
  padding: var(--space-lg);
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* === Formulaires === */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.form-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* === Scrollbar pour zones specifiques === */
.custom-scrollbar::-webkit-scrollbar {
  width: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* === Toast container === */
#toast-container {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in 250ms ease forwards;
}

.toast.toast-error { border-color: var(--color-error); }
.toast.toast-success { border-color: var(--color-success); }
.toast.toast-warning { border-color: var(--color-warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
