/* =========================
   AI AGENT — chip + panel de chat (lenguaje visual dark del app)
========================= */

/* Botón circular, sobre el (+) (que mide 80px y vive en bottom/right ~28px),
   con 30px de gap.  Centrado horizontalmente sobre el (+): right = 28 + (80-56)/2. */
#ai-chip {
  position: fixed;
  bottom: 120px;   /* 28 (+ btn bottom) + 80 (+ btn alto) + 30 (gap) */
  right: 20px;     /* centrado sobre el (+) */
  z-index: 40;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #08231f;
  background: #19d3bf;   /* verde agua (autonomous-driving teal) */
  box-shadow: 0 6px 22px rgba(25,211,191,0.35);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
}
#ai-chip:hover { background: #2ee0cd; transform: scale(1.05); }
#ai-chip:active { transform: scale(0.96); }
#ai-chip.open { background: #12b8a6; }
#ai-chip.busy { animation: ai-pulse 1.1s ease-in-out infinite; }
@keyframes ai-pulse { 0%,100% { box-shadow: 0 6px 22px rgba(25,211,191,0.25); } 50% { box-shadow: 0 6px 30px rgba(25,211,191,0.75); } }
.ai-spark { font-size: 12px; line-height: 1; }

#ai-panel {
  position: fixed;
  bottom: 206px;   /* despejado por encima del botón de IA */
  right: 22px;
  z-index: 41;
  width: min(380px, calc(100vw - 32px));
  height: min(540px, calc(100vh - 240px));
  display: flex;
  flex-direction: column;
  background: rgba(24,24,27,0.98);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  overflow: hidden;
}
#ai-panel.hidden { display: none; }

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ai-title { font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,0.92); display: inline-flex; align-items: center; gap: 6px; }
.ai-title .ai-spark { color: rgba(120,220,160,0.95); }
.ai-head-btns { display: flex; align-items: center; gap: 8px; }
.ai-gear, .ai-close {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 15px;
}
.ai-close { font-size: 18px; }
.ai-gear:hover, .ai-close:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* Settings */
.ai-settings {
  display: flex; flex-direction: column; gap: 9px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ai-settings.hidden { display: none; }
.ai-field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 10px; color: rgba(255,255,255,0.5); letter-spacing: 0.02em;
}
.ai-field select, .ai-field input {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  padding: 6px 8px;
  outline: none;
}
.ai-field select option { background: #222; color: #fff; }
.ai-settings-save {
  align-self: flex-end;
  padding: 5px 14px;
  border-radius: 8px;
  background: rgba(34,139,76,0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}
.ai-settings-save:hover { background: rgba(28,116,63,0.96); }
.ai-settings-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.ai-settings-clear {
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  cursor: pointer;
}
.ai-settings-clear:hover { background: rgba(200,64,64,0.22); border-color: rgba(200,64,64,0.45); color: #fff; }
.ai-bubble strong { color: #e8c06a; font-weight: 600; }

/* Mensajes */
.ai-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-bubble {
  max-width: 88%;
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ai-user      { align-self: flex-end; background: rgba(34,139,76,0.28); color: #fff; border: 1px solid rgba(34,139,76,0.35); }
.ai-assistant { align-self: flex-start; background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.92); }
.ai-system    { align-self: center; background: transparent; color: rgba(255,255,255,0.45); font-size: 11.5px; text-align: center; max-width: 100%; }

.ai-tool {
  align-self: flex-start;
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(126,184,255,0.10);
  border: 1px solid rgba(126,184,255,0.20);
  font-size: 11px;
  max-width: 100%;
}
.ai-tool-name { color: rgba(150,200,255,0.95); font-weight: 600; }
.ai-tool-args { color: rgba(255,255,255,0.6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ai-confirm {
  align-self: stretch;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 12px;
}
.ai-confirm-q { color: rgba(255,255,255,0.9); margin-bottom: 3px; }
.ai-confirm-args { color: rgba(255,255,255,0.55); font-size: 11px; margin-bottom: 8px; word-wrap: break-word; }
.ai-confirm-btns { display: flex; gap: 8px; font-size: 11px; color: rgba(255,255,255,0.6); }
.ai-btn { padding: 4px 12px; border-radius: 7px; cursor: pointer; font-weight: 500; }
.ai-approve { background: rgba(34,139,76,0.9); color: #fff; }
.ai-approve:hover { background: rgba(28,116,63,0.96); }
.ai-approve-all { background: rgba(25,211,191,0.85); color: #08231f; }
.ai-approve-all:hover { background: rgba(25,211,191,1); }
.ai-reject  { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.8); }
.ai-reject:hover { background: rgba(220,80,80,0.7); color: #fff; }
.ai-confirm.ai-done { opacity: 0.7; }

/* Input */
.ai-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.ai-input-row textarea {
  flex: 1;
  resize: none;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  color: #fff;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.4;
  padding: 8px 10px;
  outline: none;
  max-height: 120px;
}
.ai-input-row textarea::placeholder { color: rgba(255,255,255,0.35); }
.ai-send {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  background: rgba(34,139,76,0.92);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.ai-send:hover { background: rgba(28,116,63,0.96); }
.ai-send.busy { opacity: 0.5; pointer-events: none; }
