@charset "UTF-8";

/* ──────────────── Reset & Root ───────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-popup: rgba(0, 0, 0, 0.01);
  --bg-header: rgba(255, 255, 255, 0.08);
  --bg-ctrl: rgba(37, 37, 37, 0.9);
  --text: #fff;
  --placeholder: rgba(255, 255, 255, 0.6);
  --brand: #007bff;
  --brand-dark: #005bb5;
}

/* ───────── Hover zoom su tutti i pulsanti ───────── */
button {
  transition: transform 0.2s ease-in-out;
}
button:hover {
  transform: scale(1.1);
}

/* ─────────────── Toggle Button ──────────────── */
#rddi-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: background .2s;
  z-index: 10002;
}
#rddi-toggle.hidden { display: none; }
#rddi-toggle:hover { background: var(--brand-dark); }

/* ───────────────── Overlay ─────────────────── */
#rddi-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 999999;
  display: none;
}
@media (max-width: 600px) {
  #rddi-overlay.active { display: block; }
}

/* ───────────────── Popup ─────────────────────── */
#rddi-popup {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  right: 20px;
  width: 360px;
  max-height: 80vh;
  display: none;
  flex-direction: column;
  background: var(--bg-popup);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 30px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.6);
  overflow: hidden;
  z-index: 1000000;
  user-select: none;
  transform-origin: bottom right;
  animation-duration: .5s;
  animation-fill-mode: both;
  pointer-events: none;
}
@supports not (bottom: calc(env(safe-area-inset-bottom) + 20px)) {
  #rddi-popup { bottom: 20px; }
}
#rddi-popup.open {
  display: flex;
  animation-name: popupIn;
  pointer-events: auto;
}

/* ── Exit animation ─────────────────────────────────── */
#rddi-popup.closing {
  display: flex;             /* rimane visibile durante l’animazione */
  animation-name: popupOut;  /* keyframe già presente */
  pointer-events: none;      /* disabilita interazioni mentre chiude */
}


@media (max-width:600px) {
  #rddi-popup {
    width: 95vw;
    bottom: 10px;
    right: 2.5vw;
    max-height: 80vh;
  }
}

/* ─────────────── Popup Animations ─────────── */
@keyframes popupIn {
  0%   { transform: scale(.3) translate(100%,100%); opacity:0; }
  60%  { transform: scale(1.05) translate(0); opacity:1; }
  100% { transform: scale(1) translate(0); opacity:1; }
}
@keyframes popupOut {
  0%   { transform: scale(1) translate(0); opacity:1; }
  100% { transform: scale(.3) translate(100%,100%); opacity:0; }
}

/* ────────────────── Header ──────────────────── */
#rddi-popup .header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 40px;
  font: 17px/1.2 "Montserrat", sans-serif;
  font-weight: bold;
  color: var(--text);
  background: var(--bg-header);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
  position: relative;
}
#rddi-popup .header .title {
  white-space: nowrap;        /* mantiene il testo su un'unica riga */
  overflow: hidden;
  text-overflow: ellipsis;
}
#rddi-close {
  position: absolute;
  top: 12px;
  left: 12px;
  background: none;
  border: none;
  cursor: pointer;
}
#rddi-close img {
  width: 20px;
  height: 20px;
}
#rddi-close:hover { color: rgba(255,255,255,0.65); }

/* ─────────────── Status Dot ───────────────── */
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 8px;
  background: red;
}
.status-dot.online { background: limegreen; }

/* ─────────────── Avatar 3D ────────────────── */
#rddi-avatar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;         /* solo padding verticale minimo */
  background: transparent;
  flex-shrink: 0;
  margin-bottom: 0;
  height: 200px !important;/* altezza automatica, rimuove spazio bianco */
}

#rddi-avatar img {
  width: 300px;    /* dimensione “piccola” */
  height: 300px;
  object-fit: contain;
  border-radius: 50%; /* se vuoi un cerchio */
}

/* ─────────────── Chat Box ─────────────────── */
#rddi-message-container {
  flex: 1;                   /* occupa tutto lo spazio tra header e controlli */
  padding: 4px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-popup); /* o un colore dedicato se preferisci */
}

