/* ════════════════════════════════════════════════════════
   AuditBTP — Design System
   Thème sombre, palette de marque 1GeleC : bleu marine
   (#2c5c8f / #1b3b5f), sarcelle (#2ea8b8), vert lime (#a8cc3a).
   Les couleurs de statut d'audit (conforme/non-conforme/à
   vérifier) restent volontairement indépendantes de la marque :
   ce sont des codes couleur universels (vert/rouge/ambre), pas
   des éléments d'habillage.
   ════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────── */
:root {
  --bg-base:       #090d19;
  --bg-surface:    #111827;
  --bg-surface2:   #1a2236;
  --bg-surface3:   #1f2d45;
  --bg-hover:      #243047;

  --accent:        #2c5c8f;
  --accent-strong: #1b3b5f;
  /* Le bleu marine, plus sombre que l'ancien ambre, manque de "punch" en
     texte/icône sur fond déjà très sombre : cette variante plus claire sert
     spécifiquement aux rôles de premier plan (texte actif, focus, icônes)
     là où --accent (bords, dégradés, fonds tramés) reste la teinte de
     référence de la marque. */
  --accent-light:  #4f8fd1;
  --accent-glow:   rgba(44, 92, 143, 0.30);
  --accent-dim:    rgba(44, 92, 143, 0.15);
  --lime:          #a8cc3a;
  --blue:          #2ea8b8;
  --blue-glow:     rgba(46, 168, 184, 0.25);

  --conforme:      #10b981;
  --conforme-bg:   rgba(16, 185, 129, 0.15);
  --non-conforme:  #ef4444;
  --non-conforme-bg: rgba(239, 68, 68, 0.15);
  --a-verifier:    #f59e0b;
  --a-verifier-bg: rgba(245, 158, 11, 0.15);

  --text:          #f1f5f9;
  --text-muted:    #64748b;
  --text-dim:      #94a3b8;
  --border:        rgba(255, 255, 255, 0.07);
  --border-bright: rgba(255, 255, 255, 0.14);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.4);
  --shadow:     0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.7);

  --transition: 0.18s ease;
  --header-h:  60px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* ── Typography ──────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; }
p  { line-height: 1.6; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* ── Views ───────────────────────────────────────────────── */
.view { display: none; flex-direction: column; height: 100vh; }
.view.active { display: flex; }

/* ── Auth gate (compte obligatoire) ─────────────────────────── */
.auth-gate-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}
.auth-gate-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.auth-gate-divider::before, .auth-gate-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
/* Bouton "Continuer avec Google" : fond clair conforme aux règles de marque
   Google (logo multicolore officiel, contraste net y compris sur thème
   sombre) — ne pas recolorer avec l'accent de l'appli. */
.btn-google {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 9px 16px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-google:hover { background: #f8f8f8; box-shadow: var(--shadow-sm); }
.btn-google:active { background: #f1f3f4; }

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px; height: 36px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  padding: 3px;
}
.brand-icon svg { width: 18px; height: 18px; }
.brand-logo-img { width: 100%; height: 100%; object-fit: contain; }

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(90deg, var(--text) 55%, var(--lime));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: none; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 24px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-surface3);
  color: var(--text);
  border: 1px solid var(--border-bright);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent-light); color: var(--accent-light); }

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

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-sm svg { width: 14px; height: 14px; }

.btn-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover { background: var(--bg-surface2); color: var(--text); }
.btn-icon-danger:hover { background: var(--non-conforme-bg); color: var(--non-conforme); }

/* ── Badge ───────────────────────────────────────────────── */
.badge {
  padding: 2px 8px;
  background: var(--bg-surface3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* ── Required star ───────────────────────────────────────── */
.required { color: var(--non-conforme); }

/* ══════════════════════════════════════════════════════════
   VIEW: PROJECTS
   ══════════════════════════════════════════════════════════ */
.projects-main {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.projects-title-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* Project Card */
.project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  opacity: 0;
  transition: opacity var(--transition);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.project-card:hover {
  border-color: var(--border-bright);
  background: var(--bg-surface2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.project-card:hover::before { opacity: 1; }

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}

.project-card-icon {
  width: 42px; height: 42px;
  background: var(--accent-dim);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-light);
  flex-shrink: 0;
}
.project-card-icon svg { width: 22px; height: 22px; }

.project-card-menu {
  opacity: 0;
  transition: opacity var(--transition);
}
.project-card:hover .project-card-menu { opacity: 1; }

.project-card-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.project-card-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.project-card-meta-item svg { width: 13px; height: 13px; flex-shrink: 0; }

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.project-card-stats {
  display: flex;
  gap: 10px;
}
.stat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.stat-label-small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.project-open-btn {
  font-size: 0.8rem;
  color: var(--accent-light);
  font-weight: 500;
  display: flex; align-items: center; gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.project-open-btn svg { width: 14px; height: 14px; }
.project-card:hover .project-open-btn { opacity: 1; }

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 80px 20px;
  color: var(--text-muted);
  text-align: center;
}
.empty-icon {
  width: 64px; height: 64px;
  color: var(--text-muted);
  opacity: 0.4;
}
.empty-icon svg { width: 100%; height: 100%; }

/* ══════════════════════════════════════════════════════════
   VIEW: WORKSPACE
   ══════════════════════════════════════════════════════════ */
.workspace-header { border-bottom: 1px solid var(--border); }

.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--header-h));
}

