:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.studio-shell {
  background: #121212;
}

.studio-mobile-bar {
  background: #171717;
}

.studio-sidebar {
  background: #1b1b1b;
}

.studio-surface {
  background: #1f1f1f;
}

.studio-card {
  border: 1px solid #242424;
  background: #1f1f1f;
}

.studio-action-button {
  border: 1px solid rgb(255 255 255 / 0.1);
  background: #141414;
  color: #f4f4f5;
}

.studio-action-button:hover,
.studio-action-button:focus-visible {
  border-color: rgb(255 255 255 / 0.2);
  background: #242424;
  color: #f4f4f5;
}

.studio-beta-label {
  border-radius: 9999px;
  border: 1px solid rgb(196 181 253 / 0.2);
  background: rgb(167 139 250 / 0.1);
  padding: 0.125rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #ddd6fe;
}

/* Mentorship close: i9flow mint + navy, only on /mentoria CTAs. */
.mentorship-cta {
  border: 0;
  background: #c1d7c8;
  color: #1a1f32;
}

.mentorship-cta:hover,
.mentorship-cta:focus-visible {
  border: 0;
  background: #6f9e88;
  color: #1a1f32;
}

#mentorship-page .studio-card {
  background: #252525;
  border-color: #3a3a3a;
}

.studio-hover:hover {
  background: #242424;
  color: inherit;
}

.studio-hover-soft:hover {
  background: #1f1f1f;
  color: inherit;
}

.pricing-recommended {
  border-color: rgb(255 255 255 / 0.28);
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.25);
}

#app-sidebar[data-collapsed="true"] .sidebar-expanded-only {
  display: none;
}

#app-sidebar:not([data-collapsed="true"]) .sidebar-collapsed-only {
  display: none;
}

#app-sidebar[data-collapsed="true"] .sidebar-collapsed-only {
  display: block;
}

#app-sidebar[data-collapsed="true"] .menu button {
  justify-content: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

#sidebar-collapse-toggle {
  left: calc(18rem - 0.75rem);
}

#sidebar-collapse-toggle[data-collapsed="true"] {
  left: calc(4rem - 0.75rem);
}

#sidebar-collapse-toggle[data-collapsed="true"] svg {
  transform: rotate(180deg);
}

.studio-stage-touch-order,
.studio-sidebar-flow-move {
  display: none;
}

.studio-shell :is(
  [data-raci-verify],
  [data-policies-verify],
  [data-metrics-verify],
  [data-cadences-verify],
  [data-agentic-verify],
  [data-stage-detail-verify]
):disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

/* Keep the same table DOM and action bindings; narrow screens reflow rows into
   cards. Labels remain beside their values and desktop markup is unchanged. */
@media (max-width: 767px) {
  .studio-shell .studio-structure-table,
  .studio-shell .studio-structure-table tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .studio-shell .studio-structure-table :is(colgroup, thead) {
    display: none;
  }

  .studio-shell .studio-structure-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    padding: 1rem;
  }

  .studio-shell .studio-structure-table td {
    display: block;
    min-width: 0;
    padding: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }

  .studio-shell [data-flow-stages] td:nth-child(-n+3),
  .studio-shell [data-flow-stages] td:last-child {
    grid-column: 1 / -1;
  }

  .studio-shell [data-flow-areas] tbody tr {
    grid-template-columns: 1.25rem minmax(0, 1fr);
    align-items: center;
    column-gap: 0.5rem;
  }

  .studio-shell [data-flow-areas] td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .studio-shell [data-flow-areas] td:nth-child(1) span {
    margin: 0;
  }

  .studio-shell [data-flow-areas] td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
  }

  .studio-shell [data-flow-areas] td:nth-child(3),
  .studio-shell [data-flow-areas] td:nth-child(4) {
    grid-column: 1 / -1;
  }

  .studio-shell [data-workspace-areas] td:nth-child(1),
  .studio-shell [data-workspace-areas] td:last-child,
  .studio-shell [data-area-flows] td {
    grid-column: 1 / -1;
  }

  .studio-shell :is([data-workspace-areas], [data-area-flows]) td:is([data-mobile-label]) {
    text-align: left;
  }

  .studio-shell [data-area-edit] {
    display: flex;
    min-height: 44px;
    min-width: 0;
    align-items: center;
    font-size: 1rem;
  }

  .studio-shell [data-mobile-label]::before {
    content: attr(data-mobile-label);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    color: #a1a1aa;
  }

  .studio-shell [data-stage-edit] {
    width: 100%;
    min-height: 44px;
    font-size: 1rem;
  }

  .studio-shell [data-stage-drag-handle] {
    display: none;
  }

  .studio-shell .studio-stage-touch-order {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.5rem;
  }

  .studio-stage-touch-order > span {
    flex: 1;
    color: #a1a1aa;
  }

  .studio-shell .studio-structure-table button {
    min-height: 44px;
    min-width: 44px;
  }

  .studio-shell [data-stage-detail]::after {
    content: "Abrir detalhe";
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .studio-shell .studio-structure-table {
    min-width: 900px;
  }

  .studio-shell #flow-areas {
    overflow-x: auto;
  }
}

/* Private mobile shell: contain intrinsic grid widths rather than clipping the page.
   Desktop layout remains owned by its existing utilities. */
