/* ═══════════════════════════════════════════════════════════════════
   Visual YAML Editor - Stylesheet
   Modern, reactive dual-pane tree + code editor with dark/light mode
   ═══════════════════════════════════════════════════════════════════ */

.yaml-studio-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 135px);
  min-height: 720px;
  gap: 12px;
  padding: 12px 18px;
  box-sizing: border-box;
}

/* --- Top Header / Toolbar --- */
.yaml-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.yaml-toolbar-left,
.yaml-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.yaml-toolbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05em;
  font-weight: 700;
  color: var(--text-color);
  margin-right: 8px;
}

.yaml-badge {
  font-size: 0.72em;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.yaml-badge-purple {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.yaml-preset-select {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-color);
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.yaml-preset-select:focus {
  border-color: var(--accent-color);
}

.yaml-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82em;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-color);
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
}

.yaml-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

.yaml-btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.35);
}

.yaml-btn-primary:hover {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #ffffff;
}

.yaml-btn-accent {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  border-color: rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .yaml-btn-accent {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.3);
}

.yaml-btn-success {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .yaml-btn-success {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

/* View Mode Switcher Segmented Control */
.yaml-view-segmented {
  display: inline-flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
}

.yaml-view-btn {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-color);
  opacity: 0.75;
  cursor: pointer;
  transition: all 0.15s;
}

.yaml-view-btn.active {
  background: var(--bg-primary);
  color: var(--accent-color);
  opacity: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- Main Split Workspace --- */
.yaml-workspace {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
  flex: 1;
  min-height: 0; /* Important for inner scrolling */
  overflow: hidden;
}

.yaml-workspace.view-visual-only {
  grid-template-columns: 1fr;
}
.yaml-workspace.view-visual-only .yaml-code-pane {
  display: none;
}

.yaml-workspace.view-code-only {
  grid-template-columns: 1fr;
}
.yaml-workspace.view-code-only .yaml-visual-pane {
  display: none;
}

@media (max-width: 1024px) {
  .yaml-workspace {
    grid-template-columns: 1fr;
    height: auto;
  }
}

/* --- Visual Tree Pane (Left) --- */
.yaml-visual-pane {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.yaml-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  gap: 8px;
  flex-wrap: wrap;
}

.yaml-search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

.yaml-search-input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 0.82em;
  background: var(--bg-primary);
  color: var(--text-color);
  outline: none;
}

.yaml-search-input:focus {
  border-color: var(--accent-color);
}

.yaml-search-icon {
  position: absolute;
  left: 9px;
  font-size: 0.85em;
  opacity: 0.6;
  pointer-events: none;
}

.yaml-tree-canvas {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px 40px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- Tree Nodes & Cards --- */
.yaml-node {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: background-color 0.15s;
}

.yaml-node-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  transition: all 0.15s ease;
}

.yaml-node-card:hover {
  border-color: rgba(139, 92, 246, 0.4);
}

.yaml-node-card.focused {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.yaml-node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.yaml-node-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.yaml-collapse-btn {
  background: none;
  border: none;
  color: var(--text-color);
  opacity: 0.7;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.85em;
  line-height: 1;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.yaml-collapse-btn:hover {
  opacity: 1;
  background: var(--bg-hover);
}

.yaml-key-input {
  font-family: monospace;
  font-size: 0.85em;
  font-weight: 700;
  color: var(--text-color);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  outline: none;
  max-width: 220px;
}

.yaml-key-input:hover {
  border-color: var(--border-color);
  background: var(--bg-primary);
}

.yaml-key-input:focus {
  border-color: var(--accent-color);
  background: var(--bg-primary);
}

.yaml-type-pill {
  font-size: 0.7em;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  user-select: none;
}

.yaml-type-object {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}
.yaml-type-array {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}
.yaml-type-string {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}
.yaml-type-number {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}
.yaml-type-boolean {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
}

.yaml-node-meta {
  font-size: 0.75em;
  color: var(--text-light);
  font-family: monospace;
}

.yaml-node-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.yaml-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.8em;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.65;
  transition: all 0.15s;
}

.yaml-icon-btn:hover {
  opacity: 1;
  background: var(--bg-hover);
  border-color: var(--border-color);
}

.yaml-icon-btn-danger:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Value Inputs */
.yaml-val-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.yaml-val-input {
  flex: 1;
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-color);
  font-size: 0.85em;
  outline: none;
  font-family: inherit;
}

.yaml-val-input:focus {
  border-color: var(--accent-color);
}

.yaml-val-textarea {
  flex: 1;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.84em;
  line-height: 1.45;
  resize: vertical;
  min-height: 60px;
  outline: none;
}

.yaml-val-textarea:focus {
  border-color: var(--accent-color);
}

.yaml-val-textarea.monospace-text {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8em;
}

/* Boolean Toggle */
.yaml-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82em;
  font-weight: 600;
  user-select: none;
}

.yaml-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.yaml-slider {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  background-color: var(--border-color);
  border-radius: 20px;
  transition: 0.2s;
}

.yaml-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s;
}

.yaml-switch input:checked + .yaml-slider {
  background-color: #10b981;
}

.yaml-switch input:checked + .yaml-slider:before {
  transform: translateX(18px);
}

/* Subtree / Children Indentation */
.yaml-subtree {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 2px solid rgba(139, 92, 246, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.yaml-subtree.collapsed {
  display: none;
}

/* Add Child Row Bar */
.yaml-add-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.yaml-add-btn {
  font-size: 0.78em;
  padding: 4px 8px;
  background: var(--bg-hover);
  border: 1px dashed var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.75;
  transition: all 0.15s;
}

.yaml-add-btn:hover {
  opacity: 1;
  border-color: var(--accent-color);
  background: var(--bg-secondary);
  color: var(--accent-color);
}

/* --- Code Editor Pane (Right) --- */
.yaml-code-pane {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.yaml-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-size: 0.85em;
  font-weight: 600;
}

.yaml-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8em;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.yaml-status-valid {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.yaml-status-error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.yaml-error-banner {
  background: rgba(239, 68, 68, 0.1);
  border-bottom: 1px solid rgba(239, 68, 68, 0.25);
  color: #dc2626;
  padding: 8px 14px;
  font-size: 0.8em;
  font-family: monospace;
  display: none;
  align-items: center;
  justify-content: space-between;
  line-height: 1.4;
}

[data-theme="dark"] .yaml-error-banner {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.2);
}

.yaml-editor-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.yaml-line-numbers {
  width: 44px;
  padding: 12px 6px;
  text-align: right;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.82em;
  line-height: 1.5;
  color: var(--text-light);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  user-select: none;
  overflow: hidden;
  box-sizing: border-box;
}

.yaml-code-textarea {
  flex: 1;
  padding: 12px 14px;
  border: none;
  outline: none;
  resize: none;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.82em;
  line-height: 1.5;
  background: var(--bg-primary);
  color: var(--text-color);
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  box-sizing: border-box;
}

.yaml-code-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-size: 0.78em;
  color: var(--text-light);
}

/* Toast notification */
.yaml-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.85em;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 99999;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.yaml-toast.show {
  transform: translateY(0);
  opacity: 1;
}