/* Sidebar */
.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sidebar-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

/* Sidebar divider */
.sidebar-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Add point sidebar button ────────────────────────────── */
.btn-add-mode-sidebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-surface2);
  border: 1.5px dashed var(--border-bright);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  width: 100%;
}
.btn-add-mode-sidebar:hover {
  border-color: var(--accent-light);
  color: var(--accent-light);
  background: var(--accent-dim);
  border-style: solid;
}
.btn-add-mode-sidebar.active {
  background: var(--accent-dim);
  border: 1.5px solid var(--accent-light);
  border-style: solid;
  color: var(--accent-light);
  font-weight: 600;
  animation: pulse-border 2s infinite;
}
.btn-add-mode-sidebar .add-btn-icon {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg-surface3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.btn-add-mode-sidebar .add-btn-icon svg { width: 14px; height: 14px; }
.btn-add-mode-sidebar:hover .add-btn-icon,
.btn-add-mode-sidebar.active .add-btn-icon {
  background: var(--accent);
  color: #fff;
}
.btn-add-mode-sidebar.active .add-btn-icon svg { stroke: #fff; }
.btn-add-mode-sidebar .add-btn-label { flex: 1; text-align: left; font-size: 0.83rem; }

/* Flex section for points list */
.sidebar-section-flex {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sidebar-section-flex .points-list {
  flex: 1;
}

.sidebar-actions { display: flex; flex-direction: column; gap: 8px; }

/* Points list */
.points-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.empty-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 30px 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}
.empty-hint svg { width: 32px; height: 32px; opacity: 0.4; }

.point-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  user-select: none;
  -webkit-user-select: none;
}
.point-list-item:hover { background: var(--bg-surface2); }
.point-list-item.active { background: var(--bg-surface2); border-color: var(--border-bright); }
.point-list-item:focus { outline: none; }

.point-list-numero {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}
.point-list-numero.pending { background: var(--bg-surface3); border: 1px solid var(--border-bright); }

.point-list-info { flex: 1; min-width: 0; }
.point-list-desc {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.point-list-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.hidden { display: none !important; }

/* ── Canvas Area ─────────────────────────────────────────── */
.canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-base);
  background-image:
    radial-gradient(circle at 20% 50%, rgba(46,168,184,0.045) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(168,204,58,0.04) 0%, transparent 50%);
}

/* Canvas toolbar overlay */
.canvas-toolbar {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow);
}

.tool-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
}
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn:hover { background: var(--bg-hover); color: var(--text); }
.tool-btn.active {
  background: var(--accent-dim);
  color: var(--accent-light);
  box-shadow: 0 0 8px var(--accent-glow);
}

.toolbar-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

/* Plan draw mode toolbar */
.plan-draw-toolbar {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  box-shadow: var(--shadow);
}
.plan-draw-tool-btn, .plan-draw-color-btn, .plan-draw-width-btn {
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.2s, background 0.2s;
}
.plan-draw-tool-btn:hover, .plan-draw-color-btn:hover, .plan-draw-width-btn:hover {
  opacity: 0.8;
  background: var(--bg-hover);
}
.plan-draw-tool-btn.active, .plan-draw-color-btn.active, .plan-draw-width-btn.active {
  opacity: 1;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  transform: scale(1.1);
}
.plan-draw-width-btn svg { color: var(--text-dim); }
.plan-draw-width-btn.active svg { color: var(--accent-light); }

/* Cadran d'angle de prise de vue (fiche point) */
.angle-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10px;
  padding: 12px;
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
#angle-compass { cursor: grab; user-select: none; }
#angle-compass:active { cursor: grabbing; }

/* Add mode hint */
.add-mode-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--bg-surface);
  border: 1px solid var(--accent-light);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.82rem;
  color: var(--accent-light);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 20px var(--accent-glow);
  animation: pulse-border 2s infinite;
}
.add-mode-hint svg { width: 16px; height: 16px; }
kbd {
  background: var(--bg-surface3);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 10px var(--accent-glow); }
  50% { box-shadow: 0 0 24px var(--accent-glow); }
}

