/* ======================================================================
   CORE.CSS — vodafone Chat UI (clean + stable layout + mobile first)
   - Header + Footer always visible
   - Only #chat-box scrolls (body no-scroll)
   ====================================================================== */

/* === DM Sans (self-hosted) === */
@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/DMSans-Regular.woff2') format('woff2'),
       url('../fonts/DMSans-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/DMSans-Medium.woff2') format('woff2'),
       url('../fonts/DMSans-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/DMSans-Bold.woff2') format('woff2'),
       url('../fonts/DMSans-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* === Smoothing === */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ======================================================================
   THEME TOKENS (easy rebrand)
   ====================================================================== */
:root{
  --bg: linear-gradient(180deg, #FF1A1A 0%, #CC0000 100%);              /* vodafone */
  --ink: #0b0f14;
  --card: #ffffff;
  --muted: rgba(0,0,0,.58);

  --bot-bubble: #ffffff;
  --user-bubble: rgb(255, 152, 120);

  --cta: #193755;
  --cta-hover: #001a33;

  --radius-bubble: 26px;
  --radius-input: 14px;

  --shadow-1: 0 1px 3px rgba(0,0,0,.10);
  --shadow-2: 0 6px 18px rgba(0,0,0,.12);

  --max-chat: 520px;
  --pad-x: 12px;

  --avatar: 40px;
  --gap: 10px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ======================================================================
   APP LAYOUT (critical: body no-scroll; only chat-box scrolls)
   ====================================================================== */
html, body { height: 100%; }

body{
  margin: 0;
  font-family: 'DM Sans', Arial, sans-serif;
  font-weight: 400;
  letter-spacing: .2px;
  background: var(--bg);
  color: var(--ink);

  /* KEY for mobile stability */
  overflow: hidden;
}

body.app{
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* Header / Footer */
#site-header{
  flex: 0 0 auto;
  padding-top: var(--safe-top);
}
#site-footer{
  flex: 0 0 auto;
  padding-bottom: calc(8px + var(--safe-bottom));
}

/* Chat area */
#chat-container{
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  padding: 10px var(--pad-x);
  background: linear-gradient(180deg, #FF1A1A 0%, #CC0000 100%);
  overflow: hidden; /* chat-box handles scroll */
 
}

.offer-text{
  white-space: pre-line;
}


/* The only scrolling surface */
#chat-box{
  width: 100%;
  max-width: var(--max-chat);
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  display: flex;
  flex-direction: column;
  align-items: flex-start;

  padding: 6px 2px calc(50px + var(--safe-bottom)); /* più su, non a filo footer */
  box-sizing: border-box;
  scrollbar-width: none;
}
#chat-box::-webkit-scrollbar{ display:none; }

/* ======================================================================
   MESSAGE BASICS
   ====================================================================== */
.message-wrapper{
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: var(--gap);
  margin: 6px 0;
  animation: fadeInUp .22s ease-out;
}

.bot-avatar{
  width: var(--avatar);
  height: var(--avatar);
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: contain;
  transform: translateY(2px);
}

/* Bot bubble */
.bot-message{
  background: var(--bot-bubble);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: var(--radius-bubble);
  box-shadow: var(--shadow-1);
  max-width: min(92%, 430px);
  line-height: 1.5;
  font-size: 16px;
  transform-origin: bottom left;
  animation: bubbleAppear .32s cubic-bezier(.2,.85,.2,1);
}

/* Slightly nicer corners for bot bubble */
.bot-message{
  border-bottom-left-radius: 10px;
}

/* User bubble */
.user-message{
  align-self: flex-end;
  background: #29b3a3;
  color: #fff;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 18px;
  max-width: min(82%, 430px);
  margin: 6px 0 10px 0;
  box-shadow: var(--shadow-1);
  animation: fadeInUp .18s ease-out;
}

/* Strong */
.bot-message strong{ font-weight: 700; }

/* Headings from mdLight */
.bot-message h1, .bot-message h2, .bot-message h3{
  margin: 6px 0 2px;
  line-height: 1.15;
}
.bot-message h1{ font-size: 18px; }
.bot-message h2{ font-size: 17px; }
.bot-message h3{ font-size: 16px; }

/* Links inside bot */
.bot-message a{
  color: #0b4a6f;
  text-decoration: underline;
}

/* ======================================================
   🫧 Effetti dolci per bolla e pallini (by Horizon)
   ====================================================== */

/* 🌱 Fase iniziale: la bolla si gonfia piano da piccola */
.bot-message {
  background: #fff;
  color: #000;
  padding: 10px 15px;
  border-radius: 25px;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  max-width: 90%;
  font-size: 16px;
  animation: bubbleAppear 0.45s cubic-bezier(0.25, 0.8, 0.25, 1);
  transform-origin: bottom left;
  backface-visibility: hidden;
}

/* 🌬️ Fase “gonfiaggio dolce” */
@keyframes bubbleAppear {
  0%   { transform: scale(0.3) translateY(15px); opacity: 0; }
  50%  { transform: scale(0.8) translateY(5px); opacity: 0.7; }
  80%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* 💭 Bolla typing (3 pallini) */
.bot-message.loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 20px;

  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  animation: bubbleAppear 0.4s ease-out;
  transition: all 0.6s ease;
   border-radius: 25px 25px 25px 0px;
}

/* 🌈 Transizione quando da typing diventa messaggio */
.bot-message.expanded {
  width: auto;
  height: auto;
  padding: 12px 18px;
  border-radius: 26px;
  transition: all 0.6s ease-in-out;
}

/* ⚪ I tre pallini del loader */
.typing-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 14px;
}

