@property --fa-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

:root {
  --fa-nero: #030303;
  --fa-navy: #0a111e;
  --fa-navy-light: #0f1a2e;
  --fa-ciano: #4FE3FF;
  --fa-blu: #2680E9;
  --fa-verde: #25D366;
  --fa-verde-dark: #1ebe5b;
  --fa-bordo: rgba(62, 200, 247, 0.18);
  --fa-grad-brand: linear-gradient(135deg, #2680E9 0%, #4FE3FF 100%);
}

/* ═══ CONTAINER FISSO ═══ */
.fa-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  display: flex;
  flex-direction: column-reverse;
  gap: 14px;
  pointer-events: none;
}
.fa-container > * { pointer-events: auto; }

/* ═══ BOTTONE BASE ═══ */
.fa-btn {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  border: none;
  text-decoration: none;
  color: #fff;
  font-size: 26px;
  transition: transform 0.3s cubic-bezier(.2,.7,.2,1), box-shadow 0.3s;
  isolation: isolate;
}

/* Anello rotante */
.fa-btn::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(
    from var(--fa-angle),
    transparent 0%,
    rgba(79, 227, 255, 0.95) 25%,
    transparent 50%,
    rgba(38, 128, 233, 0.95) 75%,
    transparent 100%
  );
  animation: faSpin 5s linear infinite;
  opacity: 0.85;
  z-index: -1;
  filter: blur(0.5px);
}
@keyframes faSpin { to { --fa-angle: 360deg; } }

/* Cerchio nero di fondo per far vedere l'anello */
.fa-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  z-index: -1;
}

.fa-btn:hover {
  transform: translateY(-3px) scale(1.05);
}
.fa-btn:hover::before {
  animation-duration: 1.5s;
  opacity: 1;
  filter: blur(0);
}

/* Icona SVG dentro il bottone */
.fa-btn svg {
  width: 30px;
  height: 30px;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

/* ═══ WHATSAPP ═══ */
.fa-btn-whatsapp {
  background: linear-gradient(135deg, var(--fa-verde), var(--fa-verde-dark));
  box-shadow: 0 12px 32px rgba(37, 211, 102, 0.5), 0 0 0 0 rgba(37, 211, 102, 0.4);
}
.fa-btn-whatsapp:hover {
  box-shadow: 0 16px 44px rgba(37, 211, 102, 0.7), 0 0 0 8px rgba(37, 211, 102, 0.12);
}

/* ═══ AI ASSISTANT ═══ */
.fa-btn-ai {
  background: var(--fa-grad-brand);
  color: #02121d;
  box-shadow: 0 12px 32px rgba(38, 128, 233, 0.5), 0 0 0 0 rgba(79, 227, 255, 0.4);
}
.fa-btn-ai:hover {
  box-shadow: 0 16px 44px rgba(79, 227, 255, 0.7), 0 0 0 8px rgba(79, 227, 255, 0.12);
}
.fa-btn-ai svg {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2));
}

/* Pulse quando ha notifiche non lette */
.fa-btn-ai.has-notif::before {
  animation-duration: 2s;
}

/* ═══ BADGE NOTIFICHE ═══ */
.fa-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff3b30;
  color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--fa-nero);
  box-shadow: 0 3px 12px rgba(255, 59, 48, 0.7);
  z-index: 10;
  pointer-events: none;
}
.fa-badge.show { display: flex; }

/* ═══ TOOLTIP ═══ */
.fa-tooltip {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  background: linear-gradient(135deg, var(--fa-navy-light), var(--fa-navy));
  border: 1px solid var(--fa-bordo);
  color: #e8f4ff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  padding: 10px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 40px rgba(79, 227, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.fa-tooltip::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: var(--fa-navy-light);
}
.fa-btn:hover .fa-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* Tooltip nascosto su mobile (no hover) */
@media (max-width: 768px) {
  .fa-tooltip { display: none; }
}

/* ═══ PANNELLO CHAT ═══ */
.fa-chat-panel {
  position: fixed;
  bottom: 174px;
  right: 24px;
  width: 370px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 220px);
  background: linear-gradient(180deg, var(--fa-navy-light), var(--fa-navy));
  border: 1px solid rgba(79, 227, 255, 0.25);
  border-radius: 22px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.75),
    0 0 60px rgba(79, 227, 255, 0.1);
  overflow: hidden;
  display: none;
  flex-direction: column;
  z-index: 99999;
  font-family: 'Inter', system-ui, sans-serif;
  color: #e8f4ff;
}
.fa-chat-panel.open {
  display: flex;
  animation: faSlideUp 0.25s cubic-bezier(.2,.7,.2,1);
}
@keyframes faSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.fa-chat-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 60%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(79, 227, 255, 0.7), transparent);
}

