/* ─────────────────────────────────────────────────────────────────────────────
   Magic Fabric AI Chat — widget styles
   All rules scoped under #aiChatApp.
───────────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

@font-face {
  font-family: 'ClashDisplay-Variable';
  src: url('ClashDisplay-Variable.woff2') format('woff2'),
       url('ClashDisplay-Variable.woff')  format('woff'),
       url('ClashDisplay-Variable.ttf')   format('truetype');
  font-weight: 200 700;
  font-style: normal;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
#aiChatApp *,
#aiChatApp *::before,
#aiChatApp *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#aiChatApp {
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

/* ── Launcher ──────────────────────────────────────────────────────────────── */
/* Launcher hidden — chat is opened via URL link */
#aiChatApp .ac-launcher {
  display: none;
}

/* ── Chat window ───────────────────────────────────────────────────────────── */
#aiChatApp .ac-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 780px;
  height: 600px;
  background: #060608;
  border: 1px solid rgba(248, 248, 248, 0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  box-shadow: 0 8px 64px rgba(0, 0, 0, 0.85);
}
#aiChatApp .ac-window.ac-window--open {
  display: flex;
}

/* ── Intro screen ──────────────────────────────────────────────────────────── */
#aiChatApp .ac-intro {
  flex: 1;
  background: #060608;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}


/* Close button on intro screen */
#aiChatApp .ac-intro-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  z-index: 2;
  transition: opacity 0.2s;
  opacity: 0.9;
}
#aiChatApp .ac-intro-close:hover { opacity: 1; }

/* Diffusion canvas — fills the intro, sits behind content */
#aiChatApp .ac-diffusion {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#aiChatApp .ac-intro-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding: 2rem;
  text-align: center;
}

#aiChatApp .ac-intro-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(248, 248, 248, 0.12);
  flex-shrink: 0;
}
#aiChatApp .ac-intro-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#aiChatApp .ac-intro-title {
  font-size: 15px;
  font-weight: 500;
  color: rgba(248, 248, 248, 0.9);
  letter-spacing: 0.01em;
}

#aiChatApp .ac-intro-sub {
  font-size: 12px;
  font-weight: 300;
  color: rgba(248, 248, 248, 0.4);
  line-height: 1.65;
  max-width: 300px;
}

/* Consent checkbox */
#aiChatApp .ac-consent {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 11px;
  font-weight: 300;
  color: rgba(248, 248, 248, 0.45);
  line-height: 1.55;
  max-width: 300px;
  cursor: pointer;
}
#aiChatApp .ac-consent input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: #29fb9c;
  width: 13px;
  height: 13px;
  cursor: pointer;
}
#aiChatApp .ac-consent a {
  color: rgba(248, 248, 248, 0.6);
  text-decoration: underline;
  text-underline-offset: 2px;
}
#aiChatApp .ac-consent a:hover {
  color: rgba(248, 248, 248, 0.9);
}

/* Face cloud canvas */
#aiChatApp .ac-face {
  display: block;
  width: 320px;
  max-width: 100%;
  height: 320px;
  margin-bottom: -0.6rem;
}

/* Emi title in Clash Display */
#aiChatApp .ac-intro-title {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif !important;
  font-size: 18px !important;
  font-weight: 500 !important;
  letter-spacing: 0.03em !important;
}

#aiChatApp .ac-start-btn {
  background: transparent;
  border: 1px solid rgba(248, 248, 248, 0.35);
  border-radius: 2px;
  padding: 0.55rem 1.5rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(248, 248, 248, 0.7);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, opacity 0.2s;
  margin-top: 0.4rem;
}
#aiChatApp .ac-start-btn:hover:not(:disabled) {
  border-color: rgba(248, 248, 248, 0.8);
  color: rgba(248, 248, 248, 0.95);
}
#aiChatApp .ac-start-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Chat screen ───────────────────────────────────────────────────────────── */
#aiChatApp .ac-chat {
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* Header */
#aiChatApp .ac-header {
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid rgba(248, 248, 248, 0.08);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-shrink: 0;
}
#aiChatApp .ac-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
#aiChatApp .ac-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#aiChatApp .ac-header-text { flex: 1; }
#aiChatApp .ac-header-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(248, 248, 248, 0.9);
  letter-spacing: 0.01em;
}
#aiChatApp .ac-header-status {
  font-size: 11px;
  color: rgba(248, 248, 248, 0.35);
  margin-top: 2px;
}
#aiChatApp .ac-close-btn {
  background: none;
  border: none;
  color: rgba(248, 248, 248, 0.85);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  line-height: 1;
  transition: opacity 0.2s;
}
#aiChatApp .ac-close-btn:hover { opacity: 0.6; }