.typing-indicator span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #000;
  opacity: 0.25;
  transform: scale(0.7);
  animation: typingSoft 1.5s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

.typing-indicator span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #000;
  opacity: 0.25;
  transform: scale(0.7);
  animation: waveTyping 1.8s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes waveTyping {
  0%, 80%, 100% {
    transform: translateY(0px) scale(0.7);
    opacity: 0.25;
  }
  40% {
    transform: translateY(-6px) scale(1);
    opacity: 0.9;
  }
}


/* 🧡 Testo: entra senza “flash”, ma dolcemente */
.bot-message.expanded p,
.bot-message.expanded span,
.bot-message.expanded strong {
  animation: fadeInTextSoft 0.5s ease forwards;
}

@keyframes fadeInTextSoft {
  0%   { opacity: 0; transform: translateY(2px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Evita scatti di repaint durante le animazioni */
.animated {
  -webkit-transform: translateZ(0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


.tease {
  text-align: center;
  color: #00a0e6; /* rosso  */
  font-weight: 600;
  font-size: 14px;
  margin-top: 10px;
  line-height: 1.4;
}

/* ======================================================================
   INPUT BLOCKS (inline input + final_form)
   ====================================================================== */
.input-container{
  background: var(--card);
  color: var(--ink);
  padding: 14px 16px;
  border-radius: 20px;
  box-shadow: var(--shadow-1);
  max-width: min(92%, 430px);
  margin-left: calc(var(--avatar) + var(--gap)); /* aligns under bot bubble */
  width: 100%;
}

.ff-field + .ff-field{ margin-top: 10px; }

.input-container input{
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(0,0,0,.14);
  border-radius: var(--radius-input);
  padding: 12px 12px;
  font-size: 16px;
  line-height: 1.2;
  outline: none;
  background: #fff;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}

.input-container input:focus{
  border-color: rgba(0,0,0,.35);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}

input.error{
  border-color: #d93025 !important;
  box-shadow: 0 0 0 3px rgba(217,48,37,.12) !important;
}

/* Buttons: main CTA */
.cta-btn,
.input-container button{
  width: 100%;
  background: #001a33;
  color: #fff;
  border: none;
  border-radius: var(--radius-input);
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .06s ease, background .18s ease, box-shadow .18s ease;
  box-shadow: 0 1px 0 rgba(0,0,0,.18);
}
.cta-btn:hover,
.input-container button:hover{
  background: var(--cta-hover);
}
.cta-btn:active,
.input-container button:active{
  transform: translateY(1px);
}

/* Errors */
.error-message{
  display: block;
  color: #d93025;
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
  text-align: left;
  padding-left: 2px;
}

/* Privacy */
.privacy-container{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
  line-height: 1.35;
}
.privacy-container a{
  color: #0b4a6f;
  text-decoration: underline;
  font-weight: 700;
}
.privacy-container input[type="checkbox"]{
  transform: translateY(1px);
  margin-right: 8px;
}

/* Final infos */
.final-infos{
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.legal-note{
  margin-top: 6px;
}

/* ======================================================================
   BUTTONS GRID (Sì/No + multiple)
   ====================================================================== */
.button-container{
  width: 100%;
  max-width: var(--max-chat);
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
  margin: 6px 0;
}

.button-container button{
  background: #0a1f44;
  color: #fff;
  border: 2px solid #0a1f44;
  border-radius: 18px;
  min-height: 56px;
  padding: 12px 14px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  white-space: normal;
  transition: transform .08s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.button-container button:hover{
  background: #122b57;
  border-color: #122b57;
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.button-container button:active{
  transform: translateY(0);
}

.button-container button small{
  display:block;
  font-size: 13px;
  margin-top: 4px;
  font-weight: 600;
  color: rgba(255,255,255,.82);
}

/* Single-button rows (e.g., "Prosegui") */
.button-container:has(button:only-child){
  grid-template-columns: 1fr;
}

/* ======================================================================
   OFFER MESSAGE (clean)
   ====================================================================== */
.offer-message{
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 10px 0 !important;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
.offer-message strong{ font-weight: 800; }
.offer-message s{ color: rgba(0,0,0,.45); }

/* Offer block (inside offer-message) */
.offer{
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow-1);
  padding: 14px 16px;
  margin-left: calc(var(--avatar) + var(--gap));
  max-width: min(92%, 430px);
}
.offer-title{ font-size: 16px; margin-bottom: 4px; }
.offer-sub{ color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.offer-price{ font-size: 16px; margin: 6px 0 8px; }
.offer-feats div{ margin: 4px 0; }
.offer-note{ margin-top: 8px; color: var(--muted); font-size: 12px; }

/* ======================================================================
   ANIMATIONS
   ====================================================================== */
@keyframes fadeInUp{
  from { opacity:0; transform: translateY(10px); }
  to   { opacity:1; transform: translateY(0); }
}
@keyframes bubbleAppear{
  0%   { transform: scale(.92) translateY(8px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* ======================================================================
   RESPONSIVE
   ====================================================================== */
@media (max-width: 380px){
  :root{ --avatar: 36px; }
  .bot-message, .user-message{ font-size: 15px; }
  
}

@media (min-width: 768px){
  .bot-message{ font-size: 17px; }
  .input-container input{ font-size: 16px; }
}
/* ✅ checkbox sempre cliccabile e visibile */
.privacy-container input[type="checkbox"]{
  appearance: auto !important;
  -webkit-appearance: checkbox !important;
  width: 18px !important;
  height: 18px !important;
  cursor: pointer;
}
.privacy-container label{
  cursor: pointer;
  user-select: none;
}

.legal-row{display:flex;gap:.5rem;flex-wrap:wrap;align-items:center;margin:.5rem 0}
.legal-pill{border:0;padding:.25rem .6rem;border-radius:999px;font-size:.85rem;cursor:pointer;background:#f0bf4c}
.legal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:9998;opacity:0;transition:opacity .2s}
.legal-backdrop.show{opacity:1}
.legal-modal{position:fixed;left:0;right:0;bottom:0;max-height:75vh;background:#fff;border-radius:16px 16px 0 0;z-index:9999;transform:translateY(100%);transition:transform .25s ease;display:flex;flex-direction:column}
.legal-modal.show{transform:translateY(0)}
.legal-h{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid #eee}
.legal-b{padding:12px 16px;overflow:auto;line-height:1.4;font-size:.95rem}
.legal-ack{display:flex;align-items:center;gap:.5rem;padding:8px 16px}
.legal-cta{margin:8px 16px 16px;padding:12px 14px;border:0;border-radius:10px;cursor:pointer;background:#f0bf4c}
.legal-cta[disabled]{opacity:.6;cursor:not-allowed}
.legal-close{background:transparent;border:0;font-size:1.1rem;cursor:pointer}
.legal-note{
  font-size:.8rem; color:#6b7280; line-height:1.35;
}
.legal-note strong{ font-weight:600; color:inherit; }

/* Falso link accessibile */
.legal-link{
  background:none; border:0; padding:0;
  font:inherit; color:#00000082;      /* blu link */
  text-decoration:underline; cursor:pointer;
  font-size:.6rem;
}
.legal-link:hover{ text-decoration:none; }
.legal-link:focus-visible{ outline:2px solid currentColor; outline-offset:2px; border-radius:2px; 
    
}
