/* Plantas simuladas: janela flutuante e elementos das vistas.
   Todas as classes levam o prefixo "plant-". */

.plant-win {
  position: fixed; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 12px 36px rgba(15, 23, 42, .22), var(--shadow);
  overflow: hidden; min-width: 320px; min-height: 220px;
  color: var(--text); font-size: .85rem;
}
body.plant-dragging { user-select: none; cursor: grabbing; }
body.plant-dragging .plant-win { transition: none; }

.plant-head {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 7px 8px 7px 12px; cursor: grab; user-select: none;
  background: var(--blue-soft); border-bottom: 1px solid var(--border);
}
.plant-head:active { cursor: grabbing; }
.plant-icon { font-size: 1.15rem; line-height: 1; }
.plant-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plant-spacer { flex: 1; }

.plant-status {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font-size: .72rem; color: var(--muted); padding: 2px 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
}
.plant-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.plant-status.is-running .plant-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(22, 163, 74, .2); }
.plant-status.is-paused .plant-dot { background: var(--amber); }
.plant-status.is-stopped .plant-dot { background: #94a3b8; }

.plant-btn {
  border: 1px solid transparent; background: transparent; color: var(--text);
  padding: 4px 9px; border-radius: 7px; font-size: .78rem; cursor: pointer; flex: none;
}
.plant-btn:hover { background: var(--card); border-color: var(--border); }
.plant-btn.active { background: var(--card); border-color: var(--blue); color: var(--blue); }
.plant-btn-icon { font-size: .95rem; padding: 3px 8px; }
.plant-btn-close:hover { background: var(--red); border-color: var(--red); color: #fff; }

.plant-main { flex: 1; min-height: 0; display: flex; }
.plant-body { flex: 1; min-width: 0; min-height: 0; background: #f1f5f9; display: flex; }
.plant-body .plant-svg { display: block; width: 100%; height: 100%; user-select: none; touch-action: none; }
.plant-missing { align-items: center; justify-content: center; color: var(--muted); padding: 20px; }

.plant-svg-label { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 700; letter-spacing: .04em; }
.plant-svg-lcd { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-weight: 700; }
.plant-svg-btn { cursor: pointer; }
.plant-svg-btn:active circle:nth-of-type(2) { transform: scale(.94); transform-box: fill-box; transform-origin: center; }
.plant-slider-wrap { width: 80px; height: 190px; display: flex; align-items: center; justify-content: center; }
.plant-slider {
  writing-mode: vertical-lr; direction: rtl; width: 28px; height: 180px; cursor: pointer;
  accent-color: var(--blue);
}

/* painel de ligações */
.plant-wiring {
  flex: none; width: 250px; overflow-y: auto; padding: 10px;
  background: var(--card); border-left: 1px solid var(--border);
}
.plant-wiring-title { font-weight: 700; margin-bottom: 6px; }
.plant-wiring-group {
  margin: 10px 0 4px; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.plant-wire { margin-bottom: 8px; }
.plant-wire-top { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; font-size: .78rem; }
.plant-wire-val { min-width: 38px; text-align: right; font-family: ui-monospace, Menlo, monospace; color: var(--blue); font-weight: 700; }
.plant-select {
  width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text); font-size: .78rem;
}
.plant-select:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
.plant-select.missing { border-color: var(--amber); }

.plant-led {
  display: inline-block; width: 10px; height: 10px; flex: none; border-radius: 50%;
  background: #cbd5e1; border: 1px solid rgba(15, 23, 42, .25);
}
.plant-led.on { background: var(--green); box-shadow: 0 0 6px var(--green); border-color: var(--green); }

/* rodapé com a E/S */
.plant-foot {
  flex: none; display: flex; flex-wrap: wrap; gap: 4px 6px; padding: 6px 28px 6px 8px;
  border-top: 1px solid var(--border); background: var(--card); max-height: 74px; overflow: auto;
}
.plant-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px 1px 6px;
  border: 1px solid var(--border); border-radius: 999px; font-size: .7rem; color: var(--muted);
  background: var(--bg, #f8fafc); white-space: nowrap;
}
.plant-chip.on { color: var(--text); border-color: #bbf7d0; background: var(--green-soft, #f0fdf4); }
.plant-chip.missing { border-style: dashed; }
.plant-chip small { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: .66rem; }
.plant-chip b { font-family: ui-monospace, Menlo, monospace; color: var(--blue); }

.plant-resize {
  position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; touch-action: none;
  background:
    linear-gradient(135deg, transparent 0 55%, #94a3b8 55% 60%, transparent 60% 70%, #94a3b8 70% 75%, transparent 75% 85%, #94a3b8 85% 90%, transparent 90%);
}

/* aviso: duas fontes escrevendo na mesma entrada do CLP */
.plant-conflict {
  margin-top: 4px; font-size: .7rem; line-height: 1.3; color: #b45309;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 3px 6px;
}

/* painel "ℹ Processo": descrição da planta */
.plant-guide { width: 330px; font-size: .78rem; line-height: 1.5; color: #334155; }
.pg-text { margin: 0 0 8px; }
.pg-goal {
  background: var(--blue-soft); border: 1px solid #cfe0ff; border-radius: 7px;
  padding: 6px 9px; color: #1e3a8a;
}
.pg-list { margin: 0; padding-left: 18px; }
.pg-list li { margin-bottom: 4px; }
.pg-faults li::marker { color: var(--red); }
.pg-tips li::marker { color: var(--amber); }
.pg-io { width: 100%; border-collapse: collapse; font-size: .74rem; }
.pg-io td { padding: 3px 4px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.pg-var { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--blue); white-space: nowrap; }
.pg-dir { font-size: .6rem; font-weight: 700; letter-spacing: .04em; padding: 1px 5px; border-radius: 4px; }
.pg-dir.in { background: #e0f2fe; color: #0369a1; }
.pg-dir.out { background: #dcfce7; color: #15803d; }
.pg-note { margin: 5px 0 0; font-size: .68rem; color: var(--muted); }
.pg-example {
  width: 100%; margin-top: 12px; padding: 7px 10px; border-radius: 7px; font-size: .78rem; font-weight: 600;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e; cursor: pointer;
}
.pg-example:hover { background: #fef3c7; }
