/* ============================================================
   CMC — Espace Admin Devis & Intelligence Artificielle
   Feuille de style de l'interface d'administration
   ============================================================ */

:root {
  --admin-primary: #1c3b5c;
  --admin-primary-dark: #12263c;
  --admin-primary-light: #556f88;
  --admin-accent: #e7ac35;
  --admin-bg: #f3f6f9;
  --admin-card: #ffffff;
  --admin-border: #dfe6ec;
  --admin-text: #1e293b;
  --admin-muted: #64748b;
  --admin-success: #10b981;
  --admin-warning: #f59e0b;
  --admin-danger: #ef4444;
  --admin-radius: 12px;
  --admin-shadow: 0 4px 16px rgba(15, 23, 42, .06);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--admin-bg);
  color: var(--admin-text);
  line-height: 1.5;
}

/* Header Admin */
.admin-header {
  background: var(--admin-primary);
  color: #fff;
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-brand { display: flex; align-items: center; gap: 14px; }
.admin-logo { height: 42px; width: auto; border-radius: 6px; }
.admin-title h1 { margin: 0; font-size: 1.25rem; font-weight: 800; }
.admin-title span { font-size: .82rem; color: #cbd5e1; display: block; }

.admin-nav { display: flex; gap: 8px; }
.nav-tab {
  background: rgba(255,255,255,.08);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.15);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  transition: all .15s ease;
}
.nav-tab:hover { background: rgba(255,255,255,.18); color: #fff; }
.nav-tab.active { background: var(--admin-accent); color: var(--admin-primary-dark); border-color: var(--admin-accent); font-weight: 800; }

.btn-back-site {
  color: #fff;
  text-decoration: none;
  font-size: .88rem;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  margin-left: 12px;
}
.btn-back-site:hover { background: rgba(255,255,255,.22); }

/* Layout principal */
.admin-container {
  max-width: 1380px;
  margin: 28px auto;
  padding: 0 20px;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 20px 22px;
  box-shadow: var(--admin-shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}
.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.6rem;
  background: rgba(28, 59, 92, .08);
  color: var(--admin-primary);
}
.kpi-card:nth-child(2) .kpi-icon { background: rgba(231, 172, 53, .15); color: #b45309; }
.kpi-card:nth-child(3) .kpi-icon { background: rgba(16, 185, 129, .12); color: var(--admin-success); }
.kpi-card:nth-child(4) .kpi-icon { background: rgba(99, 102, 241, .12); color: #6366f1; }
.kpi-val { font-size: 1.6rem; font-weight: 800; color: var(--admin-text); line-height: 1.1; margin-bottom: 2px; }
.kpi-lbl { font-size: .85rem; color: var(--admin-muted); font-weight: 600; }

/* Contenu Onglets */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Toolbar Devis */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search-box input {
  padding: 10px 16px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  width: 280px;
  font: inherit;
}
.filters { display: flex; gap: 8px; }
.filter-btn {
  padding: 8px 14px;
  border: 1px solid var(--admin-border);
  background: var(--admin-card);
  border-radius: 8px;
  font-size: .86rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--admin-muted);
}
.filter-btn.active {
  background: var(--admin-primary);
  color: #fff;
  border-color: var(--admin-primary);
}

/* Tableau Devis */
.table-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow);
  overflow: hidden;
}
.quotes-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: .92rem;
}
.quotes-table th {
  background: #f8fafc;
  padding: 14px 18px;
  color: var(--admin-muted);
  font-weight: 700;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--admin-border);
}
.quotes-table td {
  padding: 16px 18px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.quotes-table tr:hover td { background: #f8fafc; }

.q-id { font-weight: 800; color: var(--admin-primary); }
.q-client-name { font-weight: 700; color: var(--admin-text); }
.q-client-sub { font-size: .8rem; color: var(--admin-muted); }
.q-title { font-weight: 600; color: var(--admin-text); }
.q-diag { font-size: .82rem; color: var(--admin-muted); max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-amount { font-weight: 800; font-size: 1.05rem; color: var(--admin-primary); }

/* ---------- Galerie Photos ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.gallery-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
  box-shadow: var(--admin-shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.gallery-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.gallery-card-img {
  width: 100%;
  aspect-ratio: 16 / 11;
  object-fit: cover;
  display: block;
  background: #e2e8f0;
}
.gallery-card-body {
  padding: 14px 16px;
}
.gallery-card-body h4 { margin: 0 0 4px; font-size: 1rem; color: var(--admin-text); }
.gallery-card-body p { margin: 0 0 10px; font-size: .85rem; color: var(--admin-muted); }
.gallery-card-badges { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.gallery-card-actions { display: flex; gap: 6px; }
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--admin-muted);
  background: var(--admin-card);
  border: 2px dashed var(--admin-border);
  border-radius: var(--admin-radius);
}

/* Badges statut */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.status-ai_analyzed { background: #e0f2fe; color: #0369a1; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-validated { background: #ecfdf5; color: #065f46; }
.status-sent { background: #e0e7ff; color: #3730a3; }
.status-accepted { background: #dcfce7; color: #166534; }
.status-rejected { background: #fee2e2; color: #991b1b; }

/* Boutons Actions */
.action-buttons { display: flex; gap: 6px; }
.btn-act {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--admin-border);
  background: #fff;
  cursor: pointer;
  font-size: .85rem;
  transition: all .15s ease;
}
.btn-act:hover { background: #f1f5f9; }
.btn-act.pdf { color: #dc2626; border-color: #fca5a5; background: #fff5f5; }
.btn-act.pdf:hover { background: #dc2626; color: #fff; }
.btn-act.edit { color: var(--admin-primary); border-color: #cbd5e1; }
.btn-act.edit:hover { background: var(--admin-primary); color: #fff; }
.btn-act.ai { color: #b45309; border-color: #fcd34d; background: #fffbeb; }
.btn-act.ai:hover { background: var(--admin-accent); color: var(--admin-primary-dark); }
.btn-act.delete,
.btn-p.quote-delete { color: #b91c1c; border-color: #fecaca; background: #fff5f5; }
.btn-act.delete:hover,
.btn-p.quote-delete:hover { background: #b91c1c; color: #fff; }
.btn-p.quote-delete { margin-right: auto; }

/* Modal Éditeur Devis */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 960px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
  padding: 30px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 18px; right: 18px;
  border: none; background: #f1f5f9;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: grid; place-items: center;
}
.modal-header { margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--admin-border); }
.modal-header h2 { margin: 0 0 6px; font-size: 1.4rem; color: var(--admin-primary); }

.quote-approval-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -4px 0 20px;
  padding: 15px 17px;
  border: 1px solid #f2cf7c;
  border-left: 5px solid #d89a1d;
  border-radius: 10px;
  background: #fff9e9;
  color: #704b08;
}
.quote-approval-panel.is-approved {
  border-color: #9ed9ba;
  border-left-color: #178550;
  background: #eefaf4;
  color: #145f3c;
}
.quote-approval-panel strong { display: block; margin-bottom: 3px; }
.quote-approval-panel p { margin: 0; font-size: .8rem; line-height: 1.45; }
.btn-p.quote-approve { flex: 0 0 auto; background: #1c3b5c; color: #fff; }
.btn-p.quote-approve:hover { background: #102a43; }
.btn-p.quote-approve[hidden] { display: none; }

.modal-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.card-sub {
  background: #f8fafc;
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  padding: 16px;
}
.card-sub h4 { margin: 0 0 10px; font-size: .95rem; color: var(--admin-primary); }
.quote-route-info {
  display: grid;
  gap: 2px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #d7e2ea;
  color: #526579;
  font-size: .78rem;
}
.quote-route-info strong { color: var(--admin-primary); }

.photos-gallery { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.photos-gallery img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid #cbd5e1; cursor: pointer; }

/* Table Lignes Devis Éditables */
.items-edit-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.items-edit-table th { background: #edf2f7; padding: 8px 10px; font-size: .8rem; text-align: left; }
.items-edit-table td { padding: 8px 6px; border-bottom: 1px solid #e2e8f0; }
.items-edit-table input, .items-edit-table select {
  width: 100%;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font: inherit;
  font-size: .88rem;
}
.btn-del-line { background: #fee2e2; color: #dc2626; border: none; border-radius: 6px; width: 30px; height: 30px; cursor: pointer; }

.modal-totals {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0;
  padding: 16px 20px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--admin-border);
}
.totals-display { text-align: right; }
.total-ttc-highlight { font-size: 1.35rem; font-weight: 800; color: var(--admin-primary); }

.modal-actions { display: flex; justify-content: flex-end; gap: 12px; }
.btn-p {
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-p.save { background: var(--admin-primary); color: #fff; }
.btn-p.save:hover { background: var(--admin-primary-dark); }
.btn-p.ai-regen { background: var(--admin-accent); color: var(--admin-primary-dark); }
.btn-p.client-delete {
  margin-right: auto;
  background: #fff5f5;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.btn-p.client-delete:hover { background: #b91c1c; color: #fff; }
.btn-p.client-delete[hidden] { display: none; }

/* ---------- Liste d'emails admin (chips) ---------- */
.email-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 20px;
  margin: 8px 0;
}
.email-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(28, 59, 92, .08);
  color: var(--admin-primary);
  font-size: .86rem;
  font-weight: 600;
  padding: 6px 8px 6px 14px;
  border-radius: 999px;
}
.email-chip.is-invalid {
  background: rgba(239, 68, 68, .1);
  color: var(--admin-danger);
}
.email-chip button {
  border: none;
  background: rgba(255,255,255,.7);
  color: inherit;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: .8rem;
  line-height: 1;
  padding: 0;
  transition: background .15s ease;
}
.email-chip button:hover { background: #fff; }
.email-chip-add {
  display: flex;
  gap: 8px;
}
.email-chip-add input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  font: inherit;
}
.email-chip-add input.is-invalid {
  border-color: var(--admin-danger);
}
.email-chip-hint {
  display: block;
  color: var(--admin-muted);
  font-size: .75rem;
  margin-top: 6px;
}
.email-chip-hint.is-error { color: var(--admin-danger); font-weight: 600; }
.btn-p.ai-regen:hover { background: #d49a26; }
.btn-p.pdf-down { background: #dc2626; color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }

/* Onglet Prompt Vocal / Rapide */
.fast-ai-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 30px;
  max-width: 840px;
  margin: 0 auto;
  box-shadow: var(--admin-shadow);
}
.fast-ai-card h3 { margin-top: 0; color: var(--admin-primary); }
.fast-client-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.fast-ai-card textarea {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--admin-border);
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
  margin: 14px 0;
}

/* ---------- Modal Galerie (création / modification chantier) ---------- */
#modal-gallery .modal-box {
  max-width: 620px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#modal-gallery .modal-header {
  margin: 0;
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--admin-border);
  background: linear-gradient(135deg, #f8fafc, #eef2f7);
}
#modal-gallery .modal-header h2 { font-size: 1.3rem; }
#modal-gallery .modal-close { top: 16px; right: 16px; z-index: 2; }
#gallery-form {
  padding: 24px 28px 28px;
  overflow-y: auto;
}
.g-field { margin-bottom: 18px; }
.g-field > label {
  display: block;
  font-weight: 800;
  font-size: .9rem;
  color: var(--admin-primary);
  margin-bottom: 8px;
}
.g-hint { font-weight: 500; color: var(--admin-muted); font-size: .8rem; }
.g-field input[type="text"],
.g-field textarea,
.g-field select {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--admin-border);
  border-radius: 10px;
  font: inherit;
  font-size: .95rem;
  background: #fff;
  color: var(--admin-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.g-field input[type="text"]:focus,
.g-field textarea:focus,
.g-field select:focus {
  outline: none;
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(28, 59, 92, .1);
}
.g-title-row { display: flex; gap: 10px; }
.g-title-row input { flex: 1; }
.btn-ai {
  white-space: nowrap;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-ai:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(124, 58, 237, .4); }
.btn-ai:disabled { opacity: .6; cursor: wait; }

.btn-ai-inline {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #c4b5fd;
  padding: 4px 12px;
  border-radius: 6px;
  font-weight: 700;
  font-size: .8rem;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-ai-inline:hover {
  background: #7c3aed;
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 58, 237, .25);
}
.btn-ai-inline:disabled { opacity: .6; cursor: wait; }
.g-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.g-check-field { display: flex; align-items: flex-end; padding-bottom: 2px; }
.g-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  padding: 12px 14px;
  border: 1.5px solid var(--admin-border);
  border-radius: 10px;
  background: #f8fafc;
  width: 100%;
}
.g-switch input { width: 18px; height: 18px; accent-color: var(--admin-primary); cursor: pointer; }

/* Dropzone galerie */
.g-dropzone {
  position: relative;
  border: 2px dashed var(--admin-border);
  border-radius: 12px;
  background: #f8fafc;
  transition: border-color .2s ease, background .2s ease;
  cursor: pointer;
}
.g-dropzone:hover, .g-dropzone.dragover {
  border-color: var(--admin-primary);
  background: #eef4fa;
}
.g-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.g-dropzone-content {
  padding: 26px 20px;
  text-align: center;
  pointer-events: none;
}
.g-drop-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.g-dropzone-content p { margin: 0 0 4px; font-size: .95rem; color: var(--admin-text); }
.g-dropzone-content small { color: var(--admin-muted); font-size: .8rem; }

/* Previews miniatures */
.g-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.g-previews:empty { display: none; }
.g-preview-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--admin-border);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.g-preview-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-preview-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 11px;
  display: grid;
  place-items: center;
  transition: background .15s ease;
}
.g-preview-remove:hover { background: #dc2626; }
.g-preview-primary {
  position: absolute;
  bottom: 4px; left: 4px;
  background: var(--admin-accent);
  color: var(--admin-primary-dark);
  font-size: .65rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
}
.g-actions { margin-top: 4px; border-top: 1px solid var(--admin-border); padding-top: 18px; }
.btn-p.g-cancel { background: #e2e8f0; color: #475569; }
.btn-p.g-cancel:hover { background: #cbd5e1; }

@media (max-width: 900px) {
  .g-row { grid-template-columns: 1fr; }
  .g-title-row { flex-direction: column; }
  .btn-ai { padding: 10px 16px; }
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .gallery-grid { grid-template-columns: 1fr; }
  .modal-grid-2 { grid-template-columns: 1fr; }
  .admin-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}

/* ============================================================
   NOTIFICATIONS TOAST MODERNES (ZÉRO ALERT POPUP)
   ============================================================ */
.cmc-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.cmc-toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 440px;
  padding: 14px 20px;
  border-radius: 12px;
  background: #fff;
  color: #1e293b;
  font-size: .92rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 5px solid var(--admin-primary);
  animation: toastSlideIn .25s ease-out forwards;
  transition: opacity .25s ease, transform .25s ease;
}
.cmc-toast.success { border-left-color: #10b981; background: #f0fdf4; color: #166534; }
.cmc-toast.error { border-left-color: #ef4444; background: #fff5f5; color: #991b1b; }
.cmc-toast.warning { border-left-color: #f59e0b; background: #fffbeb; color: #92400e; }
.cmc-toast.info { border-left-color: #3b82f6; background: #eff6ff; color: #1e40af; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cmc-toast.fade-out {
  opacity: 0;
  transform: translateY(10px) scale(.95);
}

/* ============================================================
   RÉPERTOIRE CLIENT — FICHE ET HISTORIQUE
   ============================================================ */
.client-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 16px;
  overflow: hidden;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  background: #fff;
}
.client-summary > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
  padding: 13px 16px;
}
.client-summary > div + div { border-left: 1px solid var(--admin-border); }
.client-summary strong { color: var(--admin-primary); font-size: 1.15rem; }
.client-summary span { color: var(--admin-muted); font-size: .76rem; line-height: 1.25; }

.client-modal-box { max-width: 980px; }
.client-modal-intro { margin: 4px 0 0; color: var(--admin-muted); font-size: .88rem; }
.client-file-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, .8fr);
  gap: 24px;
  align-items: start;
}
.client-profile-form { min-width: 0; }
.client-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.client-field { min-width: 0; }
.client-field label,
.client-access-box label {
  display: block;
  margin-bottom: 6px;
  color: var(--admin-primary);
  font-size: .82rem;
  font-weight: 750;
}
.client-field input,
.client-access-box input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: #fff;
  color: var(--admin-text);
  font: inherit;
}
.client-field input:focus,
.client-access-box input:focus {
  outline: 3px solid rgba(231, 172, 53, .2);
  border-color: #c08a21;
}
.client-field input[readonly] { background: #f1f5f9; color: #526579; cursor: not-allowed; }
.client-field small { display: block; margin-top: 5px; color: var(--admin-muted); font-size: .7rem; line-height: 1.35; }

.client-access-box {
  margin-top: 18px;
  padding: 15px;
  border: 1px solid #d7e2ea;
  border-left: 4px solid var(--admin-accent);
  border-radius: 9px;
  background: #f8fafc;
}
.client-access-box > div { margin-bottom: 11px; }
.client-access-box strong { color: var(--admin-primary); font-size: .9rem; }
.client-access-box p { margin: 3px 0 0; color: var(--admin-muted); font-size: .76rem; line-height: 1.4; }
.client-form-actions { margin-top: 20px; }

.client-history-panel {
  min-width: 0;
  padding-left: 22px;
  border-left: 1px solid var(--admin-border);
}
.client-account-state {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef3f7;
  color: #526579;
  font-size: .78rem;
  font-weight: 750;
}
.client-account-state.is-active { background: #eaf8f1; color: #166534; }
.client-account-state.is-pending { background: #fff8e7; color: #8a5c08; }
.client-history-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
  border-block: 1px solid var(--admin-border);
}
.client-history-stats > div { padding: 12px 6px; text-align: center; }
.client-history-stats strong { display: block; color: var(--admin-primary); font-size: 1.2rem; }
.client-history-stats span { color: var(--admin-muted); font-size: .68rem; }
.client-history-list { color: #526579; font-size: .78rem; line-height: 1.45; }
.client-history-list p { margin: 0; }
.client-history-item { padding: 9px 0; border-bottom: 1px solid #e5edf2; }
.client-history-item:last-child { border-bottom: 0; }
.client-history-item strong { display: block; color: var(--admin-text); font-size: .78rem; }
.client-history-item span { display: block; margin-top: 2px; }
.client-quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.client-quick-actions[hidden] { display: none; }

/* ============================================================
   RESPONSIVE ADMIN — navigation tactile, tableaux et modales
   ============================================================ */
html,
body { max-width: 100%; overflow-x: hidden; }

.admin-brand,
.admin-title,
.admin-container,
.tab-pane,
.toolbar,
.fast-ai-card,
.modal-box { min-width: 0; }

.admin-nav {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-nav::-webkit-scrollbar { display: none; }
.nav-tab,
.btn-back-site,
#btn-admin-logout { flex: 0 0 auto; }

.table-card { overflow-x: auto; }
.quotes-table { min-width: 760px; }
.quotes-table th,
.quotes-table td { white-space: nowrap; }
.quotes-table td .q-diag { white-space: nowrap; }

.search-box { min-width: 0; }
.search-box input { max-width: 100%; }
.filters { min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter-btn { flex: 0 0 auto; white-space: nowrap; }

.fast-ai-card input,
.fast-ai-card select,
.fast-ai-card textarea,
.modal-box input,
.modal-box select,
.modal-box textarea {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  font-size: 16px;
}
.fast-ai-card [style*="grid-template-columns"],
#tab-settings [style*="grid-template-columns"],
#modal-equipment [style*="grid-template-columns"] { min-width: 0; }

#modal-editor .items-edit-table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

@media (max-width: 900px) {
  .admin-header {
    display: block;
    padding: 12px 16px 10px;
  }
  .admin-brand { gap: 10px; }
  .admin-logo { width: 42px; height: 42px; }
  .admin-title { overflow: hidden; }
  .admin-title h1 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .admin-title span { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .admin-nav {
    width: 100%;
    margin-top: 12px;
    padding: 2px 0 4px;
    gap: 7px;
  }
  .nav-tab { padding: 8px 12px; font-size: .82rem; }
  .btn-back-site { margin-left: 0; padding: 8px 12px; font-size: .82rem; }
  #btn-admin-logout { padding: 8px 12px !important; font-size: .82rem; white-space: nowrap; }

  .admin-container { margin: 18px auto 28px; padding: 0 16px; }
  .kpi-grid { gap: 12px; margin-bottom: 20px; }
  .kpi-card { gap: 10px; padding: 14px 12px; }
  .kpi-icon { width: 40px; height: 40px; flex: 0 0 40px; font-size: 1.25rem; border-radius: 10px; }
  .kpi-val { font-size: 1.25rem; }
  .kpi-lbl { font-size: .72rem; line-height: 1.25; }

  .toolbar { align-items: stretch; gap: 10px; }
  .search-box,
  .search-box input { width: 100%; }
  .filters { width: 100%; padding-bottom: 2px; }
  .table-card { border-radius: 10px; }

  .fast-ai-card { padding: 20px 16px; }
  .fast-ai-card h3 { font-size: 1.15rem; line-height: 1.3; }
  .g-actions,
  .modal-actions { flex-wrap: wrap; }

  .modal-backdrop {
    align-items: flex-start;
    overflow-y: auto;
    padding: 10px;
  }
  .modal-box {
    max-height: calc(100dvh - 20px);
    padding: 22px 16px;
    border-radius: 16px;
  }
  .modal-header { padding-right: 38px; }
  .modal-header h2 { font-size: 1.2rem; line-height: 1.3; }
  .quote-approval-panel { align-items: stretch; flex-direction: column; }
  .quote-approval-panel .quote-approve { width: 100%; min-height: 44px; }
  .modal-grid-2 { gap: 14px; }
  .modal-totals { align-items: stretch; flex-direction: column; gap: 14px; padding: 14px; }
  .modal-totals input { width: 100% !important; }
  .totals-display { text-align: left; }
  .modal-actions > .btn-p,
  .g-actions > .btn-p { flex: 1 1 100%; width: 100%; min-height: 44px; }
  .modal-actions > .btn-p.client-delete { margin-right: 0; }

  #modal-admin-auth .modal-box { padding: 28px 18px; }
  #admin-google-btn-slot,
  #admin-google-btn-slot > div { max-width: 100%; }

  .client-file-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .client-history-panel { padding: 18px 0 0; border-top: 1px solid var(--admin-border); border-left: 0; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card { align-items: flex-start; }
  .kpi-icon { margin-top: 1px; }

  .fast-ai-card [style*="grid-template-columns"],
  .fast-client-grid,
  #tab-settings [style*="grid-template-columns"],
  #modal-equipment [style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  #tab-settings [style*="grid-column: span 2"] { grid-column: span 1 !important; }
  .email-chip-add { align-items: stretch; flex-direction: column; }
  .email-chip-add button { width: 100%; min-height: 42px; }

  .g-row { grid-template-columns: minmax(0, 1fr); }
  .g-title-row { gap: 8px; }
  .g-title-row .btn-ai { min-height: 42px; }
  .g-field > div[style*="justify-content"] { align-items: flex-start !important; flex-direction: column; gap: 8px; }
  .btn-ai-inline { width: 100%; min-height: 40px; }

  .client-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-summary > div + div { border-left: 0; }
  .client-summary > div:nth-child(even) { border-left: 1px solid var(--admin-border); }
  .client-summary > div:nth-child(n+3) { border-top: 1px solid var(--admin-border); }
  .client-form-grid { grid-template-columns: minmax(0, 1fr); gap: 13px; }
}

@media (max-width: 420px) {
  .admin-header { padding-left: 12px; padding-right: 12px; }
  .admin-container { padding: 0 12px; }
  .kpi-card { padding: 12px 10px; }
  .kpi-icon { width: 34px; height: 34px; flex-basis: 34px; font-size: 1.05rem; }
  .kpi-val { font-size: 1.1rem; }
  .kpi-lbl { font-size: .68rem; }
  .modal-backdrop { padding: 6px; }
  .modal-box { max-height: calc(100dvh - 12px); padding: 20px 13px; }
}
