/* ==========================================================================
   CAIPOP - Interface de Conception Assistée par IA pour les Portes Optiques
   Design fidèle à l'interface de recherche Dalhai (Palette claire, 3 colonnes)
   ========================================================================== */

:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --border-light: rgba(0, 0, 0, 0.06);
  --border-card: rgba(0, 0, 0, 0.05);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.08);

  /* Couleurs sémantiques */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-accent: #0284c7;
  --color-green: #10b981;
  --color-green-dark: #047857;
  --color-red: #ef4444;
  --color-red-dark: #b91c1c;
  --color-amber: #d97706;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* En-tête */
header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-light);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #0f172a;
}

.badge-ciad {
  background: #eff6ff;
  color: #2563eb;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #bfdbfe;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Conteneur Principal */
.main-vertical-container {
  min-width: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px;
  min-height: calc(100vh - 65px);
  box-sizing: border-box;
  gap: 24px;
}

/* Grille Dashboard 3 Colonnes */
.dashboard-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  width: 100%;
  box-sizing: border-box;
}

.dashboard-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-sizing: border-box;
}

.col-left {
  flex: 0 0 612px;
  max-width: 612px;
}

.col-middle {
  flex: 1 1 380px;
  min-width: 320px;
}

.col-right {
  flex: 1 1 320px;
  max-width: 440px;
}

/* ==========================================================================
   1. Colonne Gauche : Carte Géométrique & Grille de Simulations
   ========================================================================== */

.interactive-shape-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
}

.shape-header {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 14px;
}

.shape-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.structure-select-wrapper {
  flex: 1 1 180px;
  position: relative;
}

.simulation-select-wrapper {
  flex: 1 1 200px;
  position: relative;
}

.best-found-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 2px;
}

.best-found-select-wrapper {
  flex: 1;
  position: relative;
}

.sim-select-dropdown {
  font-size: 0.78rem;
  height: 38px;
}

.best-found-dropdown {
  font-size: 0.78rem;
  height: 38px;
}

