/* Feature: Inventário (Camada 7) — inclui o modal compartilhado de "ficha da máquina"
   (machineModal.js), que corrige o bug histórico de abrirModalMaquina duplicada.
   Mesmos valores visuais das duas versões legadas — nada foi redesenhado, só migrado de
   style="" inline / onfocus/onblur JS para classes CSS reais. */

.machine-modal-loading,
.machine-modal-error {
    text-align: center;
    padding: 30px;
}

.machine-modal-loading {
    color: #94a3b8;
}

.machine-modal-error {
    /* A versão legada usava var(--danger-color), que nunca foi definida em :root — na prática
       herdava a cor de texto padrão. Usamos aqui o mesmo vermelho já usado consistentemente em
       outros estados de erro do app (.toast.error), em vez de repetir a variável inexistente. */
    color: #ef4444;
}

.machine-spec-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.machine-spec-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px;
}

.machine-spec-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 6px;
}

.machine-spec-icon {
    color: var(--primary-orange);
    margin-right: 4px;
}

.machine-spec-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-blue);
}

.machine-modal-actions {
    text-align: right;
    margin-top: 15px;
}

.machine-edit-field-label {
    font-weight: 600;
    width: 40%;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    text-transform: capitalize;
    padding: 12px;
}

.machine-edit-field-value {
    padding: 0;
}

.machine-edit-input {
    width: 100%;
    padding: 12px;
    border: none;
    background: transparent;
    font-size: 14px;
    color: #475569;
    outline: none;
    box-sizing: border-box;
    transition: 0.2s;
}

.machine-edit-input:focus {
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--primary-orange);
}

/* Tabela de Inventário (js/features/inventario/page.js) — mesmos valores visuais que a versão
   legada, agora como classes em vez de style="" gerado por template string. */

/* O cabeçalho ordenável/filtrável virou o padrão da Central e mora em css/main.css como
   .dt-* — ver js/shared/dataTable.js. As regras .inv-* que viviam aqui foram para lá. */
.inv-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.inv-status-badge.is-free {
    color: #059669;
    background: #ecfdf5;
}

.inv-status-badge.is-assigned {
    color: var(--primary-blue);
    background: #eff6ff;
}

/* Monitor fora de uso (monitores.indisponivel) — nem livre, nem com alguém. */
.inv-status-badge.is-unavailable {
    color: #b91c1c;
    background: #fef2f2;
}

/* Categoria Diretoria: monitor numa mesa E38–E41 do Mapa. */
.inv-status-badge.is-diretoria {
    color: #7c3aed;
    background: #f5f3ff;
}

.inv-empty-state {
    text-align: center;
    padding: 30px;
    color: #94a3b8;
}

/* ---- Visão Mapa (js/features/inventario/mapa.js) ----
   A planta em SVG: paredes, sala de reunião, Diretoria e as 41 estações. Os tons seguem a planta visual
   original (paredes azul-escuras, salas em bege). */
