:root {
  --bg: #f8fafc;
  --bg-alt: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --danger: #ef4444;
}

/* Thème sombre noir profond */
body.dark {
  --bg: #050816;
  --bg-alt: #050816;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #111827;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

body {
  background: radial-gradient(circle at top, #e0f2fe 0, transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* en dark on vire le gradient */
body.dark {
  background: var(--bg);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.header p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Onglets */

.tabs {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  margin-bottom: 20px;
}

.tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--muted);
}

.tab.active {
  background: var(--bg-alt);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
}

/* Cartes & formulaire */

.card {
  background: var(--bg-alt);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 18px 16px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
  margin-bottom: 20px;
}

.form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.85rem;
  color: var(--muted);
}

.field input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.field input::placeholder {
  color: var(--muted);
}

.field input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.field-checkbox {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--muted);
}

.field-checkbox input {
  margin-right: 6px;
}

/* Boutons */

.btn-primary,
.btn-secondary {
  padding: 9px 14px;
  border-radius: 999px;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: transform 0.08s ease, box-shadow 0.08s ease,
    background-color 0.1s ease, filter 0.08s ease;
}

.btn-primary {
  background: var(--accent);
  color: #f9fafb;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--accent-soft);
}

/* Variante danger pour le bouton Supprimer */
.btn-danger {
  background: var(--danger);
  color: #fef2f2;
  box-shadow: 0 8px 24px rgba(248, 113, 113, 0.4);
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

/* Texte d'état */

.status {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

/* Résultats de recherche */

.results-section h2 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.lead-card {
  background: var(--bg-alt);
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lead-card h3 {
  font-size: 1rem;
  font-weight: 600;
}

.lead-card .address {
  font-size: 0.85rem;
  color: var(--muted);
}

.lead-card .info {
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lead-card a {
  color: var(--accent);
  text-decoration: none;
}

.lead-card a:hover {
  text-decoration: underline;
}

.badge-no-site {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  background: var(--accent-soft);
}

.lead-actions {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* Modal générique */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background-color: var(--bg);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

.modal-dialog {
  position: relative;
  z-index: 60;
  width: min(680px, 100% - 32px);
  background: var(--bg-alt);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 18px 18px 14px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.modal-header h2 {
  font-size: 1.1rem;
}

.modal-close {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.modal-close:hover {
  background: var(--accent-soft);
}

/* Croix rouge en dark */
body.dark .modal-close {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.8);
}

body.dark .modal-close:hover {
  background: rgba(248, 113, 113, 0.12);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Zone chat IA */

.ai-loading {
  margin-bottom: 8px;
}

.ai-loading-bar {
  position: relative;
  height: 3px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.3);
}

.ai-loading-bar::before {
  content: "";
  position: absolute;
  left: -40%;
  width: 40%;
  height: 100%;
  background: var(--accent);
  animation: ai-loading 1s infinite linear;
}

@keyframes ai-loading {
  from {
    left: -40%;
  }
  to {
    left: 100%;
  }
}

.chat-thread {
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-message {
  font-size: 0.85rem;
  padding: 6px 9px;
  border-radius: 10px;
  max-width: 100%;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--accent-soft);
}

.chat-message.ai {
  align-self: flex-start;
  background: rgba(148, 163, 184, 0.15);
}

.chat-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}

textarea#message {
  width: 100%;
  margin-top: 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-size: 0.9rem;
}

textarea#message:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.chat-footer {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-footer input {
  flex: 1;
  padding: 10px 12px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

/* comportement par défaut des boutons (desktop) */
#chat-send {
  flex: 0 0 auto;
}

#copy-message {
  flex: 0 0 auto;
}

/* Sur petits écrans : input pleine largeur + bouton Copier en dessous */
@media (max-width: 600px) {
  .chat-footer input {
    flex: 1 0 100%;     /* input sur toute la ligne */
  }

  #chat-send {
    flex: 0 0 auto;     /* reste à côté de l'input ou juste en dessous */
  }

  #copy-message {
    flex: 1 0 100%;     /* bouton Copier sur une nouvelle ligne, pleine largeur */
  }
}

/* Style de base pour toutes les cartes de modals (delete, info, IA, etc.) */
.modal-card {
  background: var(--card-bg, var(--surface)); /* au cas où tu as déjà une variable */
  border-radius: 18px;
  padding: 20px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  max-width: 520px;
  width: 100%;
}

.modal-card.info {
  max-width: 420px;
}

.modal-actions.right {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}


/* Conteneur générique de tous les modals */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

/* Cache réellement les modals quand la classe hidden est là */
.modal.hidden,
.modal-backdrop.hidden {
  display: none;
}

/* Backdrop (tu dois déjà avoir un truc comme ça) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  z-index: 40;
}

.modal-card.info h3,
.modal-card.info .modal-text {
  color: var(--text);
}


#info-modal {

  padding: 16px;
}



.chat-footer input::placeholder {
  color: var(--muted);
}

.chat-footer input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.copy-status {
  font-size: 0.8rem;
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

/* Modal suppression */

.delete-text {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 12px;
}

.delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Prospects view */

.prospects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

/* Filtres prospects */

.prospects-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.filter-group label {
  font-size: 0.8rem;
  color: var(--muted);
}

#filter-status,
#filter-query {
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

#filter-query::placeholder {
  color: var(--muted);
}

.prospects-table-wrapper {
  margin-top: 8px;
  max-height: 460px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.prospects-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.prospects-table thead {
  background: rgba(148, 163, 184, 0.1);
}

.prospects-table th,
.prospects-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.prospects-table th:last-child,
.prospects-table td:last-child {
  text-align: right;
  width: 70px;
}

.prospect-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.prospect-name {
  font-weight: 600;
}

.prospect-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.prospect-status-select {
  padding: 4px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
}

/* Bouton corbeille & IA */

.btn-icon {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  padding: 4px 7px;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-trash {
  width: 16px;
  height: 16px;
  stroke: var(--danger);
  fill: none;
  stroke-width: 1.8;
}

.btn-icon:hover {
  background: rgba(148, 163, 184, 0.1);
}

.btn-icon:hover .icon-trash {
  stroke: #b91c1c;
}

.actions-cell {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.btn-ai {
  border-color: rgba(59, 130, 246, 0.7);
  color: var(--accent);
}

.btn-ai:hover {
  background: var(--accent-soft);
}

/* Utils */

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .lead-actions {
    flex-direction: column;
  }

  .prospects-table th:nth-child(2),
  .prospects-table td:nth-child(2) {
    display: none; /* hide phone col on small screens */
  }
}


.modal-card.login {
  max-width: 380px;
}

.login-form select,
.login-form input[type="password"] {
  width: 100%;
  margin-top: 4px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.login-form label {
  font-size: 0.85rem;
  color: var(--subtle-text);
  display: block;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 12px;
  font-size: 0.85rem;
  color: var(--subtle-text);
}

.login-form .btn-primary.full {
  width: 100%;
}

.error-text {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #ff4d4f;
}
