/* ==========================================================================
   Éditeur CSV - Feuilles de styles (Vanilla CSS)
   ========================================================================== */

:root {
  /* Couleur d'accent principale : Pantone 653 C (#326295) */
  --primary: #326295; /* Pantone 653 C */
  --primary-hover: #274f7a;
  --primary-active: #1e3d60;
  --primary-light: #eaf1f7;
  --primary-border: #326295;

  --accent-blue: #0b57d0;
  --accent-warn: #b06000;
  --accent-danger: #c5221f;

  --bg-app: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f3f4;
  --bg-header: #f3f4f6;
  --bg-hover: #eef2f6;
  --bg-selected: #e7f0fa;
  --bg-active-header: #dbeafe;

  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-inverse: #ffffff;

  --border-light: #e5e7eb;
  --border-main: #d1d5db;
  --border-dark: #9ca3af;
  --border-focus: #326295;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --header-height: 52px;
  --toolbar-height: 42px;
  --formula-height: 38px;
  --statusbar-height: 28px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-main);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Layout Principal
   ========================================================================== */

.app-root {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  background-color: var(--bg-app);
}

/* ==========================================================================
   Header supérieur
   ========================================================================== */

.app-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-weight: 700;
  font-size: 15px;
}

.brand-icon {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

.current-filename {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  padding: 4px 8px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dirty-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-warn);
  background: #fef3c7;
  padding: 2px 6px;
  border-radius: 10px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  user-select: none;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 1px 2px rgba(50, 98, 149, 0.25);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-primary:active {
  background-color: var(--primary-active);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-main);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-dark);
}

.btn:focus-visible {
  outline: 2px solid var(--primary-border);
  outline-offset: 1px;
}

/* Menu déroulant (Dropdown) */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dropdown-caret {
  transition: transform 0.15s ease;
  margin-left: 2px;
}

.dropdown.is-open .dropdown-caret {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 290px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  display: none;
  flex-direction: column;
  gap: 2px;
  animation: dropdown-in 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown.is-open .dropdown-menu {
  display: flex;
}

@keyframes dropdown-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
  width: 100%;
  font-family: var(--font-sans);
}

.dropdown-item:hover {
  background-color: var(--bg-subtle);
}

.dropdown-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.dropdown-item-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  min-width: 42px;
  text-align: center;
  letter-spacing: 0.5px;
}

.badge-xlsx {
  background-color: #e8f5e9;
  color: #107c41;
  border: 1px solid #c8e6c9;
}

.badge-ods {
  background-color: #e1f5fe;
  color: #0277bd;
  border: 1px solid #b3e5fc;
}

.badge-csv {
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid #bfdbfe;
}

.badge-view {
  background-color: var(--bg-subtle);
  color: var(--primary);
  border: 1px solid var(--border-main);
  padding: 4px;
}

.view-check {
  margin-left: auto;
  color: var(--primary);
  flex-shrink: 0;
}

.dropdown-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.dropdown-item-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-light);
  margin: 4px 6px;
}

/* ==========================================================================
   Barre d'outils (Toolbar)
   ========================================================================== */

.toolbar {
  height: var(--toolbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 4px;
  z-index: 9;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background-color: var(--border-light);
  margin: 0 6px;
}

.toolbar-spacer {
  flex: 1;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
  user-select: none;
}

.tool-btn:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  border-color: var(--border-light);
}

.tool-btn:active:not(:disabled) {
  background-color: var(--border-light);
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-btn-sm {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  background: transparent;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
}

.tool-btn-sm:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.tool-btn-sm:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Zone de recherche */
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 2px 8px;
  height: 28px;
  transition: border-color 0.15s, background-color 0.15s;
}

.search-box:focus-within {
  background-color: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(50, 98, 149, 0.15);
}

.search-box svg {
  color: var(--text-muted);
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 12px;
  color: var(--text-main);
  width: 140px;
}

.btn-search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.btn-search-clear:hover {
  background-color: var(--border-light);
  color: var(--text-main);
}

.btn-search-clear svg {
  display: block;
}

.search-counter {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==========================================================================
   Barre d'adresse & formule
   ========================================================================== */

.formula-bar {
  height: var(--formula-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-main);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  z-index: 8;
}

.cell-address-box {
  min-width: 60px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  user-select: none;
}

.formula-fx {
  font-style: italic;
  font-family: "Georgia", serif;
  font-weight: bold;
  color: var(--text-muted);
  user-select: none;
  padding: 0 4px;
}

.formula-input {
  flex: 1;
  height: 26px;
  padding: 0 8px;
  font-size: 13px;
  font-family: var(--font-sans);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  outline: none;
  background-color: #fafafa;
  color: var(--text-main);
  transition: border-color 0.15s, background-color 0.15s;
}

.formula-input:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* ==========================================================================
   Grille tableur
   ========================================================================== */

.grid-viewport {
  flex: 1;
  overflow: auto;
  position: relative;
  background-color: #e9ecef;
  outline: none;
}

.table-wrapper {
  min-width: 100%;
  display: inline-block;
  vertical-align: top;
  background-color: var(--bg-surface);
}

.grid-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background-color: var(--bg-surface);
  font-size: 12px;
  user-select: none;
}

