/* Stile base del widget di chat roboquio */
/* Poppins self-hosted via @font-face (Latin subset; weights 400, 500 & 700) */

@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../public_html/assets/fonts/poppins-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../public_html/assets/fonts/poppins-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../public_html/assets/fonts/poppins-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF;
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../public_html/assets/fonts/poppins-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF;
}
:root {
  --rbq-header-bg-color: #0464ca;
  --rbq-header-text-color: #fff;
  --rbq-subtitle-text-color: rgba(255, 255, 255, 0.7);
  --rbq-border-radius: 10px;
  --rbq-bubble-radius: 1.5rem; /* border-radius for chat bubbles */
  /* Gradient fallbacks default */
  --rbq-header-bg-gradient: linear-gradient(to right, var(--rbq-header-bg-color), var(--rbq-header-bg-color));
  --rbq-user-bubble-gradient: linear-gradient(to right, var(--rbq-header-bg-color), var(--rbq-header-bg-color));
  --rbq-bot-bubble-link-color: #062dab;
}

/* Stile generale per il widget di chat */
#roboquio-chat {
  width: 100%;
  height: 100%;
  position: fixed;
  bottom: 0;
  right: 0;
  background-color: #fff;
  z-index: 1000;
  border-radius: var(--rbq-border-radius);
  overflow: hidden;
  transition: height 0.3s ease, width 0.3s ease, border-radius 0.3s ease;
  font-family: 'Poppins', Arial, sans-serif;
}

/* Stato minimizzato */
#roboquio-chat.minimized {
  border-radius: 100%;
}

/* Stato espanso */
#roboquio-chat.expanded {
  border-radius: var(--rbq-border-radius);
}

/* Testata della finestra di chat */
#roboquio-chat .chat-header {
  background: var(--rbq-header-bg-gradient);
  color: var(--rbq-header-text-color);
  padding: 3px 13px 13px 13px;
  cursor: pointer;
  text-align: center;
  font-weight: bold;
  font-size: 20px;
  position: relative;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
}

#roboquio-chat .icon {
  display: flex;
  opacity: 0;
  width: 0px;
  height: 0px;
  justify-content: center;
  align-items: center;
  padding: 5px 0 0 5px;
  transition: opacity 1.5s ease;
}

#roboquio-chat .icon svg {
  width: 90%;
  height: 90%;
  transition: width 0.5s ease, height 0.5s ease;
}

#roboquio-chat .icon svg:hover {
  width: 100%;
  height: 100%;
}

/* Header avatar */
#roboquio-chat .chat-header img.avatar {
  width: 2.75rem;
  height: 2.75rem;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 50%;
}

/* Header text container */
#roboquio-chat .chat-header-controls {
  height: auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  margin-bottom: 7px;
}

#roboquio-chat .chat-header-controls .maximize-container {
  justify-self: start;
  display: flex;
}

#roboquio-chat .chat-header-controls .minimize-container {
  justify-self: center;
  display: flex;
}

#roboquio-chat .chat-header-controls .language-selector {
  justify-self: end;
  margin-left: 0;
}

#roboquio-chat .chat-header-controls .minimize,
#roboquio-chat .chat-header-controls .maximize-full {
  border-radius: 50%;
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-content: center;
  cursor: pointer;
  z-index: 1002;
  background-color: rgba(0, 0, 0, 0);
  color: var(--rbq-header-text-color);
  transition: background 0.6s ease;
}

#roboquio-chat .chat-header-controls .minimize:hover,
#roboquio-chat .chat-header-controls .maximize-full:hover {
  background: rgba(0, 0, 0, 0.3);
}

#roboquio-chat .chat-header-title {
  height: auto;
  text-align: left;
}

#roboquio-chat .chat-header-title .header-text {
  margin-left: 5px;
  display: inline-block;
  vertical-align: middle;
}
#roboquio-chat .chat-header-title .header-text .title {
  font-size: 1em;
  font-weight: 500;
  line-height: 1;
}
#roboquio-chat .chat-header-title .header-text .subtitle {
  font-size: 0.7em;
  color: var(--rbq-subtitle-text-color);
  line-height: 1;
  font-weight: 400;
  margin-top: 3px;
}

