/* Variables de design */
:root {
  --bg: #0f0f0f;
  --bg-card: #1a1a1a;
  --bg-surface: #222222;
  --bg-hover: #2a2a2a;
  --accent: #c8f135;
  --accent-dim: rgba(200, 241, 53, 0.15);
  --text: #f0f0f0;
  --text-muted: #888888;
  --border: #333333;
  --border-light: #444444;
  --font-heading: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius: 8px;
  --radius-sm: 4px;

  /* Couleurs des statuts */
  --status-nouveau: #3b82f6;
  --status-contacte: #22c55e;
  --status-repondu: #eab308;
  --status-call: #a855f7;
  --status-devis: #06b6d4;
  --status-signe: #c8f135;
  --status-perdu: #ef4444;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.5;
  min-height: 100vh;
}

/* Utilitaires */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.font-heading { font-family: var(--font-heading); }

/* ── PAGE LOGIN ─────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.65rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #0f0f0f;
  width: 100%;
}
.btn-primary:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-danger {
  background: var(--status-perdu);
  color: #fff;
}
.btn-danger:hover { opacity: 0.85; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.error-msg {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #f87171;
  font-size: 0.82rem;
  padding: 0.6rem 0.75rem;
  margin-top: 0.75rem;
}

/* ── LAYOUT APP ─────────────────────────────────────── */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
  gap: 1rem;
}

.app-brand {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1rem;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: -0.3px;
}

/* Navigation par onglets */
.app-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-tab:hover { color: var(--text); background: var(--bg-hover); }
.nav-tab.active { color: var(--accent); background: var(--accent-dim); }

.header-actions { display: flex; align-items: center; gap: 0.75rem; }

.notif-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.notif-btn:hover { border-color: var(--accent); color: var(--accent); }
.notif-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-mono);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.logout-btn:hover { color: var(--status-perdu); }

/* Contenu des onglets */
.app-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}
.tab-content.active {
  display: flex;
}

/* ── KANBAN PIPELINE ────────────────────────────────── */
.kanban-wrapper {
  overflow-x: auto;
  flex: 1;
  padding: 1.25rem 1.5rem;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(220px, 1fr));
  gap: 0.75rem;
  min-width: 1540px;
  height: 100%;
}

.kanban-column {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
}

.kanban-column.drag-over {
  border-color: var(--accent);
  background: rgba(200, 241, 53, 0.04);
}

