/**
 * MermaidDiagram component styles
 * @countermeasure/web-components/visualization/mermaid-diagram
 */

.cmm-mermaid-diagram {
  position: relative;
  width: 100%;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: hsl(var(--background, 0 0% 100%));
  border: 1px solid hsl(var(--border, 0 0% 89%));
  border-radius: var(--radius-md, 0.5rem);
  overflow: hidden;
}

/* SVG container */
.cmm-mermaid-diagram__svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Loading state */
.cmm-mermaid-diagram__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem;
  color: hsl(var(--muted-foreground, 0 0% 42%));
}

.cmm-mermaid-diagram__spinner {
  width: 24px;
  height: 24px;
  border: 2px solid hsl(var(--border, 0 0% 89%));
  border-top-color: hsl(var(--primary, 189 94% 43%));
  border-radius: 50%;
  animation: cmm-mermaid-spin 0.8s linear infinite;
}

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

.cmm-mermaid-diagram__loading-text {
  font-size: 0.875rem;
}

/* Error state */
.cmm-mermaid-diagram__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem;
  text-align: center;
  max-width: 100%;
}

.cmm-mermaid-diagram__error-icon {
  color: hsl(var(--destructive, 0 84% 60%));
}

.cmm-mermaid-diagram__error-title {
  font-weight: 600;
  color: hsl(var(--foreground, 0 0% 3%));
}

.cmm-mermaid-diagram__error-message {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground, 0 0% 42%));
  max-width: 400px;
}

.cmm-mermaid-diagram__error-source {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: hsl(var(--muted, 0 0% 96%));
  border: 1px solid hsl(var(--border, 0 0% 89%));
  border-radius: var(--radius-sm, 0.375rem);
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color: hsl(var(--muted-foreground, 0 0% 42%));
  max-width: 100%;
  max-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}

/* Override mermaid default styles to match CounterMeasure theme */
.cmm-mermaid-diagram .node rect,
.cmm-mermaid-diagram .node circle,
.cmm-mermaid-diagram .node ellipse,
.cmm-mermaid-diagram .node polygon,
.cmm-mermaid-diagram .node path {
  stroke-width: 1px;
}

.cmm-mermaid-diagram .edgePath path {
  stroke-width: 1.5px;
}

.cmm-mermaid-diagram .label {
  font-family: inherit;
}

.cmm-mermaid-diagram .cluster rect {
  stroke-width: 1px;
}

/* Sequence diagram adjustments */
.cmm-mermaid-diagram .actor {
  stroke-width: 1px;
}

.cmm-mermaid-diagram .messageText {
  font-family: inherit;
}

/* Gantt chart adjustments */
.cmm-mermaid-diagram .section {
  stroke-width: 0;
}

/* Pie chart adjustments */
.cmm-mermaid-diagram .pieTitleText {
  font-family: inherit;
  font-weight: 600;
}

.cmm-mermaid-diagram .pieCircle {
  stroke-width: 1px;
}

/* Git graph adjustments */
.cmm-mermaid-diagram .commit-id,
.cmm-mermaid-diagram .commit-msg,
.cmm-mermaid-diagram .branch-label {
  font-family: inherit;
}

/* Timeline adjustments */
.cmm-mermaid-diagram .timeline-event {
  font-family: inherit;
}

/* Mindmap adjustments */
.cmm-mermaid-diagram .mindmap-node {
  font-family: inherit;
}

/* Dark mode specific overrides */
.dark .cmm-mermaid-diagram,
[data-theme="dark"] .cmm-mermaid-diagram {
  background: hsl(var(--background, 222 47% 11%));
  border-color: hsl(var(--border, 217 33% 17%));
}

.dark .cmm-mermaid-diagram__error-source,
[data-theme="dark"] .cmm-mermaid-diagram__error-source {
  background: hsl(var(--muted, 217 33% 17%));
  border-color: hsl(var(--border, 217 33% 17%));
}
