/* Floating Agent v6 — widget chat overlay */

#floating-agent-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #5b8def;
  color: #fff;
  border: none;
  box-shadow: 0 6px 20px rgba(91, 141, 239, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#floating-agent-bubble:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 28px rgba(91, 141, 239, 0.55);
}

#floating-agent-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 420px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

#floating-agent-panel .fa-header {
  background: #1a3a6e;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#floating-agent-panel .fa-header strong {
  flex: 1;
}

#floating-agent-panel .fa-header small {
  font-size: 11px;
  opacity: 0.85;
}

#floating-agent-panel .fa-header code {
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 6px;
  border-radius: 3px;
}

#floating-agent-panel .fa-close {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

#floating-agent-panel .fa-close:hover {
  color: #f4a;
}

#floating-agent-panel .fa-chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  background: #f8f9fa;
  min-height: 200px;
  max-height: 400px;
}

#floating-agent-panel .fa-msg {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

#floating-agent-panel .fa-msg-user {
  background: #5b8def;
  color: #fff;
  margin-left: 32px;
}

#floating-agent-panel .fa-msg-assistant {
  background: #fff;
  border: 1px solid #e5e7eb;
  margin-right: 32px;
}

#floating-agent-panel .fa-msg-system {
  background: #e7f4e7;
  color: #2e7d32;
  font-size: 12px;
  font-style: italic;
}

#floating-agent-panel .fa-msg-warning {
  background: #fff4e0;
  color: var(--isb-gold, #d4a437);
  font-size: 12px;
}

#floating-agent-panel .fa-msg-error {
  background: #fde8e8;
  color: #b03a2e;
  font-size: 12px;
}

#floating-agent-panel .fa-msg-learn {
  background: #f3e8fd;
  color: #6f42c1;
  font-size: 12px;
  border-left: 3px solid #6f42c1;
  padding-left: 9px;
}

#floating-agent-panel .fa-msg-question {
  background: #fffde0;
  color: #6c4a00;
  font-style: italic;
}

#floating-agent-panel .fa-pdf-area {
  padding: 8px 16px;
  background: #fafbfc;
  border-top: 1px solid #e5e7eb;
}

#floating-agent-panel .fa-pdf-label {
  display: block;
  padding: 8px 12px;
  background: #fff;
  border: 1px dashed #b8c5d6;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

#floating-agent-panel .fa-pdf-label:hover {
  border-color: #5b8def;
  background: #f6f9ff;
}

#floating-agent-panel .fa-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}

#floating-agent-panel .fa-input-area textarea {
  flex: 1;
  padding: 8px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
  max-height: 150px;
  font-family: inherit;
}

#floating-agent-panel .fa-input-area textarea:focus {
  outline: none;
  border-color: #5b8def;
  box-shadow: 0 0 0 2px rgba(91, 141, 239, 0.2);
}

#floating-agent-panel .fa-input-area button {
  background: #5b8def;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

#floating-agent-panel .fa-input-area button:hover:not(:disabled) {
  background: #4070d0;
}

#floating-agent-panel .fa-input-area button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#floating-agent-panel .fa-footer {
  padding: 6px 16px;
  background: #f8f9fa;
  border-top: 1px solid #e5e7eb;
  text-align: right;
  color: #888;
  font-size: 11px;
}

/* Highlight applied to form fields filled by AI */
.floating-agent-filled {
  background: #fffbe8 !important;
  border-left: 3px solid #f0a020 !important;
}

.floating-agent-uncertain {
  background: #fff4e0 !important;
  border-left: 3px solid #ff8c00 !important;
}

/* Responsive: pannello full-width su mobile */
@media (max-width: 640px) {
  #floating-agent-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 80px;
  }
  #floating-agent-bubble {
    bottom: 12px;
    right: 12px;
  }
}