@media (max-width: 1023px) {
  html.studio-drawer-open {
    overflow: hidden;
  }

  .studio-shell .drawer-content,
  .studio-shell .drawer-content .grid > *,
  #workspace-workbench > * {
    min-width: 0;
  }

  .studio-shell .drawer-side {
    z-index: 40;
  }

  .studio-shell #app-sidebar {
    width: min(20rem, calc(100vw - 2rem));
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .studio-shell #app-sidebar :is(nav, .menu) button,
  .studio-shell #app-sidebar a,
  .studio-shell #workspace-object-list [data-folder-toggle] {
    min-height: 44px;
  }

  .studio-shell .studio-sidebar-flow-row {
    display: flex;
    min-width: 0;
    align-items: center;
  }

  .studio-shell .studio-sidebar-flow-row a {
    min-width: 0;
  }

  .studio-shell .studio-sidebar-flow-move:not([hidden]) {
    display: inline-flex;
    min-width: 44px;
    flex-shrink: 0;
  }

  .studio-shell #workspace-object-list .group {
    height: auto;
    min-height: 44px;
  }

  .studio-shell #workspace-object-list .dropdown > button {
    opacity: 1;
    min-width: 44px;
    min-height: 44px;
  }

  .studio-shell #app-sidebar .dropdown-content {
    max-width: calc(100vw - 4rem);
  }

  .studio-shell [data-intake-page] > p {
    white-space: normal;
  }
}

@media (max-width: 767px) {
  .studio-shell .drawer-content :is(main, header, section, div).px-8,
  .studio-shell .drawer-content main.px-6 {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .studio-shell [data-intake-page] > p {
    white-space: normal;
  }

  .studio-shell [data-intake-page] {
    margin-top: 2rem;
  }

  .studio-shell :is(input, select, textarea) {
    min-width: 0;
    max-width: 100%;
    font-size: 16px;
  }

  .studio-shell .btn,
  .studio-shell [data-flow-tab],
  .studio-shell [data-flow-structure-tab],
  .studio-shell [data-governance-tab] {
    min-height: 44px;
  }

  .studio-shell .studio-segmented-4 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    border-radius: 1rem;
  }

  .studio-shell .studio-segmented-4 [data-governance-tab] {
    width: 100%;
    text-align: center;
  }

  .studio-shell .btn:is(.btn-circle, .btn-square) {
    min-width: 44px;
  }

  .studio-shell dialog.modal:not([open]) {
    display: none;
  }

  .studio-shell .modal-box,
  .stage-detail-modal,
  .studio-shell [data-raci-editor-panel],
  .studio-shell [data-policy-editor-panel],
  .studio-shell [data-metric-editor-panel],
  .studio-shell [data-cadence-editor-panel],
  .studio-shell [data-stage-detail-editor-panel],
  .studio-shell [data-stage-detail-process-editor-panel] {
    max-width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-wrap: anywhere;
  }

  .studio-shell .modal-action {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .studio-shell .modal-box :is(h2, h3) {
    padding-right: 2rem;
  }

  .studio-shell .drawer-content :is(h1, h2, h3, h4, p) {
    overflow-wrap: anywhere;
  }

  .studio-shell .studio-stage-diagram-controls {
    flex-wrap: wrap;
  }

  .studio-shell [data-flow-diagram-controls] {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 55%;
  }

  .studio-shell #workspace-workbench h3,
  .studio-shell #flow-catalog-grid h3 {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* Stage detail: wide legacy modal support + full-width BPMN board.
   Kept in CSS (not Tailwind utilities) because this layout is critical and
   must not depend on runtime JIT class generation. */
.stage-detail-modal {
  width: 95vw;
  max-width: 95vw;
}

.stage-detail-board {
  display: block;
  width: 100%;
  height: 560px;
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #f4f4f5;
}

.stage-detail-board [data-stage-detail-bpmn-viewer] {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 32px;
  background: transparent;
}

@media (max-width: 640px) {
  .stage-detail-board [data-stage-detail-bpmn-viewer] {
    padding: 20px;
  }
}

/* Stage provocations share the layout with the diagram; never cover it. */
.studio-stage-detail-layout,
.studio-flow-insights-layout {
  display: flex;
  min-width: 0;
}

.studio-stage-detail-layout > main,
.studio-flow-insights-layout > main {
  flex: 1 1 0;
  min-width: 0;
}

.studio-provocations-panel:not(.hidden) {
  position: sticky;
  top: 0;
  align-self: flex-start;
  flex: 0 0 14rem;
  min-width: 0;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 1023px) {
  .studio-stage-detail-layout,
  .studio-flow-insights-layout {
    flex-direction: column;
  }

  .studio-provocations-panel:not(.hidden) {
    position: static;
    order: -1;
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    max-height: 60dvh;
  }
}

#flow-stages tr[data-stage-revealed] {
  background: rgb(255 255 255 / 0.08);
}

/* Intake correction: keep the composer in the middle of the viewport, not under the transcript. */
[data-intake-adjusting] {
  padding-bottom: 40vh;
}

[data-intake-adjusting] #new-flow-page-form {
  position: sticky;
  top: 28vh;
  z-index: 2;
  scroll-margin-top: 6rem;
}

/* Value-stream map: pan the board, click a stage. Override diagram-js `move`. */
[data-flow-diagram-canvas] .bjs-container,
[data-flow-diagram-canvas] .djs-hit-stroke,
[data-flow-diagram-canvas] .djs-hit-click-stroke,
[data-flow-diagram-canvas] .djs-hit-all {
  cursor: grab;
}

[data-flow-diagram-canvas] .bjs-container:active,
[data-flow-diagram-canvas] .djs-hit-stroke:active,
[data-flow-diagram-canvas] .djs-hit-click-stroke:active,
[data-flow-diagram-canvas] .djs-hit-all:active {
  cursor: grabbing;
}

[data-flow-diagram-canvas] .vsm-stage-task,
[data-flow-diagram-canvas] .vsm-stage-task .djs-hit-stroke,
[data-flow-diagram-canvas] .vsm-stage-task .djs-hit-click-stroke,
[data-flow-diagram-canvas] .vsm-stage-task .djs-hit-all {
  cursor: pointer;
}
