/* Terra AI — Assistente de Configuração SCADA (drawer lateral) */
#terraAiToggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #3d4a5d;
  background: #141b26;
  color: #9fc3ff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
#terraAiToggle:hover { border-color: #2f81f7; color: #d6e6ff; background: #1a2332; }
#terraAiToggle.active { border-color: #2f81f7; background: #16233a; }

.terra-ai-overlay {
  position: fixed; inset: 0; background: rgba(4, 8, 14, .55);
  z-index: 9000; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.terra-ai-overlay.open { opacity: 1; pointer-events: auto; }

.terra-ai-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw;
  background: #0f1620; border-left: 1px solid #2b3a4e; z-index: 9001;
  display: flex; flex-direction: column;
  transform: translateX(102%); transition: transform .22s ease;
  box-shadow: -12px 0 32px rgba(0,0,0,.45);
  font-family: "Segoe UI", system-ui, sans-serif; color: #e6edf3;
}
.terra-ai-drawer.open { transform: translateX(0); }

.terra-ai-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid #223047;
  background: linear-gradient(180deg, #132033, #0f1620);
}
.terra-ai-head .ai-logo { font-size: 20px; }
.terra-ai-head .ai-title { font-weight: 700; font-size: 14px; letter-spacing: .02em; }
.terra-ai-head .ai-sub { font-size: 11px; color: #7d8ea3; margin-top: 2px; }
.terra-ai-head .ai-close { margin-left: auto; background: none; border: none; color: #7d8ea3;
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.terra-ai-head .ai-close:hover { color: #fff; background: #1c2a3d; }
.terra-ai-head .ai-pill { font-size: 10px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid #2f81f7; color: #9fc3ff; background: #14243b; }

.terra-ai-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.terra-ai-msg { font-size: 13px; line-height: 1.55; }
.terra-ai-msg.ai { background: #16202f; border: 1px solid #223349; border-radius: 12px;
  padding: 10px 12px; align-self: flex-start; max-width: 92%; }
.terra-ai-msg.user { background: #1d3a5f; border: 1px solid #2b5587; border-radius: 12px;
  padding: 10px 12px; align-self: flex-end; max-width: 92%; }
.terra-ai-msg .who { font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: #7d8ea3; margin-bottom: 4px; }

.terra-ai-chiprow { display: flex; flex-wrap: wrap; gap: 6px; }
.terra-ai-chip { font-size: 11px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid #2b3a4e; background: #131c29; color: #b6c6d9; }
.terra-ai-chip:hover { border-color: #2f81f7; color: #d6e6ff; }

.terra-ai-card { border: 1px solid #2b3a4e; border-radius: 12px; background: #131c29; overflow: hidden; }
.terra-ai-card .card-head { padding: 10px 12px; font-size: 12px; font-weight: 700;
  border-bottom: 1px solid #223047; background: #17222f; display: flex; align-items: center; gap: 8px; }
.terra-ai-card .card-body { padding: 10px 12px; font-size: 12.5px; line-height: 1.5; }
.terra-ai-card .kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0;
  border-bottom: 1px dashed #223047; }
.terra-ai-card .kv span:first-child { color: #7d8ea3; }
.terra-ai-card .card-actions { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #223047; }

.terra-ai-btn { font-size: 12px; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid #2b3a4e; background: #1a2534; color: #d6e6ff; }
.terra-ai-btn:hover { border-color: #2f81f7; }
.terra-ai-btn.primary { background: #1f6feb33; border-color: #2f81f7; color: #9fc3ff; }
.terra-ai-btn.danger { background: #f8514933; border-color: #f85149; color: #ffa198; }
.terra-ai-btn:disabled { opacity: .5; cursor: not-allowed; }

.terra-ai-status { font-size: 11px; display: flex; align-items: center; gap: 6px; }
.terra-ai-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #3fb950; }
.terra-ai-status .dot.warn { background: #d29922; }
.terra-ai-status .dot.crit { background: #f85149; }
.terra-ai-status .dot.off { background: #6e7681; }

.terra-ai-foot { border-top: 1px solid #223047; padding: 10px 12px; display: flex; gap: 8px; background: #0d141d; }
.terra-ai-foot input, .terra-ai-foot textarea {
  flex: 1; background: #131c29; border: 1px solid #2b3a4e; color: #e6edf3;
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; resize: none; outline: none;
}
.terra-ai-foot input:focus, .terra-ai-foot textarea:focus { border-color: #2f81f7; }
.terra-ai-send { background: #1f6feb; border: none; color: #fff; border-radius: 8px;
  padding: 0 14px; font-size: 13px; cursor: pointer; }
.terra-ai-send:hover { background: #2f81f7; }

.terra-ai-ok { color: #3fb950; } .terra-ai-warn { color: #d29922; } .terra-ai-fail { color: #f85149; }
.terra-ai-muted { color: #7d8ea3; font-size: 11px; }
.terra-ai-divider { border-top: 1px dashed #223047; margin: 8px 0; }
