/* Styles complémentaires pour l'éditeur SVG et l'interface flat Knarr Studio */

:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* Scrollbars fines et discrètes */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #262932;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #383d4a;
}

/* Accessibilité : focus visible discret */
button:focus-visible,
input:focus-visible,
select:focus-visible,
svg:focus-visible {
  outline: 1.5px solid #525766;
  outline-offset: 1px;
}

/* États du curseur sur le canvas */
#editor-svg.canvas-space-ready {
  cursor: grab;
}

#editor-svg.canvas-panning {
  cursor: grabbing;
}

#editor-svg.dragging-node {
  cursor: grabbing;
}

/* Nœuds SVG flat */
.node-group {
  cursor: grab;
}

.node-group:active {
  cursor: grabbing;
}

.node-card {
  fill: #14161b;
  stroke: #262932;
  stroke-width: 1;
  transition: stroke 120ms ease, fill 120ms ease;
}

.node-group:hover .node-card {
  fill: #191c23;
  stroke: #3a3f4d;
}

.node-group.node-selected .node-card {
  stroke: #e4e4e7;
  stroke-width: 1.5;
}

.node-label {
  fill: #f4f4f5;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
}

.node-subtitle {
  fill: #8c919e;
  font-size: 10.5px;
  pointer-events: none;
}

.node-metrics-text {
  fill: #787d8a;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  pointer-events: none;
}

.node-gauge-bg {
  fill: #22252e;
}

.node-gauge-fill {
  fill: #22c55e;
  transition: width 120ms ease, fill 120ms ease;
}

.node-divider {
  stroke: #22252e;
  stroke-width: 1;
}

.node-rows-bg {
  fill: #101216;
  stroke: #22252e;
  stroke-width: 1;
}

.node-row-sep {
  stroke: #1d2028;
  stroke-width: 1;
}

.node-row-icon {
  stroke: #6b7180;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
}

.node-row-label {
  fill: #8c919e;
  font-size: 9.5px;
  pointer-events: none;
}

.node-row-value {
  fill: #d4d4d8;
  font-size: 9.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  pointer-events: none;
}