/* Canvas cursor when in add mode */
.canvas-area.add-mode { cursor: crosshair; }

/* No plan placeholder */
.no-plan-placeholder {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
.placeholder-icon {
  width: 90px; height: 90px;
  color: var(--text-muted);
  opacity: 0.25;
}
.placeholder-icon svg { width: 100%; height: 100%; }
.no-plan-placeholder p { color: var(--text-muted); }

/* Fabric.js canvas wrapper */
.canvas-container { position: absolute !important; top: 0; left: 0; }

/* ══════════════════════════════════════════════════════════
   MODALS (using native <dialog>)
   ══════════════════════════════════════════════════════════ */
.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: 560px;
  width: calc(100vw - 40px);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  
  /* Centering */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;

  /* Resizable */
  resize: both;
  overflow: hidden; /* prevents scrollbars on the outer dialog, inner elements scroll */
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-point-dialog {
  width: 900px;
  height: 600px;
  max-width: 95vw;
  max-height: 95vh;
}

.modal-photo-dialog {
  width: auto;
  height: auto;
  max-width: min(90vw, 1000px);
  max-height: min(90vh, 850px);
  background: transparent;
  border: none;
  padding: 0;
  /* Empêche le redimensionnement manuel (hérité de .modal-dialog via
     "resize: both") qui pouvait étirer la dialog à une taille arbitraire
     et faire grandir le canvas Fabric.js bien au-delà de sa zone visible,
     rendant la photo/l'annotation invisible ou hors-champ. */
  resize: none;
}

.modal-photo-dialog::backdrop {
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(6px);
}

.modal-content { padding: 0; width: 100%; height: 100%; display: flex; flex-direction: column; }
.modal-content-wide { max-height: none; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1rem; font-weight: 600; }
.modal-header-actions { display: flex; align-items: center; gap: 6px; }

.point-modal-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}
.point-numero-badge {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.modal-form { padding: 22px; }

/* Form */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group:last-of-type { margin-bottom: 0; }
.form-group label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
}

input[type="text"],
input[type="date"],
input[type="email"],
input[type="password"],
textarea,
select,
.custom-select-btn {
  background: var(--bg-surface2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  outline: none;
}
input:focus,
textarea:focus,
.custom-select-btn:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 18px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}

/* Point modal body */
.modal-point-body {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

.point-info-panel {
  width: 380px;
  flex-shrink: 0;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.point-photos-panel {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.modal-point-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 16px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

/* Photos section */
.photos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.photos-header h3 { font-size: 0.9rem; }

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.photos-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.82rem;
  background: var(--bg-surface2);
  border: 1px dashed var(--border-bright);
  border-radius: var(--radius);
  text-align: center;
}
.photos-empty svg { width: 36px; height: 36px; opacity: 0.35; }

.photo-card {
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}
.photo-card:hover { border-color: var(--border-bright); transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.photo-thumbnail {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  cursor: pointer;
  display: block;
}

.photo-card-body { padding: 8px; }
.photo-annotation-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
  color: var(--text);
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  resize: none;
}
.photo-annotation-input:focus { border-color: var(--accent-light); }

.photo-card-footer {
  display: flex;
  justify-content: flex-end;
  padding: 6px 8px 8px;
}

/* Photo viewer */
.photo-viewer-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-height: calc(100vh - 40px);
}
.photo-viewer-close {
  position: absolute;
  top: -12px; right: -12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.photo-viewer-close:hover { background: var(--bg-surface2); color: var(--text); }
#photo-viewer-img {
  max-width: 90vw;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.photo-viewer-annotation {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 600px;
  font-style: italic;
}

/* ── Loading overlay ─────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(9, 13, 25, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.loading-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-message {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ── Toasts ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-surface2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  pointer-events: auto;
  animation: toast-in 0.25s ease;
  max-width: 320px;
}
.toast.exiting { animation: toast-out 0.25s ease forwards; }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--conforme); }
.toast.error   { border-left: 3px solid var(--non-conforme); }
.toast.info    { border-left: 3px solid var(--blue); }

@keyframes toast-in  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); }  to { opacity: 0; transform: translateX(20px); } }

/* ── Scrollbar styling ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-surface3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ── Dropdown menu ───────────────────────────────────────── */
.dropdown-menu {
  position: absolute;
  background: var(--bg-surface2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 6px;
  z-index: 100;
  box-shadow: var(--shadow);
  min-width: 140px;
  display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.dropdown-item svg { width: 15px; height: 15px; }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text); }
.dropdown-item.danger:hover { color: var(--non-conforme); background: var(--non-conforme-bg); }
.dropdown-item:disabled { opacity: 0.4; cursor: not-allowed; }
.dropdown-item:disabled:hover { background: none; color: var(--text-dim); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 6px; }

/* Menu contextuel d'un marqueur (clic droit sur le plan) : positionné à
   l'endroit exact du clic (coordonnées écran), pas ancré à un élément. */
.marker-context-menu { position: fixed; min-width: 220px; }

/* Project card menu container */
.project-card-menu-wrap {
  position: relative;
}

/* ══════════════════════════════════════════════════════════
   MODAL: CHANGELOG
   ══════════════════════════════════════════════════════════ */
.modal-changelog-dialog[open] {
  width: 95vw;
  max-width: 1400px;
  height: 95vh;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
}

.changelog-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Version block */
.cl-version {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--bg-surface2);
  position: relative;
  overflow: hidden;
}
.cl-version::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--blue));
}

