/* Zenmark Editor - Modern GitHub-Aligned Design System */

.zenmark-editor {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.zenmark-editor:focus-within {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.08);
}

.zenmark-editor.zenmark-dragover {
  border: 2px dashed #C21057 !important;
  background-color: rgba(194, 16, 87, 0.02) !important;
}

/* Toolbar Buttons */
.zenmark-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  min-width: 28px;
  height: 28px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: #475569;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.zenmark-tool-btn:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.zenmark-tool-btn:active {
  background-color: #e2e8f0;
  transform: scale(0.97);
}

/* Mode Switcher Buttons (Write / Split / Preview) */
.zenmark-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.zenmark-mode-btn:hover {
  color: #0f172a;
}

.zenmark-mode-btn.active {
  background-color: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Workspace Layouts */
.zenmark-workspace {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 550px;
  display: flex;
  overflow: hidden;
}

/* Write Mode (Default) */
.zenmark-workspace.zenmark-mode-write .zenmark-editor-pane {
  flex: 1 1 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: block;
}

.zenmark-workspace.zenmark-mode-write .zenmark-preview-pane {
  display: none !important;
}

/* Split Mode (Side-by-Side) */
.zenmark-workspace.zenmark-mode-split {
  display: flex;
  flex-direction: row;
}

.zenmark-workspace.zenmark-mode-split .zenmark-editor-pane {
  flex: 1 1 50%;
  width: 50%;
  max-width: 50%;
  min-width: 0;
  box-sizing: border-box;
  border-right: 1px solid #e2e8f0;
  display: block;
}

.zenmark-workspace.zenmark-mode-split .zenmark-preview-pane {
  flex: 1 1 50%;
  width: 50%;
  max-width: 50%;
  min-width: 0;
  box-sizing: border-box;
  display: block;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 750px;
  padding: 1.5rem;
  background-color: #fbfcfd;
}

/* Preview Mode (Full Preview) */
.zenmark-workspace.zenmark-mode-preview .zenmark-editor-pane {
  display: none !important;
}

.zenmark-workspace.zenmark-mode-preview .zenmark-preview-pane {
  flex: 1 1 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: block;
  overflow-x: auto;
  overflow-y: auto;
  min-height: 550px;
  padding: 2rem;
  background-color: #ffffff;
}

/* The Markdown Textarea */
.zenmark-textarea {
  width: 100%;
  min-height: 550px;
  height: 650px;
  padding: 1.25rem 1.5rem;
  border: none;
  outline: none !important;
  resize: vertical;
  background-color: #ffffff;
  color: #0f172a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  letter-spacing: -0.01em;
  tab-size: 2;
  box-sizing: border-box;
}

.zenmark-textarea::placeholder {
  color: #94a3b8;
  font-family: inherit;
}

/* Rendered Markdown Typography in Preview */
.zenmark-preview-content {
  color: #1e293b;
  font-size: 15px;
  line-height: 1.75;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

.zenmark-preview-content h1,
.zenmark-preview-content h2,
.zenmark-preview-content h3,
.zenmark-preview-content h4 {
  color: #0f172a;
  font-weight: 700;
  margin-top: 1.75em;
  margin-bottom: 0.6em;
  line-height: 1.3;
}

.zenmark-preview-content h1 {
  font-size: 1.75rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.35em;
}

.zenmark-preview-content h2 {
  font-size: 1.35rem;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.25em;
}

.zenmark-preview-content h3 {
  font-size: 1.15rem;
}

.zenmark-preview-content p {
  margin-top: 0;
  margin-bottom: 1.1em;
}

.zenmark-preview-content a {
  color: #C21057;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}

.zenmark-preview-content blockquote {
  border-left: 3px solid #C21057;
  padding-left: 1rem;
  margin: 1.2em 0;
  color: #64748b;
  font-style: italic;
  background-color: #fff9fa;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-radius: 0 8px 8px 0;
}

.zenmark-preview-content ul {
  list-style-type: disc;
  padding-left: 1.4rem;
  margin: 0.8em 0;
}

.zenmark-preview-content ol {
  list-style-type: decimal;
  padding-left: 1.4rem;
  margin: 0.8em 0;
}

.zenmark-preview-content li {
  margin-bottom: 0.35em;
}

.zenmark-preview-content code {
  background-color: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  border: 1px solid #e2e8f0;
}

.zenmark-preview-content pre {
  background-color: #0f172a;
  color: #f8fafc;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  margin: 1.25em 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.zenmark-preview-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
  font-size: inherit;
}

.zenmark-preview-content img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  margin: 1.25em 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.zenmark-preview-content hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 2em 0;
}

.zenmark-preview-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 13.5px;
}

.zenmark-preview-content th,
.zenmark-preview-content td {
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  text-align: left;
}

.zenmark-preview-content th {
  background-color: #f8fafc;
  font-weight: 600;
  color: #0f172a;
}

.zenmark-preview-content tr:nth-child(even) td {
  background-color: #fbfcfd;
}

/* Zen Mode (Fullscreen) */
.zenmark-editor.zenmark-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  display: flex !important;
  flex-direction: column !important;
  background-color: #ffffff !important;
  box-shadow: none !important;
}

.zenmark-editor.zenmark-fullscreen .zenmark-toolbar {
  padding-left: 2rem;
  padding-right: 2rem;
  border-bottom: 1px solid #e2e8f0;
}