/* ─────────────── Chat Box ─────────────────── */
#rddi-chatbox {
  position: relative;
  flex: 1;
  padding: 4px;
  padding-bottom: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: 14px/1.35 "Montserrat", sans-serif;
  color: var(--text);
  /* se non ti serve il fade in cima e in fondo, puoi rimuovere le righe seguenti */
  -webkit-mask-image: linear-gradient(to top, transparent 0%, black 20px, black calc(100% - 20px), transparent 100%);
  mask-image: linear-gradient(to top, transparent 0%, black 20px, black calc(100% - 20px), transparent 100%);
  margin-top: 0;
}

/* ─────────────── Bubble Styles ─────────────── */
/* Utente */
#rddi-chatbox .msg.user {
  align-self: flex-end;
  background: rgba(50,50,50,0.85);
  color: #fff;
  border-bottom-right-radius: 0;
  margin-left: auto;     /* spinge al bordo destro */
  margin-right: 16px;    /* spazio dal bordo */
  margin-bottom: 4px;    /* spazio tra un messaggio e l'altro */
  padding: 10px 14px;
  border-radius: 20px;
  max-width: 75%;
  word-break: break-word;
  line-height: 1.4;
  position: relative;
}


/* Bot */
#rddi-chatbox .msg.bot {
  align-self: flex-start;
  background: rgba(37,37,37,0.85);
  color: #fff;
  border-bottom-left-radius: 0;
  margin-bottom: 4px;
  padding: 10px 14px;
  border-radius: 20px;
  max-width: 75%;
  word-break: break-word;
  line-height: 1.4;
  position: relative;
}


/* ─────────────── Typing Indicator ─────────── */
#typing-indicator {
  display: none;
  font-style: italic;
  font-size: 13px;
  padding: 4px 16px;
  margin: 0 0 8px;
  color: var(--text);
  align-self: flex-start;
}
#typing-indicator.visible { display: block; }

/* ───────────────── Controls (barra unica) ────────────────── */
#rddi-popup .ctrl {
  position: sticky;
  bottom: 0;
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  display: flex;
  align-items: center;
  background: var(--bg-ctrl);
  border-radius: 9999px;
  padding: 4px 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  gap: 8px;
  z-index: 1;
}

/* ─────────────── Input & Buttons ───────────── */
#rddi-msg {
  flex: 1;
  min-width: 0;           /* permette lo shrink corretto */
  background: transparent;
  border: none;
  padding: 2px 8px;
  color: #fff;
  font-size: 16px;
  outline: none;
}
#rddi-msg::placeholder {
  color: var(--placeholder);
  opacity: 1;             /* placeholder sempre visibile */
}

/* ───────── Pulsanti nella barra Ctrl ───────── */
#rddi-popup .ctrl button {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
}
/* spazio orizzontale tra pulsanti */
#rddi-popup .ctrl .play-button,
#rddi-popup .ctrl .mic-button {
  margin: 0 6px;
  align-self: center;
}

/* ─── Forzo tutte le icone PNG a 20×20 ───────── */
#rddi-popup .ctrl img,
#rddi-toggle img {
  width: 20px !important;
  height: 20px !important;
  object-fit: contain;
}

/* ─────────────── Animazioni ────────────────── */
@keyframes spin {
  0% { transform: rotate(0); }
  100% { transform: rotate(360deg); }
}
@keyframes pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ─── Microphone Active State ───────────────── */
#rddi-mic.active {
  animation: pulse 0.9s ease-in-out infinite;
  transform-origin: center;
}
#rddi-mic.active img {
  transform: scale(1.1);
}

/* ─────────────── Custom Scrollbar ────────────── */
/* Nasconde il track bianco, mostra solo thumb (ovale) e freccette */
#rddi-chatbox::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
#rddi-chatbox::-webkit-scrollbar-track {
  background: transparent;
}
#rddi-chatbox::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,0.4);
  border-radius: 6px;
  border: none;
}
#rddi-chatbox::-webkit-scrollbar-button {
  display: block;
  background: transparent;
}
/* Freccette su/giù (metti il path corretto alle tue icone SVG) */
#rddi-chatbox::-webkit-scrollbar-button:vertical:decrement {
  height: 12px;
  background-image: url('path/to/up-arrow.svg');
  background-repeat: no-repeat;
  background-position: center;
}
#rddi-chatbox::-webkit-scrollbar-button:vertical:increment {
  height: 12px;
  background-image: url('path/to/down-arrow.svg');
  background-repeat: no-repeat;
  background-position: center;
}

/* Supporto Firefox */
#rddi-chatbox {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.4) transparent;
}