.cl-version-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.cl-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: 'Inter', monospace;
  letter-spacing: 0.02em;
}
.cl-badge-major {
  background: var(--accent-dim);
  color: var(--accent-light);
  border: 1px solid var(--accent-light);
}
.cl-badge-minor {
  background: rgba(46,168,184,0.12);
  color: var(--blue);
  border: 1px solid rgba(46,168,184,0.35);
}
.cl-badge-patch {
  background: rgba(16,185,129,0.12);
  color: var(--conforme);
  border: 1px solid rgba(16,185,129,0.35);
}

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

.cl-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}
.cl-tag-current {
  background: var(--conforme-bg);
  color: var(--conforme);
  border: 1px solid rgba(16,185,129,0.3);
}

.cl-subtitle {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 14px;
}

/* Section (Ajouté / Modifié / Corrigé) */
.cl-section { margin-bottom: 14px; }

.cl-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cl-section-title.added    { color: var(--conforme); }
.cl-section-title.changed  { color: var(--blue); }
.cl-section-title.fixed    { color: var(--a-verifier); }
.cl-section-title.removed  { color: var(--non-conforme); }

.cl-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 4px;
}
.cl-list li {
  font-size: 0.84rem;
  color: var(--text-dim);
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
}
.cl-list li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--text-muted);
  font-weight: 700;
}
.cl-list strong { color: var(--text); }

/* Libraries */
.cl-libraries {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.cl-lib {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
}
.cl-lib-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
}
.cl-lib-ver {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'Inter', monospace;
}
.cl-lib-ver::before { content: '@'; opacity: 0.5; }

/* Roadmap */
.cl-roadmap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--bg-base);
}
.cl-roadmap-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.cl-roadmap-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.cl-roadmap-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Footer note */
.cl-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.cl-footer code {
  background: var(--bg-surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.78rem;
  color: var(--accent-light);
  font-family: 'Inter', monospace;
}

/* ══════════════════════════════════════════════════════════
   PHOTO EDITOR (Toolbar & Canvas)
   ══════════════════════════════════════════════════════════ */
.photo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.photo-tools, .photo-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.photo-tool-btn, .photo-color-btn {
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.2s, background 0.2s;
}
.photo-tool-btn:hover, .photo-color-btn:hover {
  opacity: 0.8;
  background: var(--bg-hover);
}
.photo-tool-btn.active, .photo-color-btn.active {
  opacity: 1;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  transform: scale(1.1);
}
#photo-canvas-container {
  /* Taille explicite requise : sans width/height fixes, ce conteneur
     flex reste à 0x0 (le canvas Fabric.js interne est positionné en
     absolute et ne peut donc pas lui donner de taille intrinsèque -
     dépendance circulaire qui rendait la photo invisible).
     IMPORTANT: pas de "flex: 1" ici — le parent (.photo-viewer-content)
     est un flex-column SANS hauteur fixe (seulement un max-height), donc
     "flex: 1" se résolvait à une hauteur de 0px (rien vers quoi grandir),
     ce qui rendait ce conteneur invisible malgré le width/height fixés
     ci-dessus, et faisait que Fabric.js mesurait clientHeight=0 puis
     redimensionnait le canvas interne à une taille aberrante. */
  width: min(85vw, 900px);
  height: min(75vh, 700px);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
  position: relative;
}


#photo-canvas {
  /* IMPORTANT: Forcer l'affichage du canvas HTML.
     Fabric.js ou le CSS appliquait display: none, rendant le canvas
     invisible même si l'image était correctement chargée dedans. */
  display: block !important;
}


.canvas-container {
  /* Overrides for Fabric.js wrapper to keep it centered */
  margin: 0 auto;
}

/* ══════════════════════════════════════════════════════════
   SETTINGS MODAL (Lots & Intervenants)
   ══════════════════════════════════════════════════════════ */
.settings-list {
  margin: 0; padding: 0; list-style: none;
}
.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.settings-item-title {
  font-weight: 500;
  color: var(--text);
}
.settings-item-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

