/***************************************
 * STYLES SAFE - Ne cassent pas P5.js  *
 ***************************************/
html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8f9fa;
  height: 100vh; /* Hauteur pleine pour le centrage */
}

canvas {
  display: block;
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

/* Container principal centré */
#main-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  box-sizing: border-box;
}

/* Wrapper du contenu (canvas + palette) */
#content-wrapper {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Canvas aligné à droite de sa colonne */
#canvas-container {
  display: flex;
  justify-content: flex-end;
  flex: 1;
}

/* Contrôles en 2 colonnes */
#control-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 20px;
  padding: 0;
  background: transparent;
  flex: 1;
}

/* Zone des contrôles - style très léger */
.ui-panel {
  background: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  min-width: 200px;
}

/* Container des contrôles avec espacement vertical */
#control-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 20px;
  padding: 0;
  background: transparent;
}

.control-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hidden-file-input {
  position: absolute;
  left: -9999px;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
}

.file-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.recent-files-select-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.recent-files-label {
  font-size: 12px;
  color: #2c3e50;
  font-weight: 600;
}

.recent-files-select {
  appearance: none;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  color: #2c3e50;
  background: url('data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjNTA1MDUwIiB2aWV3Qm94PSIwIDAgMTIgOCIgd2lkdGg9IjEyIiBoZWlnaHQ9IjgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTAgMGw2IDggNi04eiIvPjwvc3ZnPg==') no-repeat right 8px center/8px 6px, linear-gradient(180deg, rgba(255,255,255,0.95), rgba(245,245,245,0.95));
}

.recent-files-select:focus {
  outline: none;
  border-color: rgba(65, 105, 225, 0.8);
  box-shadow: 0 0 0 2px rgba(65, 105, 225, 0.15);
}

.control-card {
  background: #fdfdfd;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #2c3e50;
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-card h3 span {
  font-size: 16px;
}

.control-card-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recent-files-empty {
  font-size: 12px;
  color: #777;
  font-style: italic;
}

.recent-file-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(100, 149, 237, 0.12);
  border: 1px solid rgba(100, 149, 237, 0.2);
  color: #1f3a60;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.recent-file-button:hover {
  transform: translateY(-1px);
  background: rgba(100, 149, 237, 0.2);
  box-shadow: 0 3px 8px rgba(100, 149, 237, 0.25);
}

.recent-file-button:active {
  transform: translateY(0);
}

/* Groupes libellé + curseur avec libellé au-dessus */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-group label {
  font-size: 12px;
  color: #666;
  margin-bottom: 2px;
}

.control-group input[type="range"] {
  width: 100%;
}

/* Styles pour les tooltips améliorés */
.control-label {
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
  cursor: help;
}

.control-button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.control-button {
  margin-bottom: 4px;
  cursor: help;
}

/* Labels des bornes de curseur */
.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  margin-bottom: 5px;
}

.slider-bound-label {
  font-size: 10px;
  color: #999;
  font-weight: 500;
}

/* Style pour les checkboxes */
.control-checkbox {
  margin: 5px 0;
  font-size: 12px;
  color: #333;
  cursor: pointer;
}

.control-info {
  font-size: 12px;
  color: #555;
}

.status-message {
  min-height: 16px;
}

.status-error {
  color: #c0392b !important;
  font-weight: 600;
}

.ink-options {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ink-options-label {
  font-size: 12px;
  color: #333;
  font-weight: 500;
}

.ink-options .ink-radio {
  display: inline-flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.ink-options .ink-radio label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #333;
  margin: 0;
}

.ink-options .ink-radio input[type="radio"] {
  margin: 0;
}

/* Styles pour les boutons radio d'algorithme */
.algorithm-radio {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 5px;
}

.algorithm-radio label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #333;
  margin: 0;
}

.algorithm-radio input[type="radio"] {
  margin: 0;
}

/* Amélioration des tooltips natifs */
[title] {
  position: relative;
}

/* Style personnalisé pour les tooltips (optionnel) */
.tooltip {
  position: absolute;
  background: #333;
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  max-width: 250px;
  word-wrap: break-word;
}

/* Barre d'outils */
#toolbar {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.tool-link {
  display: inline-block;
  padding: 10px 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  transition: all 0.3s ease;
}

.tool-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  color: white;
  text-decoration: none;
}

.tool-link:active {
  transform: translateY(0);
}

/* PAS de styles sur button, input, etc. pour ne pas casser P5.js */