/* ==========================================================================
   AMICO CHAT — Site-wide assistant widget
   Uses design tokens from main.css; works in light & dark themes
   ========================================================================== */

.amico-chat {
  --ac-accent: var(--brand, #f75622);
  --ac-accent-dark: var(--brand-hover, #d6431a);
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  font-family: var(--font-sans, 'Inter', sans-serif);
}

/* ── Launcher button ─────────────────────────────────────────────────── */

.ac-launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: var(--text, #2a2825);
  color: var(--bg, #fafaf8);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.4);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}

.ac-launcher:hover { transform: scale(1.07); background: var(--ac-accent-dark); }
.ac-launcher:active { transform: scale(0.96); }

.ac-launcher svg { width: 26px; height: 26px; transition: opacity 0.25s ease, transform 0.25s ease; }
.ac-launcher .ac-ico-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(0.6); }

.amico-chat.open .ac-ico-chat { opacity: 0; transform: rotate(90deg) scale(0.6); }
.amico-chat.open .ac-ico-close { opacity: 1; transform: rotate(0) scale(1); }

/* Attention ping */
.ac-ping {
  position: absolute;
  top: -3px; right: -3px;
  width: 16px; height: 16px;
  background: var(--ac-accent);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg, #fafaf8);
}
.amico-chat.open .ac-ping { display: none; }

/* ── Panel ───────────────────────────────────────────────────────────── */

.ac-panel {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: min(380px, calc(100vw - 40px));
  height: min(560px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  background: var(--bg, #fafaf8);
  border: 1px solid var(--border-med, rgba(0,0,0,0.12));
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.amico-chat.open .ac-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.ac-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: var(--text, #2a2825);
  color: var(--bg, #fafaf8);
}

.ac-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--ac-accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif, serif);
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.ac-head-text strong { display: block; font-size: 15px; font-weight: 600; line-height: 1.2; }
.ac-head-text span { font-size: 12px; opacity: 0.7; display: flex; align-items: center; gap: 6px; }
.ac-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }

/* Messages */
.ac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-alt, #f5f0eb);
  scroll-behavior: smooth;
}

.ac-msg {
  max-width: 84%;
  padding: 11px 15px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 14px;
  animation: acIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes acIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.ac-msg-bot {
  align-self: flex-start;
  background: var(--bg, #fff);
  color: var(--text, #2a2825);
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  border-bottom-left-radius: 4px;
}

.ac-msg-user {
  align-self: flex-end;
  background: var(--ac-accent-dark);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ac-msg a { color: var(--ac-accent-dark); font-weight: 500; text-decoration: underline; }
.ac-msg-user a { color: #fff; }

/* Typing indicator */
.ac-typing { display: inline-flex; gap: 4px; align-items: center; }
.ac-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted, #999);
  animation: acBlink 1.2s infinite ease-in-out;
}
.ac-typing span:nth-child(2) { animation-delay: 0.2s; }
.ac-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes acBlink { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Quick-reply chips */
.ac-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 14px;
  background: var(--bg-alt, #f5f0eb);
}

.ac-chip {
  border: 1px solid var(--ac-accent);
  background: transparent;
  color: var(--ac-accent-dark);
  font-family: inherit;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
  white-space: nowrap;
}

.ac-chip:hover { background: var(--ac-accent); color: #fff; }

/* Input */
.ac-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg, #fafaf8);
  border-top: 1px solid var(--border, rgba(0,0,0,0.08));
}

.ac-input {
  flex: 1;
  border: 1px solid var(--border-med, rgba(0,0,0,0.12));
  background: var(--bg-alt, #f5f0eb);
  color: var(--text, #2a2825);
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 100px;
  outline: none;
  transition: border-color 0.25s ease;
}
.ac-input::placeholder { color: var(--text-muted, #999); }
.ac-input:focus { border-color: var(--ac-accent); }

.ac-send {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--ac-accent-dark);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease, background 0.25s ease;
}
.ac-send:hover { background: var(--text, #2a2825); transform: scale(1.06); }
.ac-send:disabled { opacity: 0.45; cursor: default; transform: none; }

.ac-foot {
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text-muted, #999);
  padding: 0 16px 12px;
  background: var(--bg, #fafaf8);
}
.ac-foot a { color: var(--text-muted, #999); text-decoration: underline; }

/* Mobile */
@media (max-width: 480px) {
  .amico-chat { bottom: 18px; right: 18px; }
  .ac-panel {
    bottom: 74px;
    width: calc(100vw - 28px);
    height: min(72vh, 540px);
    right: -4px;
  }
}

/* On small screens the launcher shrinks to bottom:18px; keep the theme
   toggle stacked just above it so the two never overlap. */
@media (max-width: 480px) {
  .theme-toggle { bottom: 88px; right: 24px; }
}
