/* ═══════════════════════════════════════════════════ */
/* BOARD V5 — Atelier Support de Communication */
/* ConcoursDGFiP.org — Vanilla JS — Préfixe .bd- */
/* ═════════════════════════════════════════════════════ */

/* ===== VARIABLES ===== */
:root {
  --ink: #0f1117;
  --ink-2: #3d4151;
  --ink-3: #7c8399;
  --surface: #f5f6fa;
  --surface-2: #eceef5;
  --white: #ffffff;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --accent: #0ea5e9;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --border: #e2e6f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ===== RESET ===== */
* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

/* ===== BODY ===== */
body {
  font-family: 'Sora', sans-serif;
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== LAYOUT PRINCIPAL ===== */
.bd-app-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ===== HEADER ===== */
.bd-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.bd-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.bd-header-logo {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.3px;
}

.bd-header-sep { 
  width: 1px; 
  height: 20px; 
  background: var(--border); 
}

.bd-header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.bd-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== BOUTONS ===== */
.bd-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
}

.bd-btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--border);
}

.bd-btn-ghost:hover { 
  background: var(--surface); 
}

.bd-btn-primary {
  background: var(--primary);
  color: var(--white);
}

.bd-btn-primary:hover { 
  background: #1d4ed8; 
  transform: translateY(-1px); 
}

.bd-btn-success {
  background: var(--success);
  color: var(--white);
}

.bd-btn-success:hover { 
  background: #15803d; 
}

.bd-save-indicator {
  font-size: 11px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

/* ===== SIDEBAR DOCS ===== */
.bd-sidebar {
  width: 220px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .25s ease;
}

.bd-sidebar.collapsed { 
  width: 0; 
  overflow: hidden; 
}

.bd-sidebar-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bd-sidebar-header h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ink-3);
}

.bd-sidebar-toggle {
  width: 22px; 
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
}

.bd-doc-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bd-doc-item {
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all .15s;
  background: var(--white);
}

.bd-doc-item:hover, .bd-doc-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.bd-doc-icon { 
  font-size: 18px; 
  margin-bottom: 4px; 
}

.bd-doc-title { 
  font-size: 11px; 
  font-weight: 600; 
  color: var(--ink); 
  line-height: 1.3; 
}

.bd-doc-meta { 
  font-size: 10px; 
  color: var(--ink-3); 
  margin-top: 2px; 
}

.bd-doc-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 20px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
}

.badge-text { 
  background: #e0f2fe; 
  color: #0369a1; 
}

.badge-table { 
  background: #fef3c7; 
  color: #92400e; 
}

.badge-chart { 
  background: #f0fdf4; 
  color: #166534; 
}

/* ===== DOC VIEWER ===== */
.bd-doc-viewer {
  padding: 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-height: 280px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bd-doc-content {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 10px;
  line-height: 1.6;
  color: var(--ink-2);
  overflow-y: auto;
  flex: 1;
  border: 1px solid var(--border);
}

.bd-doc-content strong { 
  color: var(--ink); 
}

.bd-doc-zoom-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.bd-zoom-btn {
  width: 22px; 
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--white);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
}

.bd-zoom-level {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  min-width: 32px;
  text-align: center;
}

/* ===== TOOLBAR ===== */
.bd-toolbar {
  width: 52px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 2px;
  flex-shrink: 0;
  overflow-y: auto;
}

.bd-tool-label {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink-3);
  margin: 8px 0 2px;
  width: 100%;
  text-align: center;
}

.bd-tool-sep {
  width: 32px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.bd-tool-btn {
  width: 38px; 
  height: 38px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all .12s;
  position: relative;
  color: var(--ink-2);
}

.bd-tool-btn:hover { 
  background: var(--surface); 
}

.bd-tool-btn.active { 
  background: var(--primary-light); 
  color: var(--primary); 
}

.bd-tool-btn span.icon { 
  font-size: 16px; 
  line-height: 1; 
}

.bd-tool-btn span.label { 
  font-size: 7px; 
  font-weight: 600; 
  color: inherit; 
  line-height: 1; 
}

.bd-tool-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 46px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--white);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 999;
  font-family: 'Sora', sans-serif;
  font-weight: 500;
}