/* Coin supérieur gauche (Header 0,0) */
.corner-header {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 5;
  width: 54px;
  min-width: 54px;
  max-width: 54px;
  height: 25px;
  background-color: var(--bg-header);
  border-right: 1px solid var(--border-main);
  border-bottom: 1px solid var(--border-main);
  padding: 2px 2px;
  text-align: center;
  vertical-align: middle;
}

/* Sélecteur de filtre par statut du robot */
.corner-filter-select {
  width: 100%;
  height: 21px;
  padding: 0 1px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  text-align: center;
  transition: all 0.15s;
}

.corner-filter-select:hover {
  border-color: var(--primary);
  background-color: var(--bg-subtle);
}

.corner-filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.corner-filter-select.filter-active-ok {
  background-color: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.corner-filter-select.filter-active-fail {
  background-color: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.corner-filter-select.filter-active-error {
  background-color: #ffedd5;
  color: #c2410c;
  border-color: #fdba74;
}

/* En-têtes de colonnes (A, B, C...) */
.col-header {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 25px;
  background-color: var(--bg-header);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-main);
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
  user-select: none;
  min-width: 100px;
  padding: 0 6px;
  transition: background-color 0.1s;
}

.col-header.col-active {
  background-color: var(--bg-active-header);
  color: var(--primary);
  font-weight: 700;
  border-bottom-color: var(--primary);
}

/* En-têtes de lignes (1, 2, 3...) */
.row-header {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 54px;
  min-width: 54px;
  max-width: 54px;
  background-color: var(--bg-header);
  border-right: 1px solid var(--border-main);
  border-bottom: 1px solid var(--border-light);
  font-weight: 500;
  text-align: center;
  color: var(--text-muted);
  user-select: none;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.1s;
  padding: 0 4px;
}

.row-header.row-active {
  background-color: var(--bg-active-header);
  color: var(--primary);
  font-weight: 700;
  border-right-color: var(--primary);
}

.row-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.row-num {
  flex: 1;
  text-align: center;
}

.row-robot-icon {
  font-size: 11px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  margin-left: 2px;
  flex-shrink: 0;
}

.row-robot-icon.status-ok {
  color: #15803d;
  background-color: #dcfce7;
  font-weight: bold;
}

.row-robot-icon.status-fail,
.row-robot-icon.status-err {
  color: #b91c1c;
  background-color: #fee2e2;
  font-weight: bold;
}

.row-robot-icon.status-error,
.row-robot-icon.status-warn {
  color: #c2410c;
  background-color: #ffedd5;
  border: 1px solid #fdba74;
  font-weight: bold;
}

/* Cellules de données */
.grid-cell {
  height: 25px;
  padding: 2px 6px;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: cell;
  position: relative;
  background-color: var(--bg-surface);
  text-align: left;
}

/* Alignements automatique selon le contenu */
.grid-cell.cell-align-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.grid-cell.cell-align-left {
  text-align: left;
}

/* Cellule active */
.grid-cell.cell-selected {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  z-index: 2;
  background-color: rgba(50, 98, 149, 0.06);
}

/* Correspondance de recherche */
.grid-cell.cell-match {
  background-color: #fef08a !important;
}

.grid-cell.cell-match-current {
  background-color: #fde047 !important;
  outline: 2px dashed #ca8a04;
}

/* Cellule modifiée par le script Robot Callback (fond découlant du Pantone 653 C) */
.grid-cell.cell-robot-modified {
  background-color: #dbeafe !important;
  color: #1e3d60 !important;
  box-shadow: inset 0 0 0 1.5px #326295;
  font-weight: 500;
}

/* Éditeur inline directement dans la cellule */
.cell-inline-editor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  padding: 2px 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-main);
  background-color: #ffffff;
  box-shadow: inset 0 0 0 2px var(--primary);
  outline: none;
  z-index: 6;
  text-align: left;
}

.cell-inline-editor.editor-align-right {
  text-align: right;
}

/* Overlay de glisser-déposer */
.drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(50, 98, 149, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(3px);
}

.drop-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.drop-message {
  text-align: center;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
}

