/**
 * AisoStudio Chatbot Widget Styles
 * WCAG 2.1 AA compliant
 */

/* ── Toggle Button ─────────────────────────── */

.aiso-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: background 0.2s, transform 0.1s;
  min-height: 48px;
}

.aiso-chat-toggle:hover {
  background: #333;
  transform: translateY(-1px);
}

.aiso-chat-toggle:focus-visible {
  outline: 3px solid var(--aiso-primary, #0f766e);
  outline-offset: 2px;
}

@keyframes aisoChatPulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); }
  50% { box-shadow: 0 4px 20px rgba(15, 118, 110, 0.5); }
}

.aiso-chat-pulse {
  animation: aisoChatPulse 2s ease-in-out 3;
}

/* ── Chat Window ───────────────────────────── */

.aiso-chat-window {
  position: fixed;
  bottom: 88px;
  right: 24px;
  z-index: 10001;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.aiso-chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.aiso-chat-window[aria-hidden="true"] {
  display: flex;
}

/* ── Header ────────────────────────────────── */

.aiso-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--aiso-primary, #0f766e);
  color: #fff;
  flex-shrink: 0;
}

.aiso-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.aiso-chat-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aiso-chat-header-name {
  font-weight: 700;
  font-size: 15px;
}

.aiso-chat-header-status {
  font-size: 12px;
  opacity: 0.8;
}

.aiso-chat-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aiso-chat-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.aiso-chat-close:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ── Messages ──────────────────────────────── */

.aiso-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.aiso-chat-msg {
  display: flex;
  max-width: 85%;
}

.aiso-chat-msg-user {
  align-self: flex-end;
}

.aiso-chat-msg-bot {
  align-self: flex-start;
}

.aiso-chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: #111827;
  word-wrap: break-word;
}

.aiso-chat-msg-user .aiso-chat-bubble {
  background: var(--aiso-primary, #0f766e);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.aiso-chat-msg-bot .aiso-chat-bubble {
  background: #f3f4f6;
  color: #111827;
  border-bottom-left-radius: 4px;
}

/* ── Typing Indicator ──────────────────────── */

.aiso-chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.aiso-chat-typing span {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: aisoChatDot 1.4s ease-in-out infinite;
}

.aiso-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.aiso-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aisoChatDot {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Input Form ────────────────────────────── */

.aiso-chat-form {
  display: flex;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}

.aiso-chat-form input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: #111827;
  background: #fff;
  min-height: 44px;
}

.aiso-chat-form input:focus {
  outline: none;
  border-color: var(--aiso-primary, #0f766e);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.aiso-chat-form input::placeholder {
  color: #6b7280;
}

.aiso-chat-form button {
  background: var(--aiso-primary, #0f766e);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.aiso-chat-form button:hover {
  background: var(--aiso-primary-hover, #115e59);
}

.aiso-chat-form button:focus-visible {
  outline: 3px solid var(--aiso-primary, #0f766e);
  outline-offset: 2px;
}


/* ── Lottie Toggle Button ──────────────────── */

.aiso-chat-toggle-lottie {
  padding: 6px 16px 6px 6px;
  gap: 4px;
  background: #fff;
  color: #1a1a1a;
  border: 2px solid #e5e7eb;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.aiso-chat-toggle-lottie:hover {
  background: #fff;
  border-color: var(--aiso-primary, #0f766e);
  box-shadow: 0 6px 20px rgba(15, 118, 110, 0.2);
}

.aiso-chat-toggle-lottie .aiso-chat-toggle-label {
  color: #1a1a1a;
  font-weight: 700;
}

@keyframes aisoChatPulseLottie {
  0%, 100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); }
  50% { box-shadow: 0 4px 24px rgba(15, 118, 110, 0.35); border-color: var(--aiso-primary, #0f766e); }
}

.aiso-chat-toggle-lottie.aiso-chat-pulse {
  animation: aisoChatPulseLottie 2s ease-in-out 3;
}

.aiso-chat-avatar lottie-player {
  display: block;
}

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

@media (max-width: 480px) {
  .aiso-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .aiso-chat-toggle-label {
    display: none;
  }

  .aiso-chat-toggle {
    padding: 14px;
    border-radius: 50%;
  }
}

/* ── Hide toggle when sticky phone is visible (mobile) ── */
@media (max-width: 768px) {
  .aiso-chat-toggle {
    bottom: 80px;
  }
}
