/* Mermaid diagram styling */
.mermaid {
  width: 100%;
  min-height: 200px;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  background: var(--md-code-bg-color);
  position: relative;
  overflow: auto;
  cursor: pointer;
  padding: 16px;
  transition: border-color 0.2s ease;
}

.mermaid:hover {
  border-color: var(--md-primary-fg-color);
}

/* Style SVGs inside mermaid containers */
.mermaid svg {
  cursor: pointer;
  display: block;
  margin: 0 auto;
}

/* SVG with zoom initialized - visual feedback */
svg[data-mermaid-zoom-init="true"] {
  cursor: pointer;
}

svg[data-mermaid-zoom-init="true"]:hover {
  filter: brightness(1.02);
}

/* Full-screen modal */
#mermaid-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
}

#mermaid-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mermaid-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}

.mermaid-modal-content {
  position: relative;
  width: 95vw;
  height: 95vh;
  max-width: 1800px;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  z-index: 1;
}

.mermaid-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 2rem;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  color: #666;
  z-index: 10;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.mermaid-modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #000;
}

.mermaid-modal-body {
  width: 100%;
  height: 100%;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.mermaid-modal-body svg {
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
}

/* Dark mode support */
[data-md-color-scheme="slate"] .mermaid-modal-content {
  background: #2d2d2d;
}

[data-md-color-scheme="slate"] .mermaid-modal-close {
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

[data-md-color-scheme="slate"] .mermaid-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Keyboard hint */
#mermaid-modal.active::after {
  content: "Press ESC to close";
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 12px;
  border-radius: 4px;
  z-index: 10000;
}
