/* AI Support Chat v3.5.0 */

:root {
  --aisc-color:      #7c3aed;
  --aisc-btn-color:  #7c3aed;
  --aisc-head-color: #ffffff;
  --aisc-sub-color:  #ffffff;
}

#aisc-wrapper * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

#aisc-tooltip {
  position: fixed;
  bottom: 32px;
  right: 92px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.14);
  white-space: nowrap;
  z-index: 99998;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#aisc-tooltip.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  cursor: pointer;
}

#aisc-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--aisc-color);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,0,0,0.24), 0 1px 4px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  transition: transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
}
#aisc-launcher:hover  { transform: scale(1.08); box-shadow: 0 8px 32px rgba(0,0,0,0.28); }
#aisc-launcher:active { transform: scale(0.96); }

#aisc-launcher-logo {
  width: 40px; height: 40px;
  object-fit: cover; border-radius: 50%; display: block;
}
#aisc-launcher-icon { display: flex; align-items: center; justify-content: center; }
#aisc-launcher-icon svg { width: 26px; height: 26px; fill: #fff; }

#aisc-close-icon {
  display: none;
  position: absolute;
  width: 100%; height: 100%;
  align-items: center; justify-content: center;
  background: var(--aisc-color); border-radius: 50%;
}
#aisc-close-icon svg { width: 22px; height: 22px; fill: #fff; }


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

#aisc-panel {
  position: fixed;
  bottom: 92px; right: 24px;
  width: 360px;
  height: min(560px, calc(100vh - 110px));
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.16), 0 4px 16px rgba(0,0,0,0.08);
  z-index: 99997;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9) translateY(12px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.24s cubic-bezier(0.34,1.4,0.64,1), opacity 0.18s ease;
}
#aisc-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1; pointer-events: all;
}

/* ── Screens ──────────────────────────────────────────────────────────────── */

.aisc-screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.aisc-screen.active { display: flex; }

/* ── Powered by footer (shared) ───────────────────────────────────────────── */

.aisc-powered {
  text-align: center;
  font-size: 10.5px;
  color: #b0b7c3;
  padding: 6px 0 10px;
  background: transparent;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}
.aisc-powered a { color: #b0b7c3; text-decoration: none; font-weight: 600; }
.aisc-powered a:hover { color: var(--aisc-color); }

/* close button shared */
.aisc-panel-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: rgba(255,255,255,0.75);
  line-height: 1; padding: 5px 7px; border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.aisc-panel-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ═══════════════════════════════════════════════════════════════════════════
   SCREEN 1 — HOME
═══════════════════════════════════════════════════════════════════════════ */

#aisc-screen-home { background: #f4f6f9; }

#aisc-home-topbar {
  background: var(--aisc-color);
  padding: 14px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#aisc-home-topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
#aisc-home-topbar-av {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  overflow: visible; flex-shrink: 0;
  position: relative;
}
#aisc-home-topbar-dot {
  position: absolute;
  bottom: 0px; right: 0px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #4ade80;
  border: 2px solid var(--aisc-color);
  box-shadow: 0 0 0 1px rgba(74,222,128,0.4);
}
#aisc-home-topbar-name {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

#aisc-home-hero {
  background: var(--aisc-color);
  background-image: linear-gradient(135deg, var(--aisc-color) 0%, color-mix(in srgb, var(--aisc-color) 75%, #000) 100%);
  padding: 14px 20px 44px;
  flex-shrink: 0;
}
#aisc-home-greeting {
  color: var(--aisc-head-color);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 7px;
  letter-spacing: -0.3px;
}
#aisc-home-sub {
  color: var(--aisc-sub-color);
  opacity: 0.88;
  font-size: 13.5px;
  line-height: 1.55;
}

#aisc-home-body {
  flex: 1;
  padding: 0 14px 14px;
  margin-top: -28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* Chat card */
#aisc-chat-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.10);
  margin-top: 8px;
}
#aisc-chat-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,0.14); transform: translateY(-1px); }

#aisc-card-av {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--aisc-color);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
#aisc-card-info { flex: 1; min-width: 0; }
#aisc-card-title {
  font-size: 14px; font-weight: 700; color: #111827;
  margin-bottom: 2px;
}
#aisc-card-sub {
  font-size: 12px; color: #6b7280; line-height: 1.4;
}
#aisc-card-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--aisc-color);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity 0.15s, transform 0.15s;
}
#aisc-card-btn:hover { opacity: 0.85; transform: scale(1.06); }
#aisc-card-btn svg { width: 17px; height: 17px; fill: #fff; }

/* ═══════════════════════════════════════════════════════════════════════════
   SCREEN 2 — EMAIL FORM
═══════════════════════════════════════════════════════════════════════════ */

#aisc-screen-email { background: #fff; }

#aisc-email-topbar {
  padding: 16px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#aisc-email-logo {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--aisc-color);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#aisc-screen-email .aisc-panel-close {
  color: #9ca3af;
  font-size: 20px;
}
#aisc-screen-email .aisc-panel-close:hover { background: #f3f4f6; color: #374151; }