.structure-select-dropdown {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.structure-select-dropdown:focus {
  border-color: #2563eb;
  background: #ffffff;
}

/* Boutons d'action En-tête */
.btn-head-action {
  height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-apply-opt {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-apply-opt:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
}

.btn-apply-opt:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-meta-proc {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.btn-meta-proc:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.wavelength-info {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* Conteneur Canvas Hexagonal */
.shape-canvas-wrapper {
  position: relative;
  background: #f8fafc;
  border-radius: 12px;
  padding: 8px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  justify-content: center;
}

.hex-container {
  position: relative;
  cursor: pointer;
  width: 570px;
  height: 360px;
  min-width: 570px;
  min-height: 360px;
}

.hex {
  width: 570px;
  height: 360px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  display: block;
  background-color: #ffffff;
}

/* Pastilles des Faisceaux Lasers */
.input-pin {
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 100%;
  font-size: 0.7rem;
  font-weight: bold;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, opacity 0.15s;
  user-select: none;
}

.input-pin.inactive {
  background-color: hsla(220, 14%, 96%, 0.85);
  border: 1px dashed rgba(0, 0, 0, 0.35);
  color: #64748b;
}

.input-pin.active {
  background-color: #10b981;
  color: #ffffff;
  border: 1px solid #047857;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.input-pin.closest {
  opacity: 0.75;
  transform: scale(1.22);
}

/* Contrôles de Zoom Vectoriel et Badge Dipolaire */
.svg-zoom-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 15;
}

.zoom-btn {
  border: none;
  background: transparent;
  color: #1e293b;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 24px;
  height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}

.zoom-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.zoom-reset-btn {
  font-family: monospace;
  font-size: 0.72rem;
  border-left: 1px solid #e2e8f0;
  padding-left: 6px;
}

.dipole-coord-badge {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.82);
  color: #f8fafc;
  font-family: monospace;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 12;
}

/* Étiquettes de dimensions sur la structure */
.image-zero {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 0.72rem;
  font-family: monospace;
  color: #64748b;
  font-weight: bold;
  pointer-events: none;
}

.image-width {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font-size: 0.72rem;
  font-family: monospace;
  color: #64748b;
  font-weight: bold;
  pointer-events: none;
}

.image-height {
  position: absolute;
  left: 6px;
  top: 6px;
  font-size: 0.72rem;
  font-family: monospace;
  color: #64748b;
  font-weight: bold;
  pointer-events: none;
}

/* Grille 2x2 des Configurations de Simulation */
.results-section {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
  width: 100%;
  box-sizing: border-box;
}

.section-title {
  margin-bottom: 16px;
}

.section-title h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}

.section-title p {
  margin: 2px 0 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.simulations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
}

.sim-card-modern {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sim-card-modern:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.image-overlay-wrapper {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.raw-sim-image {
  display: block;
  width: 100%;
  height: auto;
}

.binary-code-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: monospace;
  letter-spacing: 1px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 10;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.hover-details-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.sim-card-modern:hover .hover-details-overlay {
  opacity: 1;
  pointer-events: auto;
}

.details-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 12px;
  color: #f1f5f9;
}

.details-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  margin-bottom: 6px;
  font-weight: bold;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  width: 85%;
  font-size: 0.75rem;
  margin-bottom: 3px;
}

.detail-name {
  color: #cbd5e1;
  font-family: monospace;
}

.detail-value {
  color: #38bdf8;
  font-weight: bold;
  font-family: monospace;
}

.download-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.dl-icon-button {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: all 0.15s ease;
}

.dl-icon-button:hover {
  background: #38bdf8;
  color: #0f172a;
  transform: scale(1.08);
}

/* ==========================================================================
   2. Colonne Centrale : Table de Vérité & Cartes de Portes Optiques
   ========================================================================== */

.table-container-modern {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 12px;
}

.table-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.mini-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-action-blue {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}

.btn-action-blue:hover {
  background: #2563eb;
  color: #ffffff;
}

.btn-action-red {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.btn-action-red:hover:not(:disabled) {
  background: #dc2626;
  color: #ffffff;
}

.btn-action-red:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.table-scroll-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: 8px;
}

.truth-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.truth-table th {
  padding: 8px 12px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
}

.input-header {
  background: #f8fafc;
  color: #475569;
}

.output-header {
  background: #f0fdf4;
  color: #166534;
}

.truth-table td {
  padding: 8px 12px;
  text-align: center;
  font-family: monospace;
  font-size: 0.95rem;
  border-bottom: 1px solid #f1f5f9;
}

/* Cellules Statiques d'Entrée */
.is-static-one {
  background-color: rgba(16, 185, 129, 0.08);
  color: #047857;
  font-weight: bold;
}

.is-static-zero {
  background-color: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
  font-weight: bold;
}

/* Cellules Éditables de Sortie */
.truth-table-cell.clickable {
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}

.truth-table-cell.clickable:hover {
  transform: scale(1.05);
}

.is-one {
  background-color: rgba(16, 185, 129, 0.18);
  color: #047857;
  font-weight: 800;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.is-zero {
  background-color: rgba(239, 68, 68, 0.18);
  color: #b91c1c;
  font-weight: 800;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.not-selectable {
  user-select: none;
}

/* Grille des Cartes de Portes Logiques Optiques */
.gates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  width: 100%;
}

.gate-card-modern {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gate-card-modern:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.gate-card-header {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gate-card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.badge-accent {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  font-family: monospace;
}

.gate-card-body-full {
  width: 100%;
  position: relative;
}

.gate-image-wrapper-full {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 170px;
  overflow: hidden;
  background: #fafafa;
}

.gate-image-full {
  flex: 1;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Réglette Verticale de Graduation (Scale Bar) */
.custom-scale-bar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 48px;
  height: 170px;
  position: relative;
  padding: 6px 0;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
  background: #f8fafc;
  font-size: 0.62rem;
  font-family: monospace;
  color: #475569;
  box-sizing: border-box;
  z-index: 5;
}

.scale-tick {
  line-height: 1;
  z-index: 2;
  background: rgba(248, 250, 252, 0.95);
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: bold;
}

.top-tick {
  color: #0f172a;
}

.bottom-tick {
  color: #64748b;
}

.scale-gradient {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 8px;
  width: 8px;
  background: linear-gradient(to top, #ffffff, #000000);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 2px;
}

.gate-hover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% - 48px);
  height: 100%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.gate-image-wrapper-full:hover .gate-hover-overlay {
  opacity: 1;
  pointer-events: auto;
}

.gate-card-footer-simple {
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.footer-stat {
  display: flex;
  align-items: center;
  gap: 5px;
}

.footer-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.footer-val {
  font-size: 0.8rem;
  font-weight: 700;
  font-family: monospace;
  color: #047857;
}

/* ==========================================================================
   3. Colonne Droite : Sidebar des Contrôles & Options Physiques
   ========================================================================== */

.sidebar-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.options-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
}

.options-card h3 {
  margin: 0 0 4px 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
}

.card-subtitle {
  margin: 0 0 16px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Carte Encodage Binaire */
.binary-encoding-card {
  background: linear-gradient(135deg, #ffffff, #fafbff);
  border-left: 4px solid #3b82f6;
}

.encoding-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.encoding-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.badge-label-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.binary-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: bold;
  color: #ffffff;
}

.badge-zero {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 2px 5px rgba(16, 185, 129, 0.25);
}

.badge-one {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 2px 5px rgba(59, 130, 246, 0.25);
}

.binary-lbl {
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
}

.slider-container-modern {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
}

.modern-slider {
  width: 130px;
  accent-color: #2563eb;
  cursor: pointer;
}

.val-lbl {
  font-size: 0.82rem;
  font-weight: 700;
  font-family: monospace;
  color: #0f172a;
  min-width: 36px;
  text-align: right;
}

/* Carte des Phases */
.phases-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.phase-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.phase-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 22px;
  height: 22px;
  background: #64748b;
  color: #ffffff;
  border-radius: 11px;
  font-size: 0.75rem;
  font-weight: bold;
}

.phase-slider {
  flex: 1;
  accent-color: #10b981;
  cursor: pointer;
}

.phase-val {
  font-size: 0.78rem;
  font-weight: 700;
  font-family: monospace;
  color: #334155;
  min-width: 32px;
  text-align: right;
}

/* Bascules d'Options (Switch Toggles) */
.options-switches-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-switch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.option-switch-item:last-child {
  border-bottom: none;
}

.item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.item-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: #334155;
}

.item-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.switch-toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.2s;
  border-radius: 22px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch-toggle input:checked + .toggle-slider {
  background-color: #2563eb;
}

.switch-toggle input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

/* Carte NPL */
.npl-card-wrapper {
  background: linear-gradient(135deg, #ffffff, #fffdfa);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

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

.npl-badge {
  font-size: 0.65rem;
  font-weight: bold;
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

.npl-sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.npl-slider-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lbl-grp {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #475569;
  font-weight: 500;
}

.lbl-grp .val {
  font-family: monospace;
  font-weight: 700;
  color: #d97706;
}

.npl-slider {
  width: 100%;
  accent-color: #d97706;
  cursor: pointer;
}

.npl-mask-preview-container {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(245, 158, 11, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.npl-mask-preview-header {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
}

.npl-mask-preview-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 180px;
  margin: 0 auto;
  background: #000000;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.npl-mask-preview-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

/* ==========================================================================
   4. Bas de Page : Barre d'Actions & Téléchargements
   ========================================================================== */

.links-container-modern {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px 24px;
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.links-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.links-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.link-button-item {
  height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.link-button-item:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

/* ==========================================================================
   5. Modal Native <dialog> d'Inspection des Métadonnées
   ========================================================================== */

dialog#metadataModal {
  margin: auto;
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  padding: 24px;
  max-width: 820px;
  max-height: 88vh;
  overflow-y: auto;
  width: 92%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

dialog#metadataModal:modal {
  overscroll-behavior: contain;
}

dialog#metadataModal::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 12px;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}

.btn-close-modal {
  background: #f1f5f9;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: all 0.15s;
}

.btn-close-modal:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.meta-section-subtitle {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #334155;
  margin: 12px 0 8px 0;
}

.cross-section-card {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.cross-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.cross-section-svg {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: block;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.meta-grid.meta-grid-3col {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.meta-item {
  background: #f8fafc;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.meta-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
  font-weight: 600;
}

.meta-value {
  font-size: 0.86rem;
  font-weight: 700;
  color: #0f172a;
}

.meta-unknown {
  color: #94a3b8;
  font-style: italic;
  font-weight: 600;
}

.opt-configs-table-wrapper {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 14px;
}

.opt-configs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.opt-configs-table th {
  background: #f1f5f9;
  color: #334155;
  text-align: left;
  padding: 8px 12px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid #cbd5e1;
}

.opt-configs-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}

.opt-doors-cell {
  font-weight: 700;
  font-family: monospace;
  color: #0f172a;
}

.opt-score-cell {
  font-family: monospace;
  font-weight: 700;
  color: #047857;
}

.opt-method-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-genetic {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.badge-exhaustive {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.badge-unknown {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.meta-empty-notice {
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: 8px;
  color: #64748b;
  font-size: 0.82rem;
  margin-bottom: 14px;
}

/* Spinner */
.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.spinner {
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top: 3px solid #2563eb;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
