/* Chatbot Life Club Milano — widget styling
 * Palette Life Club: nero bluastro #04060B + ciano del logo #79E1F2.
 * Il ciano fa sia da accento strutturale (titolo, logo) sia da colore delle azioni
 * (bottone flottante, invia, link): scelta di Luca dell'11/09, per stare sul brand.
 * L'ambra #F2B65A del design system della landing aziendale NON si usa qui.
 * Mobile-first.
 * Tutto namespaced sotto #lcm-chat per non conflittare con tema WordPress.
 */

#lcm-chat,
#lcm-chat *,
#lcm-chat *::before,
#lcm-chat *::after {
  box-sizing: border-box;
}

/* === Reset aggressivo button (evita override dal tema WordPress) === */
#lcm-chat button {
  background: transparent;
  border: none;
  outline: none;
  color: inherit;
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  text-shadow: none;
  box-shadow: none;
  text-decoration: none;
  padding: 0;
  margin: 0;
  line-height: normal;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

#lcm-chat button:hover,
#lcm-chat button:focus,
#lcm-chat button:active {
  background: transparent;
  color: inherit;
  text-decoration: none;
  outline: none;
}

#lcm-chat {
  --lcm-bg: #04060B;
  --lcm-bg-alt: #0D131E;
  --lcm-border: #1E2A3A;
  --lcm-text: #F2F6F8;
  --lcm-text-muted: #8FA3B3;
  --lcm-cyan: #79E1F2;
  --lcm-accent: #79E1F2;
  --lcm-accent-hover: #5FC9DB;
  --lcm-accent-text: #04060B;
  --lcm-error: #FF6B6B;

  /* Da che altezza parte il widget. Sulle landing del Life Club c'e' una
     barra fissa in fondo alta ~66px (.lc-bar): senza questo scarto il
     bottone della chat copre il CTA "Calcola il preventivo".
     Se la barra cambia altezza, si ritocca solo questo valore. */
  --lcm-fab-bottom: 88px;

  font-family: 'Inter', 'Manrope', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--lcm-text);
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 2147483000;
  pointer-events: none;
}

#lcm-chat * {
  pointer-events: auto;
}

/* === Floating button === */
#lcm-chat .lcm-fab {
  position: fixed;
  bottom: var(--lcm-fab-bottom);
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50% !important;
  background: var(--lcm-accent) !important;
  color: var(--lcm-accent-text) !important;
  border: none !important;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

#lcm-chat .lcm-fab:hover {
  transform: scale(1.06);
  background: var(--lcm-accent) !important;
  color: var(--lcm-accent-text) !important;
  box-shadow: 0 10px 30px rgba(255, 235, 0, 0.35) !important;
}

.lcm-fab svg {
  width: 28px;
  height: 28px;
}

.lcm-fab.lcm-hidden {
  display: none;
}

/* === Attention seek: dopo il trigger proattivo il FAB oscilla + pulsa ===
 * Cicla ogni 3.6s con una pausa lunga di "respiro" per non essere fastidioso.
 * Disattivato in caso di prefers-reduced-motion. */
#lcm-chat .lcm-fab.lcm-fab-attention {
  animation: lcm-fab-attention 3.6s ease-in-out infinite;
}

@keyframes lcm-fab-attention {
  0%, 70%, 100% {
    transform: scale(1) rotate(0deg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
  10% { transform: scale(1.1) rotate(-10deg); }
  20% { transform: scale(1.1) rotate(10deg); }
  30% { transform: scale(1.1) rotate(-8deg); }
  40% { transform: scale(1.1) rotate(8deg); }
  50% {
    transform: scale(1.1) rotate(0deg);
    box-shadow: 0 12px 32px rgba(255, 235, 0, 0.55);
  }
  60% { transform: scale(1) rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  #lcm-chat .lcm-fab.lcm-fab-attention {
    animation: none;
  }
}

/* === Proactive bubble === */
.lcm-bubble {
  position: fixed;
  bottom: calc(var(--lcm-fab-bottom) + 75px);
  right: 20px;
  max-width: 260px;
  background: var(--lcm-bg-alt);
  color: var(--lcm-text);
  padding: 12px 36px 12px 14px;
  border-radius: 14px 14px 4px 14px;
  border: 1px solid var(--lcm-border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  font-size: 14px;
  line-height: 1.35;
  animation: lcm-fade-in 0.3s ease;
}

#lcm-chat .lcm-bubble-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none !important;
  background: transparent !important;
  color: var(--lcm-text-muted) !important;
  cursor: pointer;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none !important;
}

#lcm-chat .lcm-bubble-close:hover {
  background: var(--lcm-border) !important;
  color: var(--lcm-text) !important;
}

.lcm-bubble.lcm-hidden {
  display: none;
}

/* === Chat window === */
.lcm-window {
  position: fixed;
  /* Anche la finestra aperta resta sopra la barra fissa della landing:
     coprirla nasconderebbe telefono e CTA proprio mentre il cliente
     sta chiedendo informazioni. */
  bottom: var(--lcm-fab-bottom);
  right: 20px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - var(--lcm-fab-bottom) - 20px);
  background: var(--lcm-bg);
  border: 1px solid var(--lcm-border);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: lcm-slide-up 0.25s ease;
}

.lcm-window.lcm-hidden {
  display: none;
}

/* === Header === */
.lcm-header {
  background: var(--lcm-bg-alt);
  border-bottom: 1px solid var(--lcm-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lcm-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lcm-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
  object-fit: contain;
}

.lcm-header-text {
  display: flex;
  flex-direction: column;
}

.lcm-header-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
  color: var(--lcm-cyan);
}

