/* Widget chatbot assistenza Legale Offline */

.lo-chat-root {
  position: fixed;
  z-index: 9990;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.lo-chat-root > * {
  pointer-events: auto;
}

.lo-chat-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1rem;
  background: var(--qs-green, #5bac26);
  color: #fff;
  font: 500 0.875rem/1.2 "Source Sans 3", system-ui, sans-serif;
  box-shadow: 0 8px 24px rgba(42, 63, 31, 0.28);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.lo-chat-fab:hover {
  background: var(--qs-green-dark, #3d7a1a);
  box-shadow: 0 10px 28px rgba(42, 63, 31, 0.34);
}

.lo-chat-fab--open {
  padding: 0.75rem;
  background: #e8eee4;
  color: #2a3f1f;
}

.lo-chat-fab-label {
  display: none;
}

@media (min-width: 640px) {
  .lo-chat-fab-label {
    display: inline;
  }
  .lo-chat-fab {
    right: 1.5rem;
  }
}

.lo-chat-panel {
  position: fixed;
  right: 1rem;
  bottom: 4.5rem;
  width: min(24rem, calc(100vw - 2rem));
  max-height: min(70vh, 32rem);
  display: flex;
  flex-direction: column;
  background: #fafcf8;
  border: 1px solid #d5e0cc;
  border-radius: 1rem;
  box-shadow: 0 18px 40px rgba(42, 63, 31, 0.22);
  overflow: hidden;
}

@media (min-width: 640px) {
  .lo-chat-panel {
    right: 1.5rem;
  }
}

.lo-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--qs-green, #5bac26);
  color: #fff;
}

.lo-chat-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font: 600 0.875rem/1.2 "Source Sans 3", system-ui, sans-serif;
}

.lo-chat-icon-btn {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
  padding: 0.15rem 0.35rem;
}

.lo-chat-icon-btn:hover {
  opacity: 1;
}

.lo-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 12rem;
  background: linear-gradient(180deg, #f4f7f0 0%, #fafcf8 40%);
}

.lo-chat-row {
  display: flex;
}

.lo-chat-row--user {
  justify-content: flex-end;
}

.lo-chat-row--assistant {
  justify-content: flex-start;
}

.lo-chat-bubble {
  max-width: 85%;
  padding: 0.65rem 0.85rem;
  border-radius: 1rem;
  font: 400 0.875rem/1.45 "Source Sans 3", system-ui, sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
}

.lo-chat-bubble--user {
  background: var(--qs-green, #5bac26);
  color: #fff;
  border-bottom-right-radius: 0.35rem;
}

.lo-chat-bubble--assistant {
  background: #eef3e8;
  color: #24321c;
  border-bottom-left-radius: 0.35rem;
}

.lo-chat-typing {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  min-height: 1.2rem;
}

.lo-chat-typing span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: rgba(42, 63, 31, 0.35);
  animation: lo-chat-bounce 1s infinite ease-in-out;
}

.lo-chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.lo-chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes lo-chat-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.lo-chat-limit {
  padding: 0 1rem 0.5rem;
  font: 400 0.7rem/1.4 "Source Sans 3", system-ui, sans-serif;
  color: #5a6b52;
  text-align: center;
}

.lo-chat-limit a {
  color: var(--qs-green-dark, #3d7a1a);
}

.lo-chat-footer {
  border-top: 1px solid #d5e0cc;
  padding: 0.75rem;
  background: #fff;
}

.lo-chat-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.lo-chat-input {
  flex: 1;
  border: 1px solid #c9d6be;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font: 400 0.875rem/1.2 "Source Sans 3", system-ui, sans-serif;
  background: #f4f7f0;
  color: #24321c;
}

.lo-chat-input:focus {
  outline: none;
  border-color: var(--qs-green, #5bac26);
  box-shadow: 0 0 0 3px rgba(91, 172, 38, 0.2);
}

.lo-chat-input:disabled {
  opacity: 0.55;
}

.lo-chat-send {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  background: var(--qs-green, #5bac26);
  color: #fff;
  font: 600 0.8rem/1 "Source Sans 3", system-ui, sans-serif;
  cursor: pointer;
  flex-shrink: 0;
}

.lo-chat-send:hover:not(:disabled) {
  background: var(--qs-green-dark, #3d7a1a);
}

.lo-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lo-chat-disclaimer {
  margin: 0.45rem 0 0;
  text-align: center;
  font: 400 0.65rem/1.3 "Source Sans 3", system-ui, sans-serif;
  color: #7a8a72;
}

/* Evita overlap con banner cookie in basso */
body:has(#cookieBanner:not([hidden])) .lo-chat-fab,
body:has(#cookieBanner:not([hidden])) .lo-chat-panel {
  bottom: 5.5rem;
}

body:has(#cookieBanner:not([hidden])) .lo-chat-panel {
  bottom: 9rem;
}