/* ==========================================================================
   Éditeur de texte brut CSV (Mode Texte)
   ========================================================================== */

.text-viewport {
  flex: 1;
  display: flex;
  position: relative;
  background-color: #ffffff;
  overflow: hidden;
}

.text-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  background-color: #ffffff;
  z-index: 1;
}

.text-highlights {
  position: relative;
  box-sizing: border-box;
  margin: 0;
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 21px;
  letter-spacing: normal;
  word-spacing: normal;
  text-transform: none;
  text-indent: 0;
  tab-size: 4;
  white-space: pre;
  word-break: normal;
  color: transparent;
  min-height: 100%;
}

.text-highlights mark.text-match {
  color: transparent;
  background-color: #fef08a;
  border-radius: 2px;
}

.text-highlights mark.text-match-current {
  background-color: #fde047;
  outline: 2px solid #ca8a04;
  outline-offset: -1px;
  border-radius: 2px;
}

.text-editor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 21px;
  letter-spacing: normal;
  word-spacing: normal;
  text-transform: none;
  text-indent: 0;
  tab-size: 4;
  color: var(--text-main);
  background-color: transparent;
  border: none;
  outline: none;
  resize: none;
  white-space: pre;
  word-break: normal;
  overflow: auto;
  z-index: 2;
}

.text-editor:focus {
  outline: none;
}

/* ==========================================================================
   Barre d'état inférieure
   ========================================================================== */

.app-statusbar {
  height: var(--statusbar-height);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
  z-index: 10;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-divider {
  color: var(--border-main);
}

.status-badge {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-main);
}

.status-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.status-lang-btn:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.lang-flag {
  font-size: 12px;
  line-height: 1;
}

.lang-code {
  font-family: var(--font-mono);
  font-size: 10px;
}

/* ==========================================================================
   Boîte de dialogue de configuration (Modale)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.is-open .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.modal-title-wrap svg {
  color: var(--primary);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.12s;
}

.modal-close:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.radio-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  cursor: pointer;
  background-color: #fafbfc;
  transition: all 0.15s ease;
}

.radio-card:hover {
  border-color: var(--primary);
  background-color: var(--bg-surface);
}

.radio-card input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--primary);
}

.radio-card input[type="radio"]:checked ~ .radio-content .opt-name {
  color: var(--primary);
}

.radio-card:has(input[type="radio"]:checked) {
  border-color: var(--primary);
  background-color: rgba(50, 98, 149, 0.04);
}

.radio-card.disabled,
.radio-card:has(input[type="radio"]:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
  background-color: var(--bg-subtle) !important;
  border-color: var(--border-light) !important;
}

.radio-card:has(input[type="radio"]:disabled) input[type="radio"] {
  cursor: not-allowed;
}

.radio-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.opt-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.badge-rec {
  font-size: 10px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  text-transform: uppercase;
}

.opt-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.opt-desc code {
  background: #f1f5f9;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  color: #0f172a;
}

.checkbox-option {
  margin-top: 4px;
  padding: 4px 0;
}

.checkbox-option label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-main);
  cursor: pointer;
}

.checkbox-option input[type="checkbox"] {
  accent-color: var(--primary);
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  background-color: var(--bg-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   Toasts & Notifications
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 40px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background-color: #1f2937;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.toast-success {
  border-left: 4px solid var(--primary-border);
}

.toast.toast-warn {
  border-left: 4px solid #f59e0b;
}

.toast.toast-error {
  border-left: 4px solid #ef4444;
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(10px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Panneau Robot Callback (Drawer rétractable)
   ========================================================================== */

.robot-drawer {
  display: flex;
  flex-direction: column;
  height: 250px;
  min-height: 180px;
  max-height: 50vh;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-main);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
  z-index: 10;
  flex-shrink: 0;
}

.robot-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 12px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.robot-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.robot-header-left svg {
  color: var(--primary);
}

.robot-header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.robot-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
}

.robot-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
  background-color: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.robot-tab-btn:hover {
  background-color: rgba(50, 98, 149, 0.08);
  color: var(--text-main);
}

.robot-tab-btn.active {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: rgba(50, 98, 149, 0.25);
  font-weight: 600;
}

.console-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 9999px;
  background-color: var(--border-dark);
  color: #ffffff;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.console-badge.badge-has-error {
  background-color: #ef4444;
}

.robot-status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full, 9999px);
  background-color: var(--bg-header);
  color: var(--text-muted);
  font-weight: 500;
  border: 1px solid var(--border-light);
}

.robot-status-badge.badge-success {
  background-color: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}

.robot-status-badge.badge-warn {
  background-color: #fef9c3;
  color: #854d0e;
  border-color: #fef08a;
}