/* ───────────── Mini-popup di approfondimento ───────────── */
#rddi-deeplink {
  display: flex;
  position: fixed;
  top: calc(env(safe-area-inset-top, 20px) + 60px);
  left: 50%;
  transform: translateX(-50%) scale(0);
  opacity: 0;
  pointer-events: none;

  flex-direction: column;
  padding: 10px 20px;
  width: 320px;
  max-width: 90vw;
  border-radius: 50px;
  background-color: rgba(50,50,50,0.85);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);

  transition: opacity 0.3s ease, transform 0.3s ease;
  transform-origin: top center;
  z-index: 1000001;
}

/* Riga di testo */
#rddi-deeplink > span {
  font-size: 15px;
  text-align: center;
}

#rddi-deeplink p {
  margin: 0 0 12px;
  line-height: 1.4;
}

#rddi-deeplink .btns {
  display: flex;
  gap: 8px;                 /* spazio orizzontale tra Sì e No */
}

/* Stili base per i bottoni Sì/No */
#rddi-deeplink button {
  margin: 3 3px;
  flex: 1;                   /* li rende della stessa larghezza */
  padding: 6px 12px;
  font-size: 14px;
  border: none;
  border-radius: 12px;      /* arrotonda anche i bottoni */
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

/* Colore “Sì” (successo) */
#rddi-deeplink-yes {
  background: #8f8f8f;      
  color: #fff;
}
#rddi-deeplink-yes:hover {
  background: #7d7d7d;
  transform: scale(1.03);
}

/* Colore “No” (attenzione) */
#rddi-deeplink-no {
  background: #8f8f8f;      
  color: #fff;
}
#rddi-deeplink-no:hover {
  background: #7d7d7d;
  transform: scale(1.03);
}

#rddi-avatar {
  transition: transform 0.4s ease;
  transform-origin: bottom center;
}

/* quando il popup di approfondimento è aperto, rimpicciolisci l’avatar */
#rddi-avatar.zoom-out {
  transform: scale(0.70);        
  transition: transform 0.4s ease;
  transform-origin: bottom center;
}

#rddi-deeplink.open {
  transform: translateX(-50%) scale(1);
  opacity: 1;
  pointer-events: auto;
  animation: deeplinkIn 0.4s ease-out both;
}

  /* ───────────── Mobile Deeplink ───────────── */
@media (max-width: 600px) {
  #rddi-deeplink {
    top: calc(env(safe-area-inset-top, 20px) + 100px); /* più spazio su mobile */
  }
  #rddi-deeplink .btns button {
    flex: 1 !important;
    width: 40px !important;
  }
}

/* Sempre mostrare la scrollbar della pagina */
html {
  overflow-y: scroll;
}

/* Previeni lo scroll-chaining dal popup al body */
#rddi-popup {
  overscroll-behavior: contain;
}

/* ─────────── Bottoni menu personalizzato ─────────── */
#rddi-main-menu,
#rddi-servizi-submenu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.rddi-menu-btn {
  width: 100%;
  padding: 10px 14px;
  background: rgba(50,50,50,0.85);
  color: #fff;
  border: none;
  border-radius: 20px;
  font: 14px/1.3 "Montserrat", sans-serif;
  cursor: pointer;
  transition: transform .2s, background .2s;
}
.rddi-menu-btn:hover {
  background: rgba(70,70,70,0.95);
  transform: scale(1.03);
}
.rddi-menu-btn small {
  display: block;
  font-size: 11px;
  opacity: .8;
}

/* ── Layout custom per #rddi-main-menu ────────────────────── */
#rddi-main-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-radius: 12;
}

/* riga superiore con due bottoni affiancati */
#rddi-main-menu .rddi-menu-row {
  display: flex;
  gap: 8px;
}

/* “Altro” sotto, centrato */
#rddi-main-menu .single-btn {
  margin-top: 8px;
  /* eredità: width auto, centrato da align-items */
}

/* ── Fai in modo che la riga superiore occupi tutta la larghezza e divida equamente i due bottoni ── */
#rddi-main-menu .rddi-menu-row {
  display: flex;
  width: 100%;      /* occupa tutta la larghezza del contenitore */
  gap: 8px;         /* distanza tra i due bottoni */
  justify-content: center;
}

#rddi-main-menu .rddi-menu-row .rddi-menu-btn {
  flex: 1;          /* ciascun bottone prende metà spazio */
  width: auto;      /* annulla il width:100% ereditato */
}

/* ── Mantieni “Altro” sotto e centrato ── */
#rddi-main-menu .single-btn {
  width: auto;
  align-self: center;
  margin-top: 8px;
}