/* Area di visualizzazione messaggi */
#roboquio-chat .chat-body {
  display: flex;
  flex-direction: column;
  gap: 10px; /* spazio verticale tra le bolle */
  flex: 1;
  padding: 15px;
  height: calc(100% - 230px);
  overflow-y: auto;
  overflow-x: hidden;
  color: #000;
  text-align: left;
  scroll-behavior: smooth;
}

#roboquio-chat .chat-body p {
  margin: 10px 0;
}

/* Footer */
#roboquio-chat .chat-input-container {
  display: block;
  height: 40px;
  padding: 15px 15px 5px 15px;
}

#roboquio-chat .chat-input-box {
  display: flex;
  background-color: #f1f5f9;
  border-radius: 1.5rem;
  padding: 0.625rem 1rem;
  width: 100%;
  align-items: center;
  border: 1px solid transparent;
}

/* Evidenzia il box input quando il textarea interno è in focus */
#roboquio-chat .chat-input-box:focus-within {
  border: 1px solid var(--rbq-send-button-active-bg);
}

#roboquio-chat .chat-input-textarea {
  flex: 1;
  background: transparent;
  resize: none;
  overflow: hidden;
  border: none;
  outline: none;
  font-size: 0.875rem;
  line-height: 1.4;
  padding: 0;
  font-family: inherit;
  white-space: nowrap;
}
#roboquio-chat .chat-send-button-container {
  display: flex;
  padding: 1px 2px 0px 10px;
}
#roboquio-chat .chat-send-button {
  background: var(--rbq-send-button-active-bg);
  border: none;
  border-radius: 50%;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  opacity: 0.5;
  transition: opacity 0.2s;
}
#roboquio-chat .chat-send-button.active {
  opacity: 1;
}
#roboquio-chat .chat-send-button:hover {
  opacity: 0.8;
}
#roboquio-chat .chat-send-button:disabled {
  cursor: default;
  opacity: 0.5;
}

/* Bolla del messaggio */
#roboquio-chat .chat-message {
  display: block;
  max-width: 85%;
  margin-bottom: 10px;
  padding: 0px 15px;
  border-radius: var(--rbq-bubble-radius);
  font-size: 0.875rem;
  line-height: 1.4;
  font-family: 'Poppins', Arial, sans-serif;
}

#roboquio-chat .chat-message.bot-message {
  background-color: #f1f5f9;
  color: #1e293b;
}

#roboquio-chat .chat-message.bot-message a {
  display: block;
  text-decoration: none;
  font-weight: 700;
  color: var(--rbq-bot-bubble-link-color);
}

#roboquio-chat .chat-message.bot-message a:before {
  content: "👉";
  padding-right: 5px;
}

#roboquio-chat .chat-message.user-message {
  background: var(--rbq-user-bubble-gradient);
  color: var(--rbq-header-text-color);
}

/* Selettore lingua nel header */
#roboquio-chat .language-selector {
  position: relative;
  display: inline-flex;
  background-color: rgba(0, 0, 0, 0);
  align-items: center;
  justify-content: center;
  margin-left: auto;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  font-size: 0.8em;
  font-weight: 600;
  color: var(--rbq-header-text-color);
  transition: background 0.2s ease;
}
#roboquio-chat .language-selector:hover {
  background: rgba(0, 0, 0, 0.3);
}
#roboquio-chat .language-current {
  border-radius: 50%;
  width: 2.75rem;
  height: 2.75rem;
  align-content: center;
  z-index: 1002;
  transition: background 0.6s ease;
}
#roboquio-chat .language-selector.active span.language-current {
  background: var(--rbq-send-button-active-bg);
  filter: brightness(85%);
  transition: none;
}
#roboquio-chat .language-dropdown {
  position: absolute;
  top: 22px;
  padding-top: 22px;
  width: 2.75rem;
  right: 0;
  background: var(--rbq-send-button-active-bg);
  border-radius: 0 0 25px 25px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 1001;
}
#roboquio-chat .language-dropdown.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#roboquio-chat .language-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9em;
  text-align: center;
  white-space: nowrap;
}
#roboquio-chat .language-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.3);
}

#roboquio-chat .chat-message.user-message a {
  color: var(--rbq-header-text-color);
  text-decoration: none;
  font-weight: 700;
}

