/* ===========================
   ObaChat base
=========================== */

#obachat-root {
  position: relative;
  z-index: 999999;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.obachat-hidden {
  display: none !important;
}

/* ===========================
   Floating button (FAB)
=========================== */

#obachat-fab,
.obachat-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 2147483647;
  pointer-events: auto;
  transform: translateZ(0);
}

#obachat-fab img,
.obachat-fab-img {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ===========================
   Chat panel (GRANDE come prima)
=========================== */

#obachat-panel {
  position: fixed;
  right: 18px;
  bottom: 90px;

  width: 420px;

  max-height: 75vh;
  min-height: 520px;

  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483646;
}


/* Header */
.obachat-header {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.obachat-title {
  font-weight: 800;
  font-size: 14px;
}

#obachat-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
}

/* ===========================
   Messages
=========================== */

.obachat-messages {
  padding: 8px 12px;
  overflow-y: auto;
  flex: 1;
}

.obachat-messages .obachat-msg:first-child {
  margin-top: 0;
}

.obachat-msg {
  margin: 6px 0;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  max-width: 90%;
  word-wrap: break-word;
}

.obachat-user {
  background: #f0f0f0;
  margin-left: auto;
}

.obachat-bot {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
}

/* ===========================
   Input area (NUOVA)
=========================== */

.obachat-footer {
  padding: 10px;
  border-top: 1px solid rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.obachat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Textarea full width + auto-grow */
#obachat-input {
  width: 100%;
  resize: none;

  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.15);

  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;

  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;

  box-sizing: border-box;
}

/* Bottone invia */
#obachat-send {
  align-self: flex-end;
  border-radius: 12px;
  border: none;
  background: #111;
  color: #fff;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
}

/* Disclaimer sotto piccolo */
.obachat-note {
  font-size: 10.5px;
  color: rgba(0,0,0,0.45);
  line-height: 1.2;
}

/* ===========================
   Links in chat (rossi)
=========================== */

.obachat-msg a.obachat-link {
  color: #d70a17;
  font-weight: 800;
  text-decoration: underline;
}

.obachat-msg a.obachat-link:hover {
  opacity: 0.85;
}

/* ===========================
   Actions / Buttons (WhatsApp + Registrati)
=========================== */

.obachat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.obachat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.obachat-btn:hover {
  opacity: 0.9;
}

.obachat-btn.primary {
  background: #d70a17;
  color: #fff !important;
  border: none;
}

/* ===========================
   Typing indicator (3 dots)
=========================== */

.obachat-typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.obachat-typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.45);
  animation: obachat-bounce 1.1s infinite ease-in-out;
}

.obachat-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.obachat-typing .dot:nth-child(3) { animation-delay: 0.3s; }

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

/* ===========================
   Responsive (mobile)
=========================== */

@media (max-width: 480px) {
  #obachat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 70vh;
  }
}

#obachat-callout {
  position: fixed;
  bottom: 92px;
  right: 20px;
  max-width: 220px;

  background: #ffffff;
  color: #222;
  font-size: 13px;
  line-height: 1.35;

  padding: 10px 14px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);

  z-index: 2147483646;
  cursor: pointer;

  animation: obachat-callout-fade 1s ease;
}

/* freccetta */
#obachat-callout::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 22px;

  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 3px 3px 6px rgba(0,0,0,0.05);
}

/* hover */
#obachat-callout:hover {
  transform: translateY(-2px);
}

/* animazione entrata */
@keyframes obachat-callout-fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}



/* --- Lead capture (email) --- */
.obachat-lead{
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  background: rgba(255,255,255,0.9);
}
.obachat-lead-title{
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}
.obachat-lead-sub{
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.25;
  margin-bottom: 8px;
}
.obachat-lead-row{
  display: flex;
  gap: 8px;
  align-items: center;
}
#obachat-email{
  flex: 1;
  height: 36px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.15);
  font-size: 13px;
}
.obachat-lead-btn{
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  cursor: pointer;
}
.obachat-lead-error{
  margin-top: 8px;
  font-size: 12px;
  color: #b00020;
}

/* =========================
   OBA CHAT – VISIBILITY BOOST (v2)
   ========================= */

/* Icona floating (FAB) */
#obachat-fab,
.obachat-fab {
  width: 68px !important;
  height: 68px !important;
  animation: obachat-soft-bounce 8s infinite;
  box-shadow: 0 10px 28px rgba(0,0,0,0.28);
  transform: translateZ(0);
}

/* Fumetto (immagine dentro la FAB) */
#obachat-fab img,
.obachat-fab-img {
  width: 100% !important;
  height: 100% !important;
}

/* Micro animazione: bounce morbido, poco frequente */
@keyframes obachat-soft-bounce {
  0%   { transform: translateY(0) scale(1); }
  2%   { transform: translateY(-6px) scale(1.05); }
  4%   { transform: translateY(0) scale(1); }
  100% { transform: translateY(0) scale(1); }
}

/* Hover: feedback leggero */
#obachat-fab:hover,
.obachat-fab:hover {
  transform: scale(1.08);
  transition: transform 0.2s ease;
}

/* Rispetta utenti con riduzione animazioni */
@media (prefers-reduced-motion: reduce) {
  #obachat-fab,
  .obachat-fab {
    animation: none;
  }
}