#aisc-email-body {
  flex: 1;
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
}
#aisc-email-heading {
  font-size: 19px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
  line-height: 1.3;
}
#aisc-email-subtext {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 20px;
  line-height: 1.5;
}
#aisc-email-input {
  width: 100%;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 14px;
  font-family: inherit;
  color: #1f2937;
  background: #fafafa;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 6px;
}
#aisc-email-input::placeholder { color: #9ca3af; }
#aisc-email-input:focus { border-color: var(--aisc-color); background: #fff; }

#aisc-email-error {
  font-size: 12px; color: #ef4444;
  min-height: 18px; margin-bottom: 12px;
}
#aisc-email-submit {
  width: 100%;
  background: var(--aisc-btn-color, var(--aisc-color));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
  letter-spacing: 0.01em;
}
#aisc-email-submit:hover  { opacity: 0.88; }
#aisc-email-submit:active { transform: scale(0.98); }

#aisc-screen-email .aisc-powered { background: #fff; }

/* ═══════════════════════════════════════════════════════════════════════════
   SCREEN 3 — CHAT
═══════════════════════════════════════════════════════════════════════════ */

#aisc-screen-chat { background: #f4f6f9; }

#aisc-chat-header {
  background: var(--aisc-color);
  background-image: linear-gradient(135deg, var(--aisc-color) 0%, color-mix(in srgb, var(--aisc-color) 75%, #000) 100%);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#aisc-back-btn {
  background: none; border: none; cursor: pointer;
  padding: 5px; border-radius: 7px;
  display: flex; align-items: center;
  transition: background 0.15s; flex-shrink: 0;
}
#aisc-back-btn:hover { background: rgba(255,255,255,0.15); }

#aisc-chat-header-av {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
#aisc-chat-header-info { flex: 1; min-width: 0; }
#aisc-chat-bot-name {
  color: #fff; font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#aisc-chat-status {
  color: rgba(255,255,255,0.75); font-size: 11px;
  display: flex; align-items: center; gap: 5px; margin-top: 2px;
}
#aisc-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
  display: inline-block;
}

/* Messages */
#aisc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  min-height: 0;
}
#aisc-messages::-webkit-scrollbar { width: 4px; }
#aisc-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.aisc-msg { display: flex; align-items: flex-end; gap: 8px; animation: aiscIn 0.2s ease-out both; }
@keyframes aiscIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.aisc-msg.user { flex-direction: row-reverse; }

.aisc-av {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; overflow: hidden;
}
.aisc-msg.bot  .aisc-av { background: var(--aisc-color); }
.aisc-msg.user .aisc-av { background: var(--aisc-color); }
.aisc-av img  { width: 28px; height: 28px; object-fit: cover; border-radius: 50%; display: block; }
.aisc-av svg  { display: block; }

.aisc-bubble {
  max-width: 76%;
  padding: 6px 2px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}
.aisc-msg.bot  .aisc-bubble {
  background: none;
  color: #1f2937;
}
.aisc-msg.user .aisc-bubble {
  background: none;
  color: #374151;
  text-align: right;
}
.aisc-msg.escalated .aisc-bubble {
  color: #991b1b;
}
.aisc-escalate-tag {
  display: block; margin-top: 6px;
  font-size: 11.5px; font-weight: 500;
  color: #6b7280;
}

/* Typing dots */
#aisc-typing {
  display: none; align-items: flex-end; gap: 8px;
  animation: aiscIn 0.2s ease-out both;
}
#aisc-typing .aisc-av { background: var(--aisc-color); overflow: hidden; }
.aisc-typing-dots {
  background: none;
  padding: 6px 2px; display: flex; gap: 4px;
}
.aisc-typing-dots span {
  display: block; width: 6px; height: 6px;
  background: #9ca3af; border-radius: 50%;
  animation: aiscBounce 1.2s infinite ease-in-out;
}
.aisc-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.aisc-typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes aiscBounce { 0%,60%,100% { transform:translateY(0); } 30% { transform:translateY(-5px); } }

/* Input row */
#aisc-input-row {
  padding: 10px 12px;
  border-top: 1px solid #e9ecf0;
  display: flex; gap: 8px; align-items: center;
  background: #fff; flex-shrink: 0;
}
#aisc-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 22px;
  padding: 10px 15px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: #f7f8fa;
  color: #1f2937;
  transition: border-color 0.2s, background 0.2s;
  min-width: 0;
}
#aisc-input::placeholder { color: #9ca3af; }
#aisc-input:focus { border-color: var(--aisc-color); background: #fff; }
#aisc-send {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--aisc-btn-color, var(--aisc-color));
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
#aisc-send:hover:not(:disabled)  { opacity: 0.85; transform: scale(1.06); }
#aisc-send:active:not(:disabled) { transform: scale(0.94); }
#aisc-send:disabled { opacity: 0.35; cursor: not-allowed; }
#aisc-send svg { fill: #fff; width: 15px; height: 15px; }