.bd-color-dot {
  width: 16px; 
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform .12s;
}

.bd-color-dot:hover { 
  transform: scale(1.2); 
}

.bd-color-dot.active { 
  border-color: var(--primary); 
  transform: scale(1.1); 
}

/* ===== CANVAS AREA ===== */
.bd-canvas-area {
  flex: 1;
  overflow: auto;
  background: var(--surface-2);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
}

/* ===== BOARD A4 ===== */
.bd-board {
  width: 794px;
  min-height: 560px;
  background: var(--white);
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* ===== BOARD HEADER ===== */
.bd-board-header {
  background: var(--ink);
  color: var(--white);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bd-board-header-left { 
  flex: 1; 
}

.bd-subject {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.bd-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.3px;
  line-height: 1.2;
}

.bd-meta {
  font-size: 10px;
  color: rgba(255,255,255,.4);
  margin-top: 4px;
}

.bd-logo {
  width: 40px; 
  height: 40px;
  background: rgba(255,255,255,.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

/* ===== GRID 2×2 ===== */
.bd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  flex: 1;
}

.bd-zone {
  background: var(--white);
  padding: 16px;
  min-height: 220px;
  position: relative;
  transition: background .15s;
  display: flex;
  flex-direction: column;
}

.bd-zone:hover { 
  background: #fafbff; 
}

.bd-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.bd-zone-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--ink-3);
}

.bd-zone-number {
  width: 20px; 
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bd-zone-content { 
  flex: 1; 
}

/* ===== ZONE VIDE ===== */
.bd-zone-empty {
  flex: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all .15s;
  min-height: 160px;
}

.bd-zone-empty:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.bd-zone-empty-icon { 
  font-size: 24px; 
}

.bd-zone-empty-text { 
  font-size: 11px; 
  font-weight: 600; 
  color: var(--ink-3); 
}

.bd-zone-empty:hover .bd-zone-empty-text { 
  color: var(--primary); 
}

/* ===== BLOCS CONTENU ===== */

/* KPI */
.bd-bloc-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.bd-kpi-value {
  font-size: 42px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -2px;
}

.bd-kpi-variation {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
  background: var(--success-light);
  padding: 2px 8px;
  border-radius: 20px;
  width: fit-content;
  margin-bottom: 4px;
}

.bd-kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.bd-kpi-source {
  font-size: 9px;
  color: var(--ink-3);
  font-style: italic;
  margin-top: 4px;
}

.bd-kpi-analyse {
  font-size: 10px;
  color: var(--ink-2);
  line-height: 1.5;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* BAR CHART */
.bd-bloc-bar { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
}

.bd-bar-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.bd-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  padding-bottom: 20px;
  position: relative;
}

.bd-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 4px;
}

.bd-bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
  transition: opacity .15s;
}

.bd-bar:hover { 
  opacity: .8; 
}

.bd-bar-val {
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-2);
  text-align: center;
}

.bd-bar-lbl {
  font-size: 8px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.2;
}

.bd-bar-source { 
  font-size: 9px; 
  color: var(--ink-3); 
  font-style: italic; 
}

/* PIE */
.bd-bloc-pie { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
}

.bd-pie-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.bd-pie-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.bd-pie-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  flex-shrink: 0;
  background: conic-gradient(
    #2563eb 0% 36%,
    #7c3aed 36% 71%,
    #0ea5e9 71% 80%,
    #94a3b8 80% 100%
  );
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

.bd-pie-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.bd-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
}

.bd-legend-dot {
  width: 8px; 
  height: 8px; 
  border-radius: 50%; 
  flex-shrink: 0; 
}

.bd-legend-label { 
  color: var(--ink-2); 
  flex: 1; 
}