.node-row-value.is-ok { fill: #86efac; }
.node-row-value.is-warn { fill: #fcd34d; }
.node-row-value.is-bad { fill: #fca5a5; }
.node-row-value.is-muted { fill: #5b606c; }

/* Ports d'entrée et sortie */
.node-port {
  fill: #14161b;
  stroke: #525766;
  stroke-width: 1.5;
  transition: r 100ms ease, stroke 100ms ease, fill 100ms ease;
}

.node-port-hit {
  fill: transparent;
  cursor: crosshair;
}

.node-port-group:hover .node-port,
.node-port-group.port-highlight .node-port {
  fill: #38bdf8;
  stroke: #0b0c0f;
}

.node-port-group.port-valid-target .node-port {
  fill: #22c55e;
  stroke: #0b0c0f;
}

.node-port-dlq-label {
  fill: #f59e0b;
  font-size: 7.5px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* Liens Bézier SVG flat */
.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  cursor: pointer;
}

.edge-path {
  fill: none;
  stroke: #464b58;
  stroke-linecap: round;
  transition: stroke 120ms ease;
  pointer-events: none;
}

.edge-group:hover .edge-path {
  stroke: #717787;
}

.edge-group.edge-selected .edge-path {
  stroke: #38bdf8;
}

.edge-badge {
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}

.edge-format-pill {
  transition: opacity 120ms ease;
  pointer-events: none;
}

.edge-format-pill-bg {
  fill: #101216;
  stroke: #2f3441;
  stroke-width: 1;
}

.edge-format-pill-text {
  font-size: 8.5px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.02em;
}

.edge-group:hover .edge-format-pill,
.edge-group.edge-selected .edge-format-pill {
  opacity: 0;
}

.edge-group:hover .edge-badge,
.edge-group.edge-selected .edge-badge {
  opacity: 1;
}

.edge-badge-bg {
  fill: #14161b;
  stroke: #262932;
  stroke-width: 1;
}

.edge-badge-text {
  fill: #d4d4d8;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.edge-draft {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 1.8;
  stroke-dasharray: 5 4;
  pointer-events: none;
}

/* Rectangle de multi-sélection */
.marquee-rect {
  fill: rgba(56, 189, 248, 0.08);
  stroke: #38bdf8;
  stroke-width: 1;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

/* Lignes de la palette */
.palette-item {
  transition: background-color 120ms ease, color 120ms ease;
}

.palette-item:hover {
  background-color: #1e212a;
}

/* Input flottant de renommage inline */
.inline-rename-input {
  position: absolute;
  z-index: 40;
  background: #14161b;
  color: #f4f4f5;
  border: 1px solid #525766;
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 500;
}

/* Info-bulles paramètres */
.param-tooltip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 9999px;
  background: #1e212a;
  color: #71717a;
  font-size: 10px;
  font-weight: 600;
  cursor: help;
}

.param-tooltip-btn:hover {
  background: #2b2f3a;
  color: #e4e4e7;
}

/* États visuels flat en simulation Mode Flux */
.node-group.node-status-healthy .node-card {
  stroke: #22c55e;
  stroke-width: 1.5;
}

.node-group.node-status-warn .node-card {
  stroke: #f59e0b;
  stroke-width: 1.5;
}

.node-group.node-status-saturated .node-card {
  stroke: #ef4444;
  stroke-width: 2;
}

.node-group.node-status-failed .node-card {
  fill: url(#pattern-failed);
  stroke: #525766;
}

@keyframes bottleneck-pulse {
  0%, 100% {
    stroke-opacity: 0.45;
  }
  50% {
    stroke-opacity: 1;
  }
}

.node-group.node-bottleneck .node-card {
  stroke: #ef4444;
  stroke-width: 2;
  animation: bottleneck-pulse 1.3s ease-in-out infinite;
}

.edge-group.edge-status-healthy .edge-path {
  stroke: #22c55e;
}

.edge-group.edge-status-warn .edge-path {
  stroke: #f59e0b;
}

.edge-group.edge-status-saturated .edge-path {
  stroke: #ef4444;
}

/* États visuels flat en simulation Mode DAG */
.node-group.node-dag-pending .node-card {
  stroke: #3f4452;
  opacity: 0.78;
}

.node-group.node-dag-ready .node-card {
  stroke: #f59e0b;
  stroke-dasharray: 4 3;
}

.node-group.node-dag-running .node-card {
  stroke: #38bdf8;
  stroke-width: 1.5;
}

.node-group.node-dag-done .node-card {
  stroke: #22c55e;
  stroke-width: 1.5;
}

.node-group.node-dag-failed .node-card {
  fill: url(#pattern-failed);
  stroke: #ef4444;
  stroke-width: 2;
}

.node-group.node-dag-blocked .node-card {
  stroke: #ef4444;
  stroke-dasharray: 4 3;
  opacity: 0.72;
}

.node-group.node-critical-path .node-card {
  stroke: #f59e0b;
  stroke-width: 1.5;
}

.edge-group.edge-critical-path .edge-path {
  stroke: #f59e0b;
  stroke-dasharray: 0;
}

.node-group.node-periodic-active .node-card {
  stroke: #818cf8;
  stroke-width: 1.5;
}

.node-group.node-periodic-waiting .node-card {
  stroke-dasharray: 5 3;
  opacity: 0.88;
}

.node-group.node-restarting .node-card {
  stroke: #f97316;
  stroke-dasharray: 3 3;
  opacity: 0.78;
}

.node-group.node-scaling .node-card {
  stroke: #326CE5;
  stroke-width: 1.5;
}

.node-runtime-badge-bg {
  fill: #1b1e26;
  stroke: #2b2f3a;
  stroke-width: 1;
}

.node-runtime-badge-text {
  fill: #d4d4d8;
  font-size: 9px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.node-rgpd-badge-bg {
  fill: #16181d;
  stroke: #2f3441;
  stroke-width: 1;
}

.node-rgpd-badge-text {
  fill: #e4e4e7;
  font-size: 8.5px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.02em;
}

.node-group.node-rgpd-alert .node-rgpd-badge-bg {
  fill: #241417;
  stroke: #ef4444;
  stroke-width: 1.2;
}

/* Groupes / zones Draw.io flat */
.group-header-hit,
.group-border-hit {
  cursor: grab;
}

.group-header-hit:active,
.group-border-hit:active {
  cursor: grabbing;
}

.group-label {
  fill: #f4f4f5;
  font-size: 11.5px;
  font-weight: 500;
  pointer-events: none;
}

.group-subtitle {
  fill: #8c919e;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  pointer-events: none;
}

.group-outline {
  stroke-opacity: 0.48;
}

.group-container.group-selected .group-outline {
  stroke-width: 1.8;
  stroke-opacity: 1;
}

.group-resize-handle {
  display: none;
}

.group-container.group-selected .group-resize-handle {
  display: block;
}

/* Mode simplifié : états visuels basiques sans saturation ni alertes */
.node-group.node-simple-active .node-card {
  stroke: #38bdf8;
  stroke-width: 1.4;
}

.edge-group.edge-simple-active .edge-path {
  stroke: #71717a;
}

/* Axe 1 : Notes, groupes pliables, port Rejets DLQ et recherche canvas */
.group-collapse-btn {
  cursor: pointer;
}

.group-collapse-btn:hover rect {
  fill: #22252e;
}

.note-container {
  cursor: grab;
}

.note-container:active {
  cursor: grabbing;
}

.note-title {
  fill: #f4f4f5;
  font-size: 11.5px;
  font-weight: 500;
  pointer-events: none;
}

.note-body {
  fill: #a1a1aa;
  font-size: 10.5px;
  pointer-events: none;
}

.note-container.note-selected .note-bg {
  stroke-width: 1.8;
  stroke-opacity: 1;
}

.note-resize-handle {
  display: none;
}

.note-container.note-selected .note-resize-handle {
  display: block;
}

.node-port.node-port-reject {
  fill: #1c1812;
  stroke: #f59e0b;
  stroke-width: 1.5;
}

.edge-group.edge-reject .edge-path {
  stroke: #f59e0b;
  stroke-dasharray: 5 3;
}

.node-group.canvas-search-match .node-card,
.group-container.canvas-search-match .group-outline,
.note-container.canvas-search-match .note-bg {
  stroke: #38bdf8;
  stroke-width: 2;
  stroke-opacity: 1;
}

.gantt-wait-bar {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(245, 158, 11, 0.2),
    rgba(245, 158, 11, 0.2) 4px,
    rgba(245, 158, 11, 0.4) 4px,
    rgba(245, 158, 11, 0.4) 8px
  );
}

/* Axe 3 & 4 : DLQ, Circuit Breaker, Schema Drift, SLA & Field Lineage */
.edge-group.edge-dlq .edge-path {
  stroke: #ef4444;
  stroke-dasharray: 5 3;
}

.node-group.node-circuit-open .node-card {
  stroke: #f97316;
  stroke-width: 2;
  stroke-dasharray: 5 3;
}

.node-group.node-schema-error .node-card {
  stroke: #ef4444;
  stroke-width: 2;
}

.node-group.node-sla-fail .node-card {
  stroke: #ef4444;
  stroke-width: 1.8;
}

.node-sla-badge-bg {
  fill: #16181d;
  stroke: #2f3441;
  stroke-width: 1;
}

.node-sla-badge-text {
  font-size: 8.5px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.node-group.lineage-dimmed,
.edge-group.lineage-dimmed {
  opacity: 0.2;
}

.node-group.lineage-raw .node-card {
  stroke: #f59e0b;
  stroke-width: 2;
}

.node-group.lineage-masked .node-card {
  stroke: #a78bfa;
  stroke-width: 2;
}

.node-group.lineage-dropped .node-card {
  stroke: #10b981;
  stroke-width: 2;
  stroke-dasharray: 4 2;
}

.edge-group.lineage-raw .edge-path {
  stroke: #f59e0b;
  stroke-width: 2.4;
}

.edge-group.lineage-masked .edge-path {
  stroke: #a78bfa;
  stroke-width: 2.4;
}

/* Blocage complet de l'éditeur sur téléphone (portrait < 768px ou paysage tactile <= 500px de hauteur) */
@media (max-width: 767px), (max-height: 500px) and (pointer: coarse) {
  body > *:not(#mobile-blocker) {
    display: none !important;
  }

  #mobile-blocker {
    display: flex !important;
  }
}

/* Respect des préférences de réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
