
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700&display=swap');

body, html {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: 'Open Sans', sans-serif;
}
#toolbar {
  height: 35px;
  line-height: 35px;
  position: relative;
  z-index: 1;
}
#toolbar button {
  margin-right: 10px;
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Open Sans', sans-serif;
  background: #f8f9fa;
  color: #495057;
}

#toolbar button:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#addNodeBtn {
  background: #007bff;
  color: white;
  border-color: #007bff;
}

#addNodeBtn:hover {
  background: #0056b3;
  border-color: #0056b3;
}

#exportProjectBtn, #exportSelectionBtn, #importFileBtn {
  background: #6c757d;
  color: white;
  border-color: #6c757d;
}

#exportProjectBtn:hover, #exportSelectionBtn:hover, #importFileBtn:hover {
  background: #545b62;
  border-color: #545b62;
}
#canvas {
  width: 100vw;
  height: calc(100vh - 35px);
  display: block;
  margin: 0;
  padding: 0;
  position: absolute;
  top: 35px;
  left: 0;
  z-index: 0;
  background: #f0f0f0;
  border-top: 1px solid #ccc;
  cursor: default;
  transition: width 0.1s ease;
  user-select: none;
}
.node {
  cursor: move;
  user-select: none;
}
.node rect {
  fill: white;
  stroke: #2c3e50;
  stroke-width: 1.4;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
  rx: 8;
  ry: 8;
}
.node text {
  font-size: 12px;
  font-family: 'Open Sans', sans-serif;
  font-weight: 500;
  pointer-events: none;
  fill: #2c3e50;
}
.port {
  fill: #444;
  stroke: white;
  stroke-width: 1;
  cursor: pointer;
}

.port.overloaded {
  fill: #f44336;
  stroke: white;
  stroke-width: 2;
  filter: drop-shadow(0 0 4px #f44336);
}
.connection {
  stroke: #0074D9;
  stroke-width: 2;
  fill: none;
  cursor: pointer;
}

.connection:hover {
  stroke-width: 6;
  cursor: pointer;
}

.connection.selected {
  stroke: #1976d2;
  stroke-width: 4;
  filter: drop-shadow(0 0 6px rgba(25, 118, 210, 0.6));
}
.selected {
}
.highlight-connection {
  stroke: white !important;
  stroke-width: 8 !important;
  filter: drop-shadow(0 0 4px white);
  cursor: pointer;
}
.port-hover {
  stroke: #000 !important;
  stroke-width: 3 !important;
  fill: #fff !important;
  filter: drop-shadow(0 0 4px #fff);
}
.node.selected rect {
  stroke: #1976d2 !important;
  stroke-width: 2 !important;
  filter: drop-shadow(0 0 8px rgba(25, 118, 210, 0.6)) drop-shadow(0 4px 8px rgba(0,0,0,0.15)) !important;
}
.node.selected text {
  fill: #1976d2 !important;
  font-weight: 600 !important;
}
.node.selected text[fill="#f44336"] {
  fill: #f44336 !important;
}
.node.selected text[fill="#4caf50"] {
  fill: #4caf50 !important;
}
.node.selected .port {
  fill: #444 !important;
  stroke: white !important;
  stroke-width: 1 !important;
}
.node.selected .bar-background {
  fill: #e3f2fd !important;
  stroke: #000 !important;
  stroke-width: 0.5 !important;
  filter: none !important;
}
.node.selected .bar-load-vert {
  fill: #4caf50 !important;
  stroke: none !important;
  stroke-width: 0 !important;
  filter: none !important;
}
.node.selected .bar-load-rouge {
  fill: #f44336 !important;
  stroke: none !important;
  stroke-width: 0 !important;
  filter: none !important;
}
#editorPanel {
  position: absolute;
  right: 0;
  top: 0;
  width: 500px;
  height: 100%;
  background: #eee;
  border-left: 1px solid #ccc;
  padding: 10px;
  display: none;
  overflow-y: auto;
  box-sizing: border-box;
  resize: horizontal;
}

#editorPanel::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 100vh;
  background: transparent;
  cursor: ew-resize;
  z-index: 10;
  pointer-events: auto;
}

#editorPanel:hover::before {
  background: rgba(0, 0, 0, 0.1);
}

#editorPanel.resizing::before {
  background: rgba(0, 0, 0, 0.2);
}

.temp-connection-green {
  stroke: #4caf50 !important;
  filter: drop-shadow(0 0 4px #4caf50);
}
.temp-connection-red {
  stroke: #f44336 !important;
  filter: drop-shadow(0 0 4px #f44336);
}
.bar-load-vert {
  fill: #4caf50 !important;
  stroke: #000 !important;
  stroke-width: 1px !important;
}
.bar-load-rouge {
  fill: #f44336 !important;
  stroke: #000 !important;
  stroke-width: 1px !important;
}

/* Rectangles de fond pour les barres de charge */
.bar-background {
  fill: #e3f2fd !important;
  stroke: #000 !important;
  stroke-width: 0.5 !important;
  opacity: 1 !important;
}

/* Barres de charge par-dessus */
.bar-load-vert {
  fill: #4caf50 !important;
  stroke: none !important;
  stroke-width: 0 !important;
  z-index: 10 !important;
}
.bar-load-rouge {
  fill: #f44336 !important;
  stroke: none !important;
  stroke-width: 0 !important;
  z-index: 10 !important;
}

/* Forcer les barres de charge SVG à être rectangulaires, sans arrondi */
.bar-background,
.bar-load-vert,
.bar-load-rouge {
  border-radius: 0 !important;
  rx: 0 !important;
  ry: 0 !important;
}
svg rect.bar-background,
svg rect.bar-load-vert,
svg rect.bar-load-rouge {
  border-radius: 0 !important;
  rx: 0 !important;
  ry: 0 !important;
}

#contextMenu {
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  border-radius: 6px;
  padding: 4px 0;
  z-index: 1000;
  position: absolute;
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 2px 2px 8px #aaa;
  min-width: 180px;
}
#contextMenu .context-option {
  padding: 8px 18px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
#contextMenu .context-option:hover {
  background: #e3eaff;
}