.bd-legend-val { 
  font-weight: 700; 
  color: var(--ink); 
}

.bd-pie-source { 
  font-size: 9px; 
  color: var(--ink-3); 
  font-style: italic; 
}

/* LIST */
.bd-bloc-list { 
  display: flex; 
  flex-direction: column; 
  gap: 6px; 
}

.bd-list-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.bd-list-items { 
  display: flex; 
  flex-direction: column; 
  gap: 4px; 
}

.bd-list-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 10px;
  color: var(--ink-2);
  line-height: 1.4;
}

.bd-list-dot {
  width: 5px; 
  height: 5px; 
  border-radius: 50%;
  background: var(--primary);
  margin-top: 5px;
  flex-shrink: 0;
}

.bd-list-summary {
  font-size: 10px;
  font-style: italic;
  color: var(--ink-3);
  padding-top: 8px;
  border-top: 1px solid var(--border);
  line-height: 1.4;
}

.bd-list-source { 
  font-size: 9px; 
  color: var(--ink-3); 
  font-style: italic; 
  margin-top: 4px; 
}

/* ===== BLOC CONTROLS ===== */
.bd-bloc-controls {
  position: absolute;
  top: 0; 
  right: 0;
  display: none;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  box-shadow: var(--shadow);
}

.bd-zone:hover .bd-bloc-controls { 
  display: flex; 
}

.bd-ctrl-btn {
  width: 22px; 
  height: 22px;
  border-radius: 4px;
  border: none;
  background: var(--surface);
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}

.bd-ctrl-btn:hover { 
  background: var(--surface-2); 
}

.bd-ctrl-btn.del { 
  color: var(--danger); 
}

.bd-ctrl-btn.del:hover { 
  background: #fee2e2; 
}

/* ===== MODAL ===== */
.bd-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.bd-modal {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 420px;
  max-width: 100%;
  overflow: hidden;
}

.bd-modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bd-modal-title { 
  font-size: 14px; 
  font-weight: 700; 
}

.bd-modal-zone-label { 
  font-size: 11px; 
  color: var(--ink-3); 
  margin-top: 2px; 
}

.bd-modal-close {
  width: 28px; 
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bd-modal-body { 
  padding: 20px; 
}

/* ===== BLOC TYPES ===== */
.bd-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.bd-type-btn {
  padding: 12px 8px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--white);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all .15s;
  font-family: 'Sora', sans-serif;
}

.bd-type-btn:hover { 
  border-color: var(--primary); 
  background: var(--primary-light); 
}

.bd-type-btn.selected { 
  border-color: var(--primary); 
  background: var(--primary-light); 
}

.bd-type-icon { 
  font-size: 22px; 
}

.bd-type-name { 
  font-size: 10px; 
  font-weight: 600; 
  color: var(--ink-2); 
  text-align: center; 
}

/* ===== FORM ===== */
.bd-form-field { 
  margin-bottom: 14px; 
}

.bd-form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 5px;
}

.bd-form-label span { 
  color: var(--danger); 
}

.bd-form-input, .bd-form-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  color: var(--ink);
  background: var(--white);
  transition: border-color .12s;
  outline: none;
}

.bd-form-input:focus, .bd-form-textarea:focus { 
  border-color: var(--primary); 
}

.bd-form-textarea { 
  resize: vertical; 
  min-height: 72px; 
  line-height: 1.5; 
}

.bd-form-hint {
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 3px;
  font-style: italic;
}

.bd-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== CITATION ===== */
.bd-bloc-citation {
  padding: 16px;
  background: var(--surface);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  position: relative;
}

.bd-citation-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  font-style: italic;
  margin-bottom: 12px;
}

.bd-citation-ref {
  font-size: 10px;
  color: var(--ink-3);
  font-style: italic;
}

/* ===== TEXT ===== */
.bd-bloc-text {
  padding: 16px;
  line-height: 1.6;
  color: var(--ink-2);
}