/* Wrapper per allineamento orizzontale delle bolle */
#roboquio-chat .chat-row {
  display: flex;
  width: 100%;
}
#roboquio-chat .bot-row {
  justify-content: flex-start;
}
#roboquio-chat .user-row {
  justify-content: flex-end;
}
#roboquio-chat .bot-row .chat-message {
  margin-right: 2rem; /* spazio a sinistra del bot */
}
#roboquio-chat .user-row .chat-message {
  margin-left: 2rem; /* spazio a destra dell'utente */
}

#roboquio-chat.minimized .icon {
  opacity: 1; /* per mostrare l'icona */
  width: 100%;
  height: 100%;
}

#roboquio-chat.maximized .icon {
  opacity: 0; /* per nascondere l'icona */
  width: 0px;
  height: 0px;
}

#roboquio-chat.minimized .chat-header {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding: 0;
}

#roboquio-chat.maximized .chat-header {
  height: auto;
}

#roboquio-chat.minimized .chat-header-controls {
  display: none;
}

#roboquio-chat.maximized .chat-header-controls {
  display: flex;
}

#roboquio-chat.minimized .chat-header-title {
  display: none;
}

#roboquio-chat.maximized .chat-header-title {
  display: flex;
}

#roboquio-chat.minimized .chat-body {
  display: none;
}

#roboquio-chat.maximized .chat-body {
  display: flex;
}

#roboquio-chat.minimized .chat-input-container {
  display: none;
}

#roboquio-chat.expanded .chat-input-container {
  display: flex;
}

#roboquio-chat.minimized .chat-credits {
  display: none;
}

#roboquio-chat.expanded .chat-credits {
  display: block;
  text-align: center;
  line-height: 1em;
}
  
#roboquio-chat .credits-text {
  font-size: 0.77em;
  color: #CCC;
}

/* Loading animation dei puntini tra query e risposta */
#roboquio-chat .chat-message.loading {
  display: flex;
  justify-content: center;
  align-items: center;
}

#roboquio-chat .loading-dots {
  width: 50px;
  height: 40px;
}

#roboquio-chat .loading-dots circle {
  fill: #999;
  opacity: 0.5;
  animation: loading-dot 1s infinite ease-in-out;
}

#roboquio-chat .loading-dots circle:nth-child(1) { animation-delay: 0s; }
#roboquio-chat .loading-dots circle:nth-child(2) { animation-delay: 0.2s; }
#roboquio-chat .loading-dots circle:nth-child(3) { animation-delay: 0.4s; }

@keyframes loading-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 1; }
  40% { transform: translateY(-5px); opacity: 0.5; }
}

/* Pop-in animation per comparsa delle bolle */
#roboquio-chat .chat-message.bot-message.animate-in {
  animation: pop-in-left-to-right 0.2s ease-out forwards, bounce 0.1s ease-in 0.2s forwards;
}
#roboquio-chat .chat-message.user-message.animate-in {
  animation: pop-in-right-to-left 0.2s ease-out forwards, bounce 0.1s ease-in 0.2s forwards;
}
@keyframes pop-in-left-to-right {
  from { opacity: 0; transform: translateX(-100px) scale(0); }
  to   { opacity: 1; transform: translateX(0) scale(1.1 ); }
}
@keyframes pop-in-right-to-left {
  from { opacity: 0; transform: translateX(100px) scale(0); }
  to   { opacity: 1; transform: translateX(0) scale(1.1); }
}
@keyframes bounce {
 from { transform: scale(1.1); }
 to { transform: scale(1); }
}

/* Tooltip wrapper outside the iframe */
.roboquio-wrapper {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 0;
  z-index: 10000000;
  max-height: calc(100% - 32px);
  transition: height 0.3s ease;
}

#roboquio-chat-container {
  flex-shrink: 0;
}

.roboquio-tooltip {
  height: 56px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  width: 0;
  overflow: hidden;
  /* nessuna transition qui */
}

.roboquio-tooltip.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  width: auto;
  overflow: visible;
  transition: opacity 0.3s ease, transform 0.3s ease;
  cursor: pointer;
}

.tooltip-svg {
  overflow: visible;
  display: block;
}

.tooltip-svg text {
  fill: var(--rbq-tooltip-color);
  font-family: sans-serif;
  font-weight: bold;
}

.tooltip-svg path {
  fill: #ffffff;
  stroke: var(--rbq-tooltip-color);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}