/* Modal d'aide */
#helpModal {
  backdrop-filter: blur(2px);
}

#helpContent {
  font-family: 'Open Sans', sans-serif;
  line-height: 1.6;
}

#helpContent h3 {
  color: #1976d2;
  margin-top: 25px;
  margin-bottom: 10px;
  font-size: 18px;
}

#helpContent h3:first-of-type {
  margin-top: 0;
}

#helpContent ul {
  margin: 10px 0;
  padding-left: 20px;
}

#helpContent li {
  margin: 5px 0;
}

#helpContent strong {
  color: #333;
}

#closeHelpBtn:hover {
  color: #1976d2 !important;
  transform: scale(1.1);
  transition: all 0.2s ease;
}

#helpBtn {
  background: #28a745;
  color: white;
  border-color: #28a745;
}

#helpBtn:hover {
  background: #1e7e34;
  border-color: #1e7e34;
}

#printBtn {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
}

#printBtn:hover {
  background: #c82333;
  border-color: #c82333;
}

/* Styles pour tous les boutons du projet */
button {
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 500;
  background: #f8f9fa;
  color: #495057;
}

button:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Styles pour les inputs */
input[type="text"], input[type="number"], select {
  border: 1px solid #ddd;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Open Sans', sans-serif;
  background: #fff;
  color: #495057;
  transition: all 0.2s ease;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Styles spécifiques pour les boutons du panneau d'édition */
#editorPanel button {
  margin: 2px 4px 2px 0;
}

#editorPanel button[onclick*="duplicateNode"] {
  background: #28a745;
  color: white;
  border-color: #28a745;
}

#editorPanel button[onclick*="duplicateNode"]:hover {
  background: #1e7e34;
  border-color: #1e7e34;
}

#editorPanel button[onclick*="deleteNode"] {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
}

#editorPanel button[onclick*="deleteNode"]:hover {
  background: #c82333;
  border-color: #c82333;
}

#editorPanel button[onclick*="addPort"] {
  background: #17a2b8;
  color: white;
  border-color: #17a2b8;
}

#editorPanel button[onclick*="addPort"]:hover {
  background: #138496;
  border-color: #138496;
}

/* Styles pour les boutons de suppression dans les listes */
#editorPanel button[onclick*="removePort"] {
  background: #6c757d;
  color: white;
  border-color: #6c757d;
  padding: 2px 6px;
  font-size: 11px;
  margin-left: 4px;
}

#editorPanel button[onclick*="removePort"]:hover {
  background: #545b62;
  border-color: #545b62;
}

/* Styles pour les labels */
#editorPanel label {
  font-weight: 500;
  color: #495057;
  margin-bottom: 4px;
  display: block;
}

/* Styles pour les séparateurs */
#editorPanel hr {
  border: none;
  border-top: 1px solid #dee2e6;
  margin: 15px 0;
}

/* Styles pour les titres */
#editorPanel h3, #editorPanel h4 {
  color: #495057;
  margin-top: 20px;
  margin-bottom: 10px;
  font-family: 'Open Sans', sans-serif;
}

#editorPanel h3 {
  font-size: 18px;
  border-bottom: 2px solid #007bff;
  padding-bottom: 5px;
}

#editorPanel h4 {
  font-size: 16px;
  color: #6c757d;
}

/* Styles pour les conteneurs d'entrées et sorties */
#inputList, #outputList {
  margin: 10px 0;
}

/* Styles pour chaque entrée/sortie */
#inputList > div, #outputList > div {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

#inputList > div:hover, #outputList > div:hover {
  background: #e9ecef;
  border-color: #dee2e6;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Styles spécifiques pour les entrées */
#inputList > div {
  border-left: 4px solid #007bff;
  background: linear-gradient(135deg, #f8f9fa 0%, #e3f2fd 100%);
}

/* Styles spécifiques pour les sorties */
#outputList > div {
  border-left: 4px solid #28a745;
  background: linear-gradient(135deg, #f8f9fa 0%, #e8f5e8 100%);
}

/* Styles pour les champs dans les entrées/sorties */
#inputList input, #outputList input,
#inputList select, #outputList select {
  margin: 4px 0;
  width: 100%;
  box-sizing: border-box;
}

/* Style spécifique pour les sélecteurs d'unités */
#inputList select, #outputList select {
  width: auto;
  min-width: 50px;
}

/* Correction pour éviter les retours à la ligne dans les labels */
#inputList label, #outputList label {
  display: inline;
  margin-right: 8px;
}

/* Styles pour les conteneurs de champs */
#inputList .field-group, #outputList .field-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

#inputList .field-group > *, #outputList .field-group > * {
  margin: 0;
}

/* Styles pour les boutons dans les entrées/sorties */
#inputList button, #outputList button {
  margin: 4px 4px 4px 0;
}

/* Espacement entre les éléments dans chaque entrée/sortie */
#inputList > div > *, #outputList > div > * {
  margin-bottom: 6px;
}

#inputList > div > *:last-child, #outputList > div > *:last-child {
  margin-bottom: 0;
}