/* Header chat */
.fa-chat-header {
  background: linear-gradient(135deg, var(--fa-blu), #1035B0);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.fa-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.fa-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--fa-ciano);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
  color: var(--fa-nero);
  box-shadow: 0 0 20px rgba(79, 227, 255, 0.5);
}
.fa-chat-title {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  line-height: 1.2;
}
.fa-chat-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 2px;
}
.fa-chat-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.fa-chat-icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  padding: 6px 8px;
  opacity: 0.75;
  border-radius: 8px;
  transition: all 0.2s;
  font-family: inherit;
  line-height: 1;
}
.fa-chat-icon-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}
.fa-chat-icon-btn.fa-close {
  font-size: 22px;
  padding: 4px 10px;
}

/* Messaggi */
.fa-chat-messages {
  flex: 1;
  min-height: 300px;
  max-height: 380px;
  overflow-y: auto;
  padding: 16px;
  background: #060d1a;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fa-chat-messages::-webkit-scrollbar { width: 5px; }
.fa-chat-messages::-webkit-scrollbar-track { background: transparent; }
.fa-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(79, 227, 255, 0.25);
  border-radius: 3px;
}
.fa-msg {
  padding: 11px 15px;
  border-radius: 14px;
  max-width: 88%;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: faMsgIn 0.22s ease-out;
}
@keyframes faMsgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.fa-msg-user {
  align-self: flex-end;
  background: var(--fa-grad-brand);
  color: #02121d;
  font-weight: 600;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(38, 128, 233, 0.35);
}
.fa-msg-bot {
  align-self: flex-start;
  background: #0f1d30;
  color: #fff;
  border-left: 3px solid var(--fa-ciano);
  border-bottom-left-radius: 4px;
  box-shadow: -3px 0 12px rgba(79, 227, 255, 0.15);
}
.fa-msg-time {
  font-size: 10px;
  color: #4a6c96;
  text-align: center;
  margin: 4px 0;
}

/* Typing indicator */
.fa-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 13px 18px;
  background: #0f1d30;
  border-radius: 14px;
  border-left: 3px solid var(--fa-ciano);
  max-width: 72px;
}
.fa-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fa-ciano);
  opacity: 0.5;
  animation: faTypingBounce 1.2s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(79, 227, 255, 0.6);
}
.fa-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.fa-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes faTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick buttons */
.fa-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 14px 8px;
  background: #060d1a;
  border-top: 1px solid rgba(62, 200, 247, 0.1);
}
.fa-quick-btn {
  background: rgba(38, 128, 233, 0.14);
  border: 1px solid rgba(79, 227, 255, 0.4);
  color: var(--fa-ciano);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.fa-quick-btn:hover {
  background: rgba(79, 227, 255, 0.22);
  border-color: var(--fa-ciano);
  transform: translateY(-1px);
}

/* Input */
.fa-chat-input-wrap {
  padding: 12px 14px;
  background: var(--fa-navy-light);
  border-top: 1px solid var(--fa-bordo);
  flex-shrink: 0;
}
.fa-chat-input-row {
  display: flex;
  gap: 8px;
}
.fa-chat-input {
  flex: 1;
  padding: 12px 18px;
  border-radius: 50px;
  border: 1px solid var(--fa-bordo);
  background: #0d1929;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.fa-chat-input:focus {
  border-color: var(--fa-ciano);
  box-shadow: 0 0 20px rgba(79, 227, 255, 0.2);
}
.fa-chat-input::placeholder { color: #4a6c96; }
.fa-chat-send {
  background: var(--fa-grad-brand);
  color: #02121d;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  font-size: 21px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  display: grid;
  place-items: center;
}
.fa-chat-send:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 0 20px rgba(79, 227, 255, 0.5);
}
.fa-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ═══ MOBILE ═══ */
@media (max-width: 768px) {
  .fa-container {
    bottom: 20px;
    right: 20px;
    gap: 12px;
  }
  .fa-btn {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }
  .fa-btn svg { width: 26px; height: 26px; }
  .fa-chat-panel {
    bottom: 20px;
    right: 16px;
    left: 16px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 40px);
    border-radius: 20px;
  }
  .fa-chat-messages {
    min-height: 240px;
    max-height: calc(100vh - 260px);
  }
}

/* ═══ SPOSTA IN ALTO SE C'È IL CARRELLO MOBILE ═══ */
body.has-cart .fa-container {
  bottom: 100px;
}
body.has-cart .fa-chat-panel {
  bottom: 244px;
}
@media (max-width: 1024px) {
  body.has-cart .fa-container { bottom: 100px; }
  body.has-cart .fa-chat-panel { bottom: 244px; }
}

/* ═══ NASCONDI VECCHI BOTTONI HARDCODED ═══ */
.whatsapp-float,
#selkermo-float-btn,
#selkermo-chat-panel {
  display: none !important;
}