/* ===== APERÇU JURY ===== */
.bd-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,17,23,.85);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  overflow: auto;
}

.bd-preview-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  background: rgba(255,255,255,.1);
  padding: 8px 16px;
  border-radius: 40px;
  backdrop-filter: blur(10px);
}

.bd-preview-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.7);
}

/* ===== STATUS BAR ===== */
.bd-status-bar {
  height: 28px;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 10px;
  color: var(--ink-3);
  flex-shrink: 0;
}

.bd-status-left, .bd-status-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bd-status-dot {
  width: 6px; 
  height: 6px; 
  border-radius: 50%;
  background: var(--success);
}

/* ===== SEND TO CANVAS ===== */
.bd-send-btn {
  position: fixed;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: none;
  z-index: 500;
  font-family: 'Sora', sans-serif;
  gap: 4px;
  align-items: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .bd-sidebar { 
    width: 0; 
    overflow: hidden; 
  }
  
  .bd-canvas-area { 
    padding: 16px; 
  }
  
  .bd-board { 
    width: 100%; 
    min-width: 0; 
  }
  
  .bd-kpi-value { 
    font-size: 32px; 
  }
}

@media (max-width: 768px) {
  .bd-toolbar { 
    width: 44px; 
  }
  
  .bd-tool-btn { 
    width: 34px; 
    height: 34px; 
  }
  
  .bd-grid { 
    grid-template-columns: 1fr; 
  }
  
  .bd-zone { 
    min-height: 160px; 
  }
  
  .bd-header-title { 
    display: none; 
  }
  
  .bd-canvas-area { 
    padding: 8px; 
  }
  
  .bd-board { 
    border-radius: 0; 
  }
  
  .bd-pie-wrapper { 
    flex-direction: column; 
  }
  
  .bd-pie-circle { 
    width: 80px; 
    height: 80px; 
  }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(4px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

.bd-zone { 
  animation: fadeIn .3s ease both; 
}

.bd-zone:nth-child(1) { 
  animation-delay: .05s; 
}

.bd-zone:nth-child(2) { 
  animation-delay: .1s; 
}

.bd-zone:nth-child(3) { 
  animation-delay: .15s; 
}

.bd-zone:nth-child(4) { 
  animation-delay: .2s; 
}

/* ===== HIGHLIGHT TEXT ===== */
::selection { 
  background: var(--primary-light); 
}

/* ===== TEMPLATE PICKER ===== */
.bd-template-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,17,23,.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bd-template-modal {
  background: var(--white);
  border-radius: 20px;
  padding: 36px 40px;
  max-width: 680px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.bd-template-header {
  text-align: center;
  margin-bottom: 28px;
}

.bd-template-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 8px;
}

.bd-template-header p {
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.5;
}

.bd-template-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.bd-tpl-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 20px 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, box-shadow .15s, background .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.bd-tpl-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 4px 16px rgba(37,99,235,.15);
}

.bd-tpl-icon {
  font-size: 28px;
  line-height: 1;
}

.bd-tpl-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.bd-tpl-desc {
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.4;
}

.bd-tpl-blank {
  border-style: dashed;
}

.bd-tpl-blank:hover {
  border-color: var(--ink-3);
  background: var(--surface-2);
  box-shadow: none;
}

/* ===== ZONE PICK (inline type selector) ===== */
.bd-zone-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 8px;
  min-height: 120px;
}

.bd-zone-pick-hint {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.bd-zone-pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}

.bd-pick-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-2);
  font-weight: 600;
  transition: background .12s, border-color .12s;
}

.bd-pick-btn span:first-child {
  font-size: 16px;
  line-height: 1;
}

.bd-pick-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== INLINE EDITING ===== */
.bd-editable {
  cursor: text;
  border-radius: 4px;
  transition: background .12s, outline .12s;
  outline: 1px solid transparent;
  min-height: 1em;
}

.bd-editable:hover {
  background: rgba(37,99,235,.05);
  outline-color: rgba(37,99,235,.2);
}

