/* ============================================================
   Assistente Ernia Shop — Widget Styles
   ============================================================ */

:root {
  --asernia-primary: #e63946;
  --asernia-primary-dark: #c1121f;
  --asernia-bg: #ffffff;
  --asernia-surface: #f8fafc;
  --asernia-border: #e2e8f0;
  --asernia-text: #1e293b;
  --asernia-text-muted: #64748b;
  --asernia-shadow: 0 20px 60px rgba(0,0,0,.15), 0 8px 20px rgba(0,0,0,.08);
  --asernia-radius: 18px;
  --asernia-radius-msg: 14px;
  --asernia-z: 99999;
}

/* ── Bottone rotondo floating ────────────────────────────── */
#asernia-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--asernia-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,.4);
  z-index: var(--asernia-z);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
  outline: none;
}
#asernia-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
#asernia-toggle-btn.asernia-hidden { display: none !important; }

/* Badge notifica */
#asernia-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #111;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}
#asernia-badge.visible { display: flex; }

/* ── Finestra chat ───────────────────────────────────────── */
#asernia-chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 110px);
  background: var(--asernia-bg);
  border-radius: var(--asernia-radius);
  box-shadow: var(--asernia-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--asernia-z);
  transform-origin: bottom right;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s;
  border: 1px solid var(--asernia-border);
}
#asernia-chat-window.asernia-hidden {
  transform: scale(.85) translateY(16px);
  opacity: 0;
  pointer-events: none;
}

/* ── Header ──────────────────────────────────────────────── */
#asernia-header {
  background: var(--asernia-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#asernia-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#asernia-header-info { flex: 1; min-width: 0; }
#asernia-header-title { font-weight: 700; font-size: 15px; }
#asernia-header-subtitle { font-size: 11px; opacity: .8; margin-top: 1px; }

#asernia-minimize-btn,
#asernia-close-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  opacity: .85;
  transition: opacity .15s, background .15s;
  line-height: 1;
}
#asernia-minimize-btn:hover,
#asernia-close-btn:hover { opacity: 1; background: rgba(255,255,255,.2); }

/* ── Messaggi ────────────────────────────────────────────── */
#asernia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--asernia-surface);
  scroll-behavior: smooth;
}
#asernia-messages::-webkit-scrollbar { width: 4px; }
#asernia-messages::-webkit-scrollbar-thumb { background: var(--asernia-border); border-radius: 99px; }

.asernia-msg {
  display: flex;
  gap: 8px;
  max-width: 90%;
  animation: aserniaFadeIn .25s ease;
}
@keyframes aserniaFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.asernia-msg.asernia-bot  { align-self: flex-start; }
.asernia-msg.asernia-user { align-self: flex-end; flex-direction: row-reverse; }

.asernia-msg-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--asernia-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 14px;
}
.asernia-msg.asernia-user .asernia-msg-icon { background: #6366f1; }

.asernia-msg-bubble {
  padding: 10px 13px;
  border-radius: var(--asernia-radius-msg);
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.asernia-bot .asernia-msg-bubble {
  background: var(--asernia-bg);
  color: var(--asernia-text);
  border: 1px solid var(--asernia-border);
  border-bottom-left-radius: 4px;
}
.asernia-user .asernia-msg-bubble {
  background: var(--asernia-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.asernia-bot .asernia-msg-bubble strong { font-weight: 700; }
.asernia-bot .asernia-msg-bubble code {
  background: var(--asernia-surface);
  border: 1px solid var(--asernia-border);
  padding: 1px 5px; border-radius: 4px;
  font-family: monospace; font-size: 13px;
}
.asernia-bot .asernia-msg-bubble a { color: var(--asernia-primary); text-decoration: underline; }

/* Typing */
.asernia-typing {
  display: flex; align-items: center; gap: 5px;
  padding: 10px 13px;
  background: var(--asernia-bg);
  border: 1px solid var(--asernia-border);
  border-radius: var(--asernia-radius-msg);
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.asernia-typing span {
  width: 7px; height: 7px;
  background: var(--asernia-text-muted);
  border-radius: 50%;
  animation: aserniaBounce 1.2s ease infinite;
}
.asernia-typing span:nth-child(2) { animation-delay: .2s; }
.asernia-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aserniaBounce {
  0%,60%,100% { transform: translateY(0); opacity:.4; }
  30%          { transform: translateY(-6px); opacity:1; }
}

/* ── Input ───────────────────────────────────────────────── */
#asernia-input-area {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--asernia-border);
  background: var(--asernia-bg);
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#asernia-input {
  flex: 1;
  border: 1.5px solid var(--asernia-border);
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 42px;
  line-height: 1.5;
  color: var(--asernia-text);
  background: var(--asernia-surface);
  transition: border-color .15s;
  box-sizing: border-box;
}
#asernia-input:focus { border-color: var(--asernia-primary); }
#asernia-input::placeholder { color: var(--asernia-text-muted); }

#asernia-send-btn {
  width: 42px; height: 42px; min-width: 42px;
  border-radius: 50%;
  background: var(--asernia-primary);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
#asernia-send-btn:hover { background: var(--asernia-primary-dark); transform: scale(1.05); }
#asernia-send-btn:disabled { opacity:.5; cursor:not-allowed; transform:none; }

/* ── Privacy ─────────────────────────────────────────────── */
#asernia-privacy {
  text-align: center;
  font-size: 11px;
  color: var(--asernia-text-muted);
  padding: 5px 12px 9px;
  background: var(--asernia-bg);
  border-top: 1px solid var(--asernia-border);
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  #asernia-chat-window {
    bottom: 0; right: 0;
    width: 100%; max-width: 100%;
    height: 100%; max-height: 100%;
    border-radius: 0;
  }
  #asernia-toggle-btn { bottom: 16px; right: 16px; }
}
