/* Modelos físicos — wizard do modelo, árvore do gaveteiro composto e cadastro de máquina a partir da
   revisão (docs/machine-models-refactoring-plan.md §10). Vive dentro dos dialogs de .shared-drawer-dialog
   e reaproveita a linguagem visual de shared-drawers.css. Global de propósito: o MudDialog recebe a
   classe pelo parâmetro Class e o CSS isolado não alcança elementos de componentes MudBlazor. */

/* ---------- Cartões de escolha (natureza, construção) ---------- */

.machine-model-construction-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.machine-model-construction-cards--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.machine-model-construction-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 14px;
    border: 1px solid var(--tm-border);
    border-radius: 12px;
    background: var(--tm-surface);
    color: var(--tm-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.machine-model-construction-card:hover:not(:disabled) {
    border-color: var(--tm-secondary);
}

.machine-model-construction-card:focus-visible {
    outline: 2px solid var(--tm-primary);
    outline-offset: 1px;
}

.machine-model-construction-card--selected {
    border-color: var(--tm-primary);
    background-color: var(--tm-primary-tint);
}

.machine-model-construction-card:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.machine-model-construction-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 14px;
}

.machine-model-construction-hint {
    font-size: 13px;
    color: var(--tm-text-muted);
}

.machine-model-todo {
    padding: 0 6px;
    border: 1px solid var(--tm-border);
    border-radius: 6px;
    font-family: var(--font-tech);
    font-size: 11px;
    font-weight: 700;
    color: var(--tm-text-muted);
}

.machine-model-inline-action {
    display: flex;
    align-items: center;
}

.machine-model-error-list {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 13px;
}

.machine-model-review-facts {
    margin-bottom: 12px;
}

.machine-model-review-facts dd {
    text-align: left;
}

/* Coluna "Ordem de abertura": trancas numa linha sem quebra (até cinco). */
.machine-model-route {
    display: block;
    white-space: nowrap;
}

/* ---------- Árvore do gaveteiro composto ---------- */

.machine-model-tree-editor {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.machine-model-pane-switch {
    display: none;
    gap: 8px;
    grid-column: 1 / -1;
}

.machine-model-tree-pane,
.machine-model-props-pane {
    min-width: 0;
}

.machine-model-props-pane {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.machine-model-tree-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.machine-model-tree,
.machine-model-tree ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.machine-model-tree ul {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
    padding-left: 14px;
    border-left: 1px dashed var(--tm-border);
}

.machine-model-tree-root-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tm-text-muted);
}

.machine-model-tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--tm-border);
    border-radius: 10px;
    background: var(--tm-surface);
    color: var(--tm-text);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.machine-model-tree-item > span:first-of-type {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.machine-model-tree-item:hover {
    border-color: var(--tm-secondary);
}

.machine-model-tree-item:focus-visible {
    outline: 2px solid var(--tm-primary);
    outline-offset: 1px;
}

.machine-model-tree-item--selected {
    border-color: var(--tm-primary);
    background-color: var(--tm-primary-tint);
    font-weight: 600;
}

/* Linha da árvore: botão de recolher + item. Profundidade 5 não alarga o dialog: o recuo é fixo e pequeno
   e o rótulo corta com reticências. */
.machine-model-tree-row {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.machine-model-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--tm-text-muted);
    cursor: pointer;
}

.machine-model-tree-toggle:focus-visible {
    outline: 2px solid var(--tm-primary);
}

.machine-model-tree-toggle-spacer {
    flex: 0 0 22px;
}

.machine-model-tree ul ul {
    padding-left: 10px;
}

.machine-model-tree-item {
    min-width: 0;
}

.machine-model-tree-item--pending {
    border-style: dashed;
}

.machine-model-node-facts,
.machine-model-node-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.machine-model-replication-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border: 1px solid var(--tm-border);
    border-radius: 10px;
    background: var(--tm-secondary-tint);
}

.machine-model-tree-empty.mud-typography {
    display: block;
    margin: 4px 0 0 14px;
    color: var(--tm-warning);
}

/* ---------- Gaveteiro rotativo ---------- */