/* Messages */
#aiChatApp .ac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.4rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
#aiChatApp .ac-messages::-webkit-scrollbar { width: 3px; }
#aiChatApp .ac-messages::-webkit-scrollbar-track { background: transparent; }
#aiChatApp .ac-messages::-webkit-scrollbar-thumb {
  background: rgba(248, 248, 248, 0.12);
  border-radius: 2px;
}

#aiChatApp .ac-msg-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}
#aiChatApp .ac-msg-row--user { flex-direction: row-reverse; }

#aiChatApp .ac-msg-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
#aiChatApp .ac-msg-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#aiChatApp .ac-msg-av--user {
  background: #f0ece6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 500;
  color: #0a0a0a;
  border-radius: 50%;
}

#aiChatApp .ac-msg {
  max-width: 72%;
  padding: 0.65rem 0.9rem;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 300;
}
#aiChatApp .ac-msg--bot {
  background: rgba(248, 248, 248, 0.05);
  border: 1px solid rgba(248, 248, 248, 0.1);
  border-radius: 18px 18px 18px 4px;
  color: rgba(248, 248, 248, 0.82);
}
#aiChatApp .ac-msg--user {
  background: #29fb9c;
  border: 1px solid #29fb9c;
  border-radius: 18px 18px 4px 18px;
  color: #000;
}

/* Typing indicator */
#aiChatApp .ac-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.65rem 0.9rem;
  background: rgba(248, 248, 248, 0.05);
  border: 1px solid rgba(248, 248, 248, 0.1);
  border-radius: 18px 18px 18px 4px;
}
#aiChatApp .ac-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(248, 248, 248, 0.3);
  animation: acBlink 1.2s infinite;
}
#aiChatApp .ac-typing span:nth-child(2) { animation-delay: 0.2s; }
#aiChatApp .ac-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes acBlink {
  0%, 80%, 100% { opacity: 0.3; }
  40%           { opacity: 1;   }
}

/* Input area */
#aiChatApp .ac-input-area {
  border-top: 1px solid rgba(248, 248, 248, 0.08);
  padding: 0.9rem 1rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-shrink: 0;
}
#aiChatApp .ac-input {
  flex: 1;
  background: rgba(248, 248, 248, 0.04);
  border: 1px solid rgba(248, 248, 248, 0.12);
  border-radius: 2px;
  padding: 0.55rem 0.8rem;
  color: #f8f8f8;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 300;
  outline: none;
  transition: border-color 0.2s;
}
#aiChatApp .ac-input::placeholder { color: rgba(248, 248, 248, 0.3); }
#aiChatApp .ac-input:focus { border-color: rgba(248, 248, 248, 0.3); }
#aiChatApp .ac-input:disabled { opacity: 0.5; cursor: not-allowed; }

#aiChatApp .ac-send-btn {
  background: #f0ece6;
  border: none;
  border-radius: 2px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
#aiChatApp .ac-send-btn:hover  { background: #fff; }
#aiChatApp .ac-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#aiChatApp .ac-send-btn svg {
  width: 14px;
  height: 14px;
  fill: #0a0a0a;
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  #aiChatApp .ac-window {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    transform: none;
    border: none;
    overscroll-behavior: none;
  }
  #aiChatApp .ac-intro-close {
    top: 1.2rem;
    right: 1.2rem;
    font-size: 22px;
    opacity: 1;
    text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  }
  #aiChatApp .ac-messages {
    overscroll-behavior: contain;
  }
}