.robot-status-badge.badge-error {
  background-color: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.robot-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sm {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  gap: 4px;
}

.robot-close-btn {
  font-size: 14px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.robot-drawer-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.robot-main-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--border-light);
}

.robot-tab-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.console-pane-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background-color: #1e293b;
  border-bottom: 1px solid #334155;
  font-size: 11px;
  color: #94a3b8;
  flex-shrink: 0;
}

.console-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.console-bar-title {
  font-weight: 600;
  color: #e2e8f0;
}

.console-bar-stats {
  font-size: 11px;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.btn-console-tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-console-tool:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.robot-console-output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  background-color: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 0;
}

.console-empty-notice {
  padding: 24px;
  text-align: center;
  color: #64748b;
  font-style: italic;
  font-size: 12px;
}

.console-empty-notice code {
  color: #38bdf8;
  background-color: rgba(56, 189, 248, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
}

.console-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 12px;
  line-height: 1.5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.console-line:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.console-time {
  color: #64748b;
  font-size: 11px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.console-row-tag {
  color: #38bdf8;
  font-size: 11px;
  background: rgba(56, 189, 248, 0.12);
  padding: 0 4px;
  border-radius: 3px;
  flex-shrink: 0;
  font-weight: 500;
  margin-top: 1px;
}

.console-msg {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-all;
}

.console-line.console-log .console-msg {
  color: #f1f5f9;
}

.console-line.console-warn {
  background-color: rgba(245, 158, 11, 0.08);
}

.console-line.console-warn .console-msg {
  color: #fbbf24;
}

.console-line.console-error {
  background-color: rgba(239, 68, 68, 0.12);
}

.console-line.console-error .console-msg {
  color: #f87171;
  font-weight: 500;
}

.console-line.console-info .console-msg {
  color: #60a5fa;
}

.robot-editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background-color: #fafbfc;
  border-bottom: 1px solid var(--border-light);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  gap: 8px;
}

.robot-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.robot-code-file-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-code-tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-code-tool:hover {
  background-color: var(--bg-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-code-tool svg {
  color: var(--text-muted);
  transition: color 0.15s;
}

.btn-code-tool:hover svg {
  color: var(--primary);
}

.robot-filename-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  margin-left: 4px;
  white-space: nowrap;
}

.robot-bar-right {
  display: flex;
  align-items: center;
}

.robot-code-label code {
  color: var(--primary);
  font-family: var(--font-mono);
  font-weight: 600;
}

.robot-code-hint kbd {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 10px;
}

.robot-code-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background-color: #ffffff;
}

.robot-code-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  background-color: #ffffff;
  z-index: 1;
}

.robot-code-highlights {
  box-sizing: border-box;
  margin: 0;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  letter-spacing: normal;
  tab-size: 2;
  white-space: pre;
  word-break: normal;
  color: #1e293b;
  min-height: 100%;
  pointer-events: none;
}

/* Tokens de coloration syntaxique JavaScript */
.robot-code-highlights .tok-comment {
  color: #94a3b8;
  font-style: italic;
}

.robot-code-highlights .tok-string {
  color: #15803d;
}

.robot-code-highlights .tok-keyword {
  color: #7c3aed;
  font-weight: 600;
}

.robot-code-highlights .tok-boolean {
  color: #d97706;
  font-weight: 600;
}

.robot-code-highlights .tok-number {
  color: #0891b2;
}

.robot-code-highlights .tok-builtin {
  color: #326295;
  font-weight: 600;
}

.robot-code-highlights .tok-operator {
  color: #475569;
}

.robot-code-highlights .tok-ident {
  color: #1e293b;
}

.robot-code-editor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 14px;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  letter-spacing: normal;
  tab-size: 2;
  white-space: pre;
  word-break: normal;
  color: transparent !important;
  caret-color: #0f172a !important;
  background-color: transparent !important;
  overflow: auto;
  z-index: 2;
}

.robot-code-editor:focus {
  outline: none;
}

.robot-code-editor::selection {
  background-color: rgba(50, 98, 149, 0.25) !important;
  color: transparent !important;
}

.robot-cheatsheet {
  width: 280px;
  min-width: 260px;
  max-width: 320px;
  padding: 12px 14px;
  background-color: #fafbfc;
  font-size: 12px;
  color: var(--text-secondary, #475569);
  overflow-y: auto;
  flex-shrink: 0;
}

.cheatsheet-title {
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.cheatsheet-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cheatsheet-list li {
  line-height: 1.4;
}

.cheatsheet-list code {
  font-family: var(--font-mono);
  font-size: 11px;
  background-color: #ffffff;
  border: 1px solid var(--border-main);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--primary);
  font-weight: 600;
}