.mapa-layout {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

.mapa-lateral {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-size: 13px;
    color: #64748b;
}

.mapa-resumo {
    font-weight: 600;
    color: #475569;
}

.mapa-atualizacao {
    margin-top: -8px;
    font-size: 12px;
    color: #64748b;
}

.mapa-legenda {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mapa-legenda > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mapa-chip {
    display: inline-block;
    width: 16px;
    height: 12px;
    border-radius: 3px;
    border: 1.5px solid #94a3b8;
    background: #fff;
}

.mapa-chip.tem-monitor {
    border-color: #059669;
    background: #ecfdf5;
}

.mapa-chip.sala {
    border-color: #1e293b;
    background: #f5ede3;
}

.mapa-planta {
    flex: 1 1 auto;
    min-width: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
}

.mapa-svg {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
}

.mapa-parede {
    stroke: #1e3a52;
    stroke-width: 3;
    stroke-linecap: round;
}

.mapa-sala {
    fill: #f5ede3;
    stroke: #1e293b;
    stroke-width: 2.5;
}

.mapa-sala-nome {
    fill: #9a6b4b;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-anchor: middle;
}

.mapa-sala-mesa {
    fill: #fff;
    stroke: #c9906b;
    stroke-width: 1.2;
}

.mapa-estacao rect {
    fill: #fff;
    stroke: #64748b;
    stroke-width: 1.6;
    transition: fill 0.15s, stroke 0.15s;
}

.mapa-estacao text {
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.mapa-codigo {
    fill: #64748b;
    font-size: 8.5px;
}

.mapa-rotulo {
    fill: #065f46;
    font-size: 9.5px;
    font-weight: 700;
}

.mapa-estacao.tem-monitor rect {
    fill: #ecfdf5;
    stroke: #059669;
}

.mapa-estacao.editavel {
    cursor: pointer;
}

.mapa-estacao.editavel:hover rect,
.mapa-estacao.editavel:focus rect {
    stroke: var(--primary-orange);
    stroke-width: 2;
}

.mapa-estacao:focus {
    outline: none;
}

/* O monitor que a busca do mapa achou: a mesa dele pulsa em laranja. */
.mapa-estacao.is-localizado rect {
    fill: #fff7ed;
    stroke: var(--primary-orange);
    stroke-width: 3;
    animation: mapa-pulso 1.2s ease-in-out infinite;
}

.mapa-estacao.is-localizado text {
    fill: #9a3412;
}

@keyframes mapa-pulso {
    50% {
        stroke-width: 5.5;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mapa-estacao.is-localizado rect {
        animation: none;
    }
}

.mapa-busca-resultado {
    font-size: 13px;
    font-weight: 600;
}

.mapa-busca-resultado.is-achou {
    color: #9a3412;
}

.mapa-busca-resultado.is-nao-achou {
    color: #b91c1c;
}

.mapa-dica {
    display: block;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.5;
}

/* No celular a coluna da direita sobe para cima da planta. */
@media (max-width: 768px) {
    .mapa-layout {
        flex-direction: column-reverse;
    }

    .mapa-lateral {
        flex-basis: auto;
    }
}

/* ---- A aba não rola; só a tabela ----
   A página inteira rolava porque .table-responsive tem altura fixa (100vh - 250px, main.css), pensada
   para abas com menos coisa em cima da tabela; aqui ainda vêm o seletor Máquinas | Monitores | Mapa
   e a linha da busca. Em vez de outro número mágico, a aba ocupa a altura do <main> e é uma coluna
   flex: cabeçalho e busca no tamanho deles, e a tabela encolhe até caber no que sobra, rolando por
   dentro. No Mapa, quem encolhe é a planta. No celular fica o rolar normal — a tabela ficaria
   espremida sob os cabeçalhos empilhados. */
@media (min-width: 769px) {
    .main-content:has(> #tab-inventario.active) {
        overflow-y: hidden;
    }

    #tab-inventario.active {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
    }

    #tab-inventario > * {
        flex: none;
    }

    /* O painel escondido leva display:none inline (page.js), que ganha deste display. */
    #tab-inventario > .inv-painel {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }

    .inv-painel > * {
        flex: none;
    }

    .inv-painel > .table-responsive {
        flex: 0 1 auto;
        min-height: 0;
        max-height: none;
    }

    .inv-painel > .mapa-layout {
        flex: 1 1 auto;
        min-height: 0;
    }

    .mapa-layout > .mapa-planta {
        display: flex;
        min-height: 0;
    }

    .mapa-layout > .mapa-planta > .mapa-svg {
        width: auto;
        height: 100%;
        max-width: 100%;
    }
}

/* ---- Ver o modelo (js/features/inventario/modelos.js) ----
   As fotos são 768x768 com fundo branco: o palco é branco também, para a foto não virar um
   quadrado solto dentro do modal. */

.modelo-viewer-box {
    max-width: 560px;
}

.modelo-viewer-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: #ffffff;
}

.modelo-viewer-foto {
    display: block;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.modelo-viewer-miniaturas {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.modelo-viewer-miniatura {
    width: 72px;
    height: 72px;
    padding: 4px;
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
    cursor: pointer;
}

.modelo-viewer-miniatura:hover {
    border-color: var(--slate-400);
}

.modelo-viewer-miniatura.is-active {
    border-color: var(--brand-600);
    box-shadow: 0 0 0 1px var(--brand-600);
}

.modelo-viewer-miniatura img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.machine-modal-actions .btn-secondary + .btn-primary {
    margin-left: 8px;
}