.kanban-col-header {
  padding: 0.75rem 0.9rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.kanban-col-title {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.col-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kanban-col-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.75rem;
  cursor: grab;
  transition: background 0.12s, transform 0.1s;
  user-select: none;
}

.kanban-card:hover { background: var(--bg-hover); }
.kanban-card:active { cursor: grabbing; transform: scale(0.98); }
.kanban-card.dragging { opacity: 0.5; }

.card-nom {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.card-badges { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── BADGES STATUT ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  white-space: nowrap;
}

.badge-nouveau  { background: rgba(59,130,246,0.15);  color: #60a5fa; }
.badge-contacte { background: rgba(34,197,94,0.15);   color: #4ade80; }
.badge-repondu  { background: rgba(234,179,8,0.15);   color: #facc15; }
.badge-call     { background: rgba(168,85,247,0.15);  color: #c084fc; }
.badge-devis    { background: rgba(6,182,212,0.15);   color: #22d3ee; }
.badge-signe    { background: rgba(200,241,53,0.15);  color: #c8f135; }
.badge-perdu    { background: rgba(239,68,68,0.15);   color: #f87171; }

.badge-offre {
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-relance {
  background: rgba(200,241,53,0.1);
  color: var(--accent);
}

/* ── ONGLET PROSPECTS (tableau) ─────────────────────── */
.tab-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  outline: none;
  width: 240px;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

.filter-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.5rem 0.6rem;
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--accent); }

.toolbar-spacer { flex: 1; }

.table-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.5rem 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead { position: sticky; top: 0; z-index: 2; }

th {
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover { background: var(--bg-card); }

/* ── ONGLET RELANCES ────────────────────────────────── */
.relances-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.relance-section-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.relance-cards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.relance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.relance-card.urgente { border-left: 3px solid var(--status-perdu); }
.relance-card.bientot { border-left: 3px solid var(--status-repondu); }
.relance-card.planifiee { border-left: 3px solid var(--border); }

.relance-info { flex: 1; min-width: 200px; }
.relance-nom {
  font-family: var(--font-heading);
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.relance-meta { font-size: 0.78rem; color: var(--text-muted); }
.relance-label {
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

.relance-timing { text-align: right; font-size: 0.8rem; }
.timing-due { color: var(--status-perdu); font-weight: 600; }
.timing-bientot { color: var(--status-repondu); }
.timing-ok { color: var(--status-contacte); }

.relance-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 0.5rem 0;
}

/* ── ONGLET ANALYTICS ───────────────────────────────── */
.analytics-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
  align-content: start;
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.analytics-card-title {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* CA Progress */
.ca-numbers {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.ca-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
}

.ca-objectif { font-size: 0.8rem; color: var(--text-muted); }

.progress-bar {
  background: var(--bg-surface);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.ca-subtext { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.5rem; }

/* Funnel */
.funnel-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.funnel-label { font-size: 0.8rem; color: var(--text-muted); width: 100px; flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; background: var(--bg-surface); border-radius: 3px; height: 20px; overflow: hidden; }
.funnel-bar { height: 100%; background: var(--accent); opacity: 0.7; border-radius: 3px; transition: width 0.5s ease; }
.funnel-count { font-size: 0.8rem; color: var(--text); width: 30px; text-align: right; flex-shrink: 0; }

/* Listes de répartition */
.breakdown-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.breakdown-label { font-size: 0.8rem; color: var(--text-muted); width: 100px; flex-shrink: 0; }
.breakdown-bar-wrap { flex: 1; background: var(--bg-surface); border-radius: 3px; height: 16px; overflow: hidden; }
.breakdown-bar { height: 100%; background: var(--accent); opacity: 0.6; border-radius: 3px; transition: width 0.5s ease; }
.breakdown-count { font-size: 0.78rem; color: var(--text-muted); width: 40px; text-align: right; flex-shrink: 0; }

/* Métriques */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.metric-item {
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.metric-label { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.metric-value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
}

/* ── MODAL ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.modal-body .form-group.full-width { grid-column: 1 / -1; }

textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s;
}
textarea:focus { border-color: var(--accent); }

select {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  cursor: pointer;
}
select:focus { border-color: var(--accent); }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Couleurs des colonnes kanban */
[data-statut="nouveau"] .col-dot    { background: var(--status-nouveau); }
[data-statut="contacte"] .col-dot   { background: var(--status-contacte); }
[data-statut="repondu"] .col-dot    { background: var(--status-repondu); }
[data-statut="call"] .col-dot       { background: var(--status-call); }
[data-statut="devis"] .col-dot      { background: var(--status-devis); }
[data-statut="signe"] .col-dot      { background: var(--status-signe); }
[data-statut="perdu"] .col-dot      { background: var(--status-perdu); }

[data-statut="nouveau"] .kanban-card  { border-left-color: var(--status-nouveau); }
[data-statut="contacte"] .kanban-card { border-left-color: var(--status-contacte); }
[data-statut="repondu"] .kanban-card  { border-left-color: var(--status-repondu); }
[data-statut="call"] .kanban-card     { border-left-color: var(--status-call); }
[data-statut="devis"] .kanban-card    { border-left-color: var(--status-devis); }
[data-statut="signe"] .kanban-card    { border-left-color: var(--status-signe); }
[data-statut="perdu"] .kanban-card    { border-left-color: var(--status-perdu); }

/* Scrollbar custom */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