#aisc-screen-chat .aisc-powered { background: #fff; border-top: none; }

/* ── Widget position variants ─────────────────────────────────────────────── */

/* Bottom Left */
[data-aisc-pos="bottom-left"] #aisc-launcher {
  right: auto; left: 24px;
}
[data-aisc-pos="bottom-left"] #aisc-panel {
  right: auto; left: 24px;
  transform-origin: bottom left;
}
[data-aisc-pos="bottom-left"] #aisc-tooltip {
  right: auto; left: 92px;
  transform: translateX(-8px);
}
[data-aisc-pos="bottom-left"] #aisc-tooltip.visible {
  transform: translateX(0);
}

/* Bottom Center */
[data-aisc-pos="bottom-center"] #aisc-launcher {
  right: auto; left: 50%; transform: translateX(-50%);
}
[data-aisc-pos="bottom-center"] #aisc-launcher:hover {
  transform: translateX(-50%) scale(1.08);
}
[data-aisc-pos="bottom-center"] #aisc-launcher:active {
  transform: translateX(-50%) scale(0.96);
}
[data-aisc-pos="bottom-center"] #aisc-panel {
  right: auto; left: 50%;
  transform: translateX(-50%) scale(0.9) translateY(12px);
  transform-origin: bottom center;
}
[data-aisc-pos="bottom-center"] #aisc-panel.open {
  transform: translateX(-50%) scale(1) translateY(0);
}
[data-aisc-pos="bottom-center"] #aisc-tooltip {
  right: auto; left: 50%; transform: translateX(calc(-50% + 8px));
}
[data-aisc-pos="bottom-center"] #aisc-tooltip.visible {
  transform: translateX(-50%);
}

/* Right Center */
[data-aisc-pos="right-center"] #aisc-launcher {
  bottom: auto; top: 50%; transform: translateY(-50%);
}
[data-aisc-pos="right-center"] #aisc-launcher:hover {
  transform: translateY(-50%) scale(1.08);
}
[data-aisc-pos="right-center"] #aisc-launcher:active {
  transform: translateY(-50%) scale(0.96);
}
[data-aisc-pos="right-center"] #aisc-panel {
  bottom: auto; top: 50%; right: 92px;
  transform: translateY(-50%) scale(0.9);
  transform-origin: right center;
}
[data-aisc-pos="right-center"] #aisc-panel.open {
  transform: translateY(-50%) scale(1);
}
[data-aisc-pos="right-center"] #aisc-tooltip {
  bottom: auto; top: 50%;
  transform: translateX(8px) translateY(-50%);
}
[data-aisc-pos="right-center"] #aisc-tooltip.visible {
  transform: translateX(0) translateY(-50%);
}

/* Left Center */
[data-aisc-pos="left-center"] #aisc-launcher {
  right: auto; left: 24px; bottom: auto; top: 50%; transform: translateY(-50%);
}
[data-aisc-pos="left-center"] #aisc-launcher:hover {
  transform: translateY(-50%) scale(1.08);
}
[data-aisc-pos="left-center"] #aisc-launcher:active {
  transform: translateY(-50%) scale(0.96);
}
[data-aisc-pos="left-center"] #aisc-panel {
  right: auto; left: 92px; bottom: auto; top: 50%;
  transform: translateY(-50%) scale(0.9);
  transform-origin: left center;
}
[data-aisc-pos="left-center"] #aisc-panel.open {
  transform: translateY(-50%) scale(1);
}
[data-aisc-pos="left-center"] #aisc-tooltip {
  right: auto; left: 92px; bottom: auto; top: 50%;
  transform: translateX(-8px) translateY(-50%);
}
[data-aisc-pos="left-center"] #aisc-tooltip.visible {
  transform: translateX(0) translateY(-50%);
}

/* ── Tablet ───────────────────────────────────────────────────────────────── */

@media (max-width: 1024px) and (min-width: 481px) {
  #aisc-panel { width: 340px; }
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  #aisc-launcher { bottom: 16px; right: 16px; width: 52px; height: 52px; }
  #aisc-launcher-logo { width: 36px; height: 36px; }
  #aisc-badge { bottom: 57px; right: 12px; }

  #aisc-panel {
    width: calc(100vw - 24px);
    right: 12px; bottom: 78px;
    height: calc(100vh - 100px);
    max-height: 560px;
    border-radius: 18px;
  }

  #aisc-home-greeting { font-size: 21px; }
  .aisc-bubble { max-width: 82%; font-size: 13px; padding: 10px 13px; }
  #aisc-input { font-size: 16px; }
}

@media (max-width: 360px) {
  #aisc-panel { width: calc(100vw - 16px); right: 8px; max-height: 520px; }
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #aisc-panel, #aisc-launcher, #aisc-badge, .aisc-msg { transition: none; animation: none; }
  .aisc-typing-dots span { animation: none; }
}