.zenmark-editor.zenmark-fullscreen .zenmark-workspace {
  flex: 1 1 auto;
  height: calc(100vh - 86px);
  max-height: calc(100vh - 86px);
}

.zenmark-editor.zenmark-fullscreen .zenmark-workspace.zenmark-mode-write .zenmark-textarea {
  max-width: 920px;
  margin: 0 auto;
  height: 100%;
  min-height: 100%;
  padding: 2.5rem 2rem;
  font-size: 16px;
  line-height: 1.8;
}

.zenmark-editor.zenmark-fullscreen .zenmark-workspace.zenmark-mode-split .zenmark-textarea,
.zenmark-editor.zenmark-fullscreen .zenmark-workspace.zenmark-mode-split .zenmark-preview-pane {
  height: 100%;
  max-height: 100%;
  padding: 2rem;
}

.zenmark-editor.zenmark-fullscreen .zenmark-workspace.zenmark-mode-preview .zenmark-preview-pane {
  max-width: 920px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

.zenmark-editor.zenmark-fullscreen .zenmark-status-bar > div {
  padding-left: 2rem;
  padding-right: 2rem;
}

/* Toast Notification */
.zenmark-toast {
  position: absolute;
  bottom: 48px;
  right: 18px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: #0f172a;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
  animation: zenmarkToastFadeIn 0.2s ease;
}

.zenmark-toast.hidden,
.zenmark-toast:empty {
  display: none !important;
}

.zenmark-toast.zenmark-toast-error {
  background-color: #e11d48;
}

@keyframes zenmarkToastFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Zenmark Visual Architecture Studio (diagram-js Integration)
   ========================================================================== */

.djs-parent {
  --accent-color: #C21057;
  --bendpoint-fill-color: #C21057;
  --bendpoint-stroke-color: #ffffff;
  --resizer-fill-color: #C21057;
  --resizer-stroke-color: #ffffff;
  --snap-line-stroke-color: rgba(194, 16, 87, 0.35);
}

.djs-container {
  width: 100% !important;
  height: 100% !important;
}

.djs-outline,
.djs-selection-outline {
  fill: none;
  shape-rendering: geometricPrecision;
  stroke-width: 2px;
}

.djs-outline {
  visibility: hidden;
}

.djs-element.selected .djs-outline {
  visibility: visible;
  stroke: #C21057;
  stroke-dasharray: 4 3;
}

.djs-connection.selected .djs-outline {
  display: none;
}

.djs-visual,
.djs-outline {
  pointer-events: none;
}

.djs-element > .djs-hit-all,
.djs-element > .djs-hit-no-move {
  pointer-events: all;
  cursor: move;
}

.djs-element > .djs-hit-stroke,
.djs-element > .djs-hit-click-stroke {
  pointer-events: stroke;
  cursor: pointer;
}

.djs-dragger * {
  fill: none !important;
  stroke: #C21057 !important;
}

.djs-dragging,
.djs-dragging > * {
  opacity: 0.35 !important;
  pointer-events: none !important;
}

.djs-snap-line {
  stroke: rgba(194, 16, 87, 0.35);
  stroke-linecap: round;
  stroke-width: 1.5px;
  pointer-events: none;
}

/* Resize Handles */
.djs-resize-overlay {
  fill: none;
  stroke-dasharray: 5 2;
  stroke: #C21057;
  pointer-events: none;
}

.djs-resizer-hit {
  fill: none;
  pointer-events: all;
}

.djs-resizer-visual {
  fill: #C21057;
  stroke-width: 1.5px;
  stroke: #ffffff;
}

.djs-resizer-n, .djs-resizer-s { cursor: ns-resize; }
.djs-resizer-e, .djs-resizer-w { cursor: ew-resize; }
.djs-resizer-nw, .djs-resizer-se { cursor: nwse-resize; }
.djs-resizer-ne, .djs-resizer-sw { cursor: nesw-resize; }

/* Bendpoints on Connections */
.djs-segment-dragger,
.djs-bendpoint {
  display: none;
}

.djs-segment-dragger .djs-visual,
.djs-bendpoint .djs-visual {
  fill: #C21057;
  stroke: #ffffff;
  stroke-width: 1.5px;
}

.djs-segment-dragger:hover,
.djs-bendpoints.hover .djs-segment-dragger,
.djs-bendpoints.selected .djs-segment-dragger,
.djs-bendpoint:hover,
.djs-bendpoints.hover .djs-bendpoint,
.djs-bendpoints.selected .djs-bendpoint {
  display: block;
}

.djs-segment-dragger .djs-hit,
.djs-bendpoint .djs-hit {
  fill: none;
  pointer-events: all;
}

.djs-segment-dragger.horizontal .djs-hit { cursor: ns-resize; }
.djs-segment-dragger.vertical .djs-hit { cursor: ew-resize; }

/* On-Canvas Context Pad */
.djs-context-pad {
  position: absolute;
  display: none;
  pointer-events: none;
  line-height: 1;
  width: 36px;
  z-index: 100;
}

.djs-context-pad.open {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.djs-context-pad .entry {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
  transition: all 0.12s ease;
}

.djs-context-pad .entry:hover {
  background-color: #f8fafc;
  border-color: #C21057;
  color: #C21057;
  transform: scale(1.06);
}

.djs-context-pad .entry.cq-pad-danger:hover {
  background-color: #fff1f2;
  border-color: #e11d48;
  color: #e11d48;
}