.bd-editable:focus {
  background: rgba(37,99,235,.07);
  outline-color: var(--primary);
  outline-width: 2px;
}

.bd-inline-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-top: 8px;
  margin-bottom: 2px;
}

.bd-inline-data {
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  line-height: 1.6;
  min-height: 48px;
}

.bd-inline-data:focus {
  background: #fff;
  border-color: var(--primary);
  outline: none;
}

/* ===== MINUTEUR EXAMEN (B) ===== */
.bd-timer-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: 'Sora', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-2);
  transition: all .2s;
  min-width: 48px;
}

.bd-timer-btn .icon { font-size: 14px; }

.bd-timer-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .5px;
}

.bd-timer-btn:hover { border-color: var(--primary); background: var(--primary-light); }

.bd-timer-btn.bd-timer-green {
  border-color: var(--success);
  background: #dcfce7;
  color: var(--success);
}

.bd-timer-btn.bd-timer-orange {
  border-color: #d97706;
  background: #fef3c7;
  color: #92400e;
  animation: bd-pulse-orange 1.5s ease-in-out infinite;
}

.bd-timer-btn.bd-timer-red {
  border-color: var(--danger);
  background: #fee2e2;
  color: var(--danger);
  animation: bd-pulse-red .8s ease-in-out infinite;
}

.bd-timer-btn.bd-timer-done {
  border-color: var(--ink-3);
  background: var(--surface-2);
  color: var(--ink-3);
  cursor: default;
}

@keyframes bd-pulse-orange {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}

@keyframes bd-pulse-red {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* ===== BOARD VERROUILLÉ ===== */
.bd-locked [contenteditable] {
  pointer-events: none;
  cursor: default;
}

.bd-locked .bd-bloc-controls { display: none !important; }
.bd-locked .bd-zone-pick { display: none !important; }

.bd-locked::after {
  content: '⏰ Support verrouillé — fin du temps imparti';
  display: block;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  padding: 6px;
  background: #fee2e2;
  border-top: 1px solid #fca5a5;
  margin-top: 8px;
}

/* ===== AUTO-ÉVALUATION (C) ===== */
.bd-eval-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.bd-eval-modal {
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 520px;
  max-width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.bd-eval-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.bd-eval-header h2 { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.bd-eval-header p  { font-size: 11px; color: var(--ink-3); }

.bd-eval-close {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.bd-eval-score-wrap {
  padding: 20px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.bd-eval-score {
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 6px;
}
.bd-eval-score span { font-size: 24px; font-weight: 600; opacity: .6; }
.bd-eval-mention { font-size: 13px; font-weight: 700; margin-bottom: 12px; }

.bd-eval-bar-bg {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.bd-eval-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .6s ease;
}

.bd-eval-checks {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.bd-eval-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.bd-eval-check.ok  { background: #f0fdf4; border-color: #bbf7d0; }
.bd-eval-check.nok { background: #fef2f2; border-color: #fecaca; }

.bd-eval-check-icon {
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}
.bd-eval-check.ok  .bd-eval-check-icon { color: var(--success); }
.bd-eval-check.nok .bd-eval-check-icon { color: var(--danger); }

.bd-eval-check-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.bd-eval-check-tip {
  font-size: 11px;
  color: #991b1b;
  margin-top: 3px;
  line-height: 1.4;
}

.bd-eval-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== PRINT ===== */
@media print {
  .bd-header,
  .bd-sidebar,
  .bd-toolbar,
  .bd-modal-overlay,
  .bd-bloc-controls,
  .bd-zone-empty,
  .bd-zone-pick,
  .bd-inline-label,
  .bd-inline-data,
  .bd-template-overlay,
  .bd-eval-overlay,
  .bd-status-bar {
    display: none !important;
  }

  .bd-board {
    box-shadow: none;
    border-radius: 0;
    width: 100%;
  }

  .bd-canvas-area {
    padding: 0;
    background: white;
  }
}
