/* =============================================================================
   motigroup-control-engine.css
   =============================================================================
   MotiGroup Control Engine UI — rebuilt on top of the shared design tokens
   (css/design-tokens.css) instead of hardcoded colors, so this tab actually
   matches the rest of the panel (light/dark theme both work, spacing/radius
   match every other card) rather than looking like a separate raw HTML form
   bolted on the side.
   ========================================================================= */

.mge-subtitle {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin: -6px 0 var(--space-5);
  max-width: 620px;
}

/* ---- Sub-view segmented toggle ---- */
.mge-subview-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-6);
}
.mge-toggle-btn {
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition-base);
}
.mge-toggle-btn:hover {
  color: var(--color-text-primary);
}
.mge-toggle-btn.mge-toggle-active {
  background: var(--color-accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ---- Panel cards (GitHub Account / Repo Config / Grants / Edit CMS) ---- */
.mge-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  overflow: hidden;
}
.mge-panel-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
}
.mge-panel-icon {
  font-size: 20px;
  line-height: 1;
  flex: 0 0 auto;
}
.mge-panel-title {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
}
.mge-panel-desc {
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  margin-top: 2px;
}
.mge-panel-body {
  padding: var(--space-5);
}

.mge-field-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.mge-input-w260 { max-width: 260px; margin-bottom: 0 !important; }
.mge-input-w120 { max-width: 120px; margin-bottom: 0 !important; }
.mge-input-grow { flex: 1 1 220px; min-width: 180px; margin-bottom: 0 !important; }
.mge-inline-result {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* ---- Empty states ---- */
.mge-empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  color: var(--color-text-secondary);
}
.mge-empty-state-compact {
  padding: var(--space-5);
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
}
.mge-empty-icon {
  font-size: 32px;
  margin-bottom: var(--space-2);
}
.mge-empty-title {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: 4px;
}
.mge-empty-text {
  font-size: var(--font-size-sm);
  max-width: 480px;
  margin: 0 auto;
}
.mge-empty-state-compact .mge-empty-text { margin: 0; }

/* ---- Linked GitHub account row ---- */
.mge-github-linked-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.mge-github-avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.mge-github-info { flex: 1 1 auto; min-width: 160px; }
.mge-github-username {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  font-size: var(--font-size-md);
}
.mge-github-email {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}
.mge-hint { opacity: 0.75; }
.mge-github-actions {
  display: flex;
  gap: var(--space-2);
  flex: 0 0 auto;
}

.mge-note {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin: 6px 0;
}
.mge-note-warn {
  color: var(--color-warning);
  font-weight: var(--font-weight-semibold);
}

.mge-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}
.mge-badge-good {
  background: var(--color-success-bg);
  color: var(--color-success);
}
.mge-badge-bad {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.mge-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
.mge-table th,
.mge-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}
.mge-table th {
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.mge-table tr:last-child td { border-bottom: none; }

.mge-diff-pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  max-height: 320px;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
}
.mge-diff-add {
  background: rgba(34, 197, 94, 0.25);
  color: #86efac;
}
.mge-diff-del {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  text-decoration: line-through;
}

/* ---- Full-screen Monaco editor overlay ---- */
.mge-editor-overlay {
  position: fixed;
  inset: 0;
  background: #1e1e1e;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  box-shadow: var(--shadow-lg);
}
.mge-editor-overlay.mge-editor-maximized {
  width: 100% !important;
  height: 100% !important;
  top: 0 !important;
  left: 0 !important;
}
.mge-editor-overlay.mge-editor-minimized {
  height: 44px;
  overflow: hidden;
}
.mge-editor-titlebar {
  height: 44px;
  flex: 0 0 44px;
  background: #252526;
  color: #d4d4d4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 13px;
  font-family: "SFMono-Regular", Consolas, monospace;
  cursor: default;
  border-bottom: 1px solid #333;
}
.mge-editor-titlebar #mgeEditorFileLabel {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}
.mge-editor-titlebar > div {
  flex: 0 0 auto;
  display: flex;
}
.mge-editor-titlebar .btn {
  padding: 5px 11px;
  margin-left: 4px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.mge-monaco-container {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
}
.mge-resize-handle {
  position: absolute;
  z-index: 10000;
  background: transparent;
}
.mge-resize-top {
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
}
.mge-resize-left {
  top: 0;
  bottom: 0;
  left: 0;
  width: 6px;
  cursor: ew-resize;
}

/* ---- §7 file-tree explorer ---- */
.mge-tree-layout {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  margin-top: var(--space-4);
}
.mge-file-tree-panel {
  flex: 0 0 250px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface-alt);
}
.mge-file-tree-panel-header {
  padding: 8px 12px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--color-border);
}
.mge-file-tree {
  max-height: 340px;
  overflow: auto;
  padding: 8px;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
}
.mge-editor-side {
  flex: 1;
  min-width: 0;
}
.mge-file-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 16px;
}
.mge-file-tree > ul.mge-tree-root {
  padding-left: 0;
}
.mge-tree-folder.mge-tree-collapsed > ul {
  display: none;
}
.mge-tree-label,
.mge-tree-file {
  display: block;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}
.mge-tree-label:hover,
.mge-tree-file:hover {
  background: var(--color-border);
}
.mge-tree-file.mge-tree-selected {
  background: var(--color-accent);
  color: #fff;
  font-weight: var(--font-weight-semibold);
}

@media (max-width: 720px) {
  .mge-tree-layout {
    flex-direction: column;
  }
  .mge-file-tree-panel {
    flex: 0 0 auto;
    width: 100%;
  }
  .mge-file-tree {
    max-height: 220px;
  }
  .mge-github-actions {
    width: 100%;
  }

  /* ---- full-screen Monaco editor overlay on mobile ---- */
  .mge-field-row {
    flex-direction: column;
    align-items: stretch;
  }
  .mge-field-row .btn {
    width: 100%;
  }
  .mge-input-grow {
    min-width: 0;
  }
  .mge-editor-titlebar {
    padding: 0 8px;
    font-size: 12px;
  }
  .mge-editor-titlebar .btn {
    padding: 6px 9px;
    margin-left: 3px;
    font-size: 13px;
    /* keep touch targets usable even with the tighter mobile padding */
    min-width: 32px;
  }
  /* drag-resize is a desktop mouse interaction; the overlay is already
     full-screen on mobile so these handles would just sit in the way
     of touch-scrolling the editor. */
  .mge-resize-handle {
    display: none;
  }
  /* mgeInitEditorResize's drag handlers set inline width/height on the
     overlay (desktop mouse-drag resize) — with the handles hidden above
     those never get set from a touch session, but guard the non-minimized
     case anyway so the editor always fills the viewport on mobile. */
  .mge-editor-overlay:not(.mge-editor-minimized) {
    width: 100% !important;
    height: 100% !important;
  }
}