.machine-model-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.rotary-editor-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 160px) minmax(0, 220px) auto;
    gap: 12px;
    align-items: start;
    margin-bottom: 12px;
}

.rotary-apply-all {
    margin-top: 8px;
    justify-self: start;
}

.rotary-floor-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Linha do andar: ordem · andar · tranca · posições · abertura · planta. */
.rotary-floor-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 120px) minmax(0, 120px) auto;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid var(--tm-border);
    border-radius: 10px;
    background: var(--tm-surface);
}

.rotary-floor-row--selected {
    border-color: var(--tm-primary);
    background: var(--tm-primary-tint);
}

.rotary-floor-ordinal {
    font-weight: 700;
    color: var(--tm-text-muted);
}

.rotary-floor-span {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--tm-text-muted);
}

/* Planta + tabela lado a lado; empilham no estreito. */
.rotary-floor-view {
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.rotary-plan-svg {
    display: block;
    width: 100%;
    max-width: 300px;
    height: auto;
}

.rotary-sector {
    fill: var(--tm-secondary-tint);
    stroke: var(--tm-surface);
    stroke-width: 1;
    cursor: pointer;
}

circle.rotary-sector {
    stroke: var(--tm-secondary-tint);
}

.rotary-sector:hover {
    fill: var(--tm-primary-tint);
}

.rotary-sector--selected,
.rotary-sector--selected:hover {
    fill: var(--tm-primary);
}

circle.rotary-sector--selected {
    stroke: var(--tm-primary);
}

.rotary-sector-number {
    font-size: 9px;
    fill: var(--tm-text);
    pointer-events: none;
}

.rotary-target-line {
    stroke: var(--tm-primary);
    stroke-width: 1.5;
    stroke-dasharray: 3 3;
}

.rotary-target-dot {
    fill: var(--tm-primary);
}

.rotary-window {
    fill: var(--tm-secondary);
}

.rotary-center-label {
    font-size: 12px;
    font-weight: 700;
    fill: var(--tm-text);
}

.rotary-plan-legend {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--tm-text-muted);
}

.rotary-legend-window {
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: 6px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 8px solid var(--tm-secondary);
}

/* Muitos setores: a tabela rola dentro do dialog, a página não. */
.rotary-table-wrap {
    max-height: 360px;
    overflow: auto;
    min-width: 0;
}

.rotary-row--selected td {
    background: var(--tm-primary-tint);
}

.rotary-row-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--tm-primary);
    font: inherit;
    font-family: var(--mud-typography-default-family, inherit);
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.rotary-row-button:focus-visible {
    outline: 2px solid var(--tm-primary);
    outline-offset: 2px;
}

.rotary-floor-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.rotary-floor-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 12px;
    border: 1px solid var(--tm-border);
    border-radius: 10px;
    background: var(--tm-surface);
    color: var(--tm-text);
    font: inherit;
    cursor: pointer;
}

.rotary-floor-chip--selected {
    border-color: var(--tm-primary);
    background: var(--tm-primary-tint);
}

.rotary-floor-chip:focus-visible {
    outline: 2px solid var(--tm-primary);
}

.rotary-floor-chip-meta {
    font-size: 12px;
    color: var(--tm-text-muted);
}

/* ---------- Estreito ---------- */

@media (max-width: 959px) {
    .machine-model-construction-cards {
        grid-template-columns: minmax(0, 1fr);
    }

    .machine-model-tree-editor {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Celular/tablet: árvore e propriedades alternam dentro do mesmo dialog. */
    .machine-model-pane-switch {
        display: flex;
    }

    .machine-model-tree-editor--tree .machine-model-props-pane,
    .machine-model-tree-editor--props .machine-model-tree-pane {
        display: none;
    }

    .rotary-editor-toolbar,
    .rotary-floor-view {
        grid-template-columns: minmax(0, 1fr);
    }

    .rotary-plan-svg {
        margin: 0 auto;
    }

    /* Andar em duas linhas: identificações em cima, posições/abertura/planta embaixo. */
    .rotary-floor-row {
        grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1fr);
    }

    .rotary-floor-row > :nth-child(4) {
        grid-column: 2;
    }
}