.lcm-header-subtitle {
  font-size: 11px;
  color: var(--lcm-text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.lcm-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00d96d;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(0, 217, 109, 0.2);
}

.lcm-header-actions {
  display: flex;
  gap: 4px;
}

#lcm-chat .lcm-icon-button {
  width: 34px;
  height: 34px;
  border: none !important;
  background: transparent !important;
  color: var(--lcm-text-muted) !important;
  cursor: pointer;
  border-radius: 8px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  box-shadow: none !important;
}

#lcm-chat .lcm-icon-button:hover {
  background: var(--lcm-border) !important;
  color: var(--lcm-text) !important;
}

.lcm-icon-button svg {
  width: 18px;
  height: 18px;
}

/* === Messages area === */
.lcm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.lcm-messages::-webkit-scrollbar {
  width: 6px;
}

.lcm-messages::-webkit-scrollbar-track {
  background: transparent;
}

.lcm-messages::-webkit-scrollbar-thumb {
  background: var(--lcm-border);
  border-radius: 3px;
}

.lcm-msg {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: 14px;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: lcm-fade-in 0.18s ease;
}

.lcm-msg-bot {
  align-self: flex-start;
  background: var(--lcm-bg-alt);
  border: 1px solid var(--lcm-border);
  border-bottom-left-radius: 4px;
}

.lcm-msg-user {
  align-self: flex-end;
  background: var(--lcm-accent);
  color: var(--lcm-accent-text);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.lcm-msg a {
  color: var(--lcm-accent);
  text-decoration: underline;
}

.lcm-msg-user a {
  color: var(--lcm-accent-text);
}

.lcm-msg-error {
  align-self: center;
  background: transparent;
  color: var(--lcm-error);
  border: 1px dashed var(--lcm-error);
  font-size: 13px;
  text-align: center;
  max-width: 90%;
}

/* === Typing indicator === */
.lcm-typing {
  align-self: flex-start;
  background: var(--lcm-bg-alt);
  border: 1px solid var(--lcm-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 12px 14px;
  display: flex;
  gap: 4px;
}

.lcm-typing.lcm-hidden {
  display: none;
}

.lcm-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lcm-text-muted);
  animation: lcm-blink 1.4s infinite ease-in-out both;
}

.lcm-typing-dot:nth-child(1) { animation-delay: 0s; }
.lcm-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.lcm-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* === Input area === */
.lcm-input-area {
  border-top: 1px solid var(--lcm-border);
  padding: 12px;
  background: var(--lcm-bg);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.lcm-textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  background: var(--lcm-bg-alt);
  border: 1px solid var(--lcm-border);
  border-radius: 10px;
  color: var(--lcm-text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color 0.15s ease;
}

.lcm-textarea:focus {
  border-color: var(--lcm-accent);
}

.lcm-textarea::placeholder {
  color: var(--lcm-text-muted);
}

#lcm-chat .lcm-send {
  width: 40px;
  height: 40px;
  border: none !important;
  background: var(--lcm-accent) !important;
  color: var(--lcm-accent-text) !important;
  border-radius: 10px !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, opacity 0.15s ease;
  box-shadow: none !important;
  text-transform: none !important;
  letter-spacing: normal !important;
}

#lcm-chat .lcm-send:hover {
  background: var(--lcm-accent-hover) !important;
  color: var(--lcm-accent-text) !important;
}

#lcm-chat .lcm-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--lcm-accent) !important;
}

.lcm-send svg {
  width: 18px;
  height: 18px;
}

/* === Footer disclaimer === */
.lcm-disclaimer {
  font-size: 11px;
  color: var(--lcm-text-muted);
  text-align: center;
  padding: 6px 12px 10px;
  background: var(--lcm-bg);
}

.lcm-disclaimer strong {
  color: var(--lcm-text);
}

/* === Animazioni === */
@keyframes lcm-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes lcm-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes lcm-blink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* === Mobile (floating card - chat overlay sopra al sito, NON full-screen) === */
@media (max-width: 480px) {
  .lcm-window {
    /* Floating card: margini su tutti i lati, si vede pagina sotto */
    width: calc(100% - 16px);
    height: 78vh;
    height: 78dvh;             /* dynamic viewport: si adatta a tastiera */
    max-height: 78vh;
    max-height: 78dvh;
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 8px;
    left: 8px;
    border-radius: 16px;       /* arrotondato su TUTTI i lati */
    border: 1px solid var(--lcm-border);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    animation: lcm-slide-up-mobile 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  }

  /* Tap target minimo 44x44 (Apple HIG) */
  .lcm-icon-button {
    width: 44px;
    height: 44px;
  }
  .lcm-icon-button svg {
    width: 20px;
    height: 20px;
  }

  .lcm-messages {
    padding: 14px 16px;
  }

  /* Mobile: chatbot a destra, alzato al 19% del viewport per non sovrapporsi al CTA "Chiama".
   * Usa #lcm-chat per matchare la specificity del selettore base (altrimenti il bottom desktop
   * sovrascrive il mobile). */
  /* Il valore precedente era 19% del viewport, tarato sulla barra di Art
     Mall. Qui si usa lo stesso token del desktop, con qualche pixel in
     meno perche' la barra su mobile e' piu' bassa (~62px). */
  #lcm-chat .lcm-fab {
    bottom: calc(var(--lcm-fab-bottom) - 8px);
    right: 21px;
    width: 60px;
    height: 60px;
  }

  .lcm-bubble {
    right: 21px;
    /* Bottom = FAB bottom + altezza FAB (60px) + gap (12px) */
    bottom: calc(var(--lcm-fab-bottom) - 8px + 72px);
    max-width: calc(100vw - 42px);
  }

  /* Input area in fondo (la card si occupa gia della safe-area col bottom margin) */
  .lcm-input-area {
    padding-bottom: 12px;
  }
}

@keyframes lcm-slide-up-mobile {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
