/**
 * Web Techiq AI Chat & Live Support Frontend Styles
 *
 * Glassmorphic floating chat widget, fully responsive across desktop, tablet, and mobile.
 *
 * @package Web_Techiq_Official
 * @version 2.4.0
 */

/* ── 1. FLOATING ACTION TRIGGER BUTTON ───────────────────────────────── */
.wt-ai-chat-root {
  position: fixed;
  right: 20px;       /* Aligned with .wt-float-lang-wrap: right: 20px */
  bottom: 78px;      /* Stacked above language button (20px base + 46px btn + 12px gap = 78px) */
  z-index: 99995;    /* Above standard page content */
  font-family: inherit;
  box-sizing: border-box;
  transition: bottom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.wt-ai-chat-root.has-lang-float {
  bottom: 78px;
}

.wt-ai-chat-root.no-lang-float {
  bottom: 20px;
}

.wt-ai-chat-root * {
  box-sizing: border-box;
}

.wt-ai-trigger-btn {
  position: relative;
  width: 46px;       /* matches .wt-lang-toggle-btn: width:46px */
  height: 46px;      /* matches .wt-lang-toggle-btn: height:46px */
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b00 0%, #ff8e00 100%);
  border: 1.5px solid rgba(255, 230, 179, 0.5); /* matches .wt-lang-toggle-btn border */
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 107, 0, 0.45), 0 0 0 0 rgba(255, 107, 0, 0.4);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  padding: 0;
}

.wt-ai-trigger-btn:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 107, 0, 0.55);
}

.wt-ai-trigger-btn:active {
  transform: scale(0.96);
}

.wt-ai-trigger-icon-open,
.wt-ai-trigger-icon-close {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.wt-ai-trigger-badge-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.wt-ai-trigger-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(255, 107, 0, 0.6);
  animation: wtAiPulse 2.5s infinite;
  pointer-events: none;
}

@keyframes wtAiPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(0.95); opacity: 0; }
}

/* ── 2. CHAT WINDOW MODAL ────────────────────────────────────────────── */
.wt-ai-window {
  position: fixed;
  right: 20px;
  bottom: 78px;      /* 20px (base) + 46px (btn) + 12px (gap) */
  width: 388px;
  height: 580px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 110px);
  background: #0d1526;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 20px;
  box-shadow:
    0 28px 64px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 107, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: wtAiSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.wt-ai-chat-root.no-lang-float .wt-ai-window {
  bottom: 20px;
  max-height: calc(100vh - 50px);
}

@keyframes wtAiSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── 3. HEADER (RESPONSIVE & CLEAN) ──────────────────────────────────── */
.wt-ai-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 10px;
  flex-shrink: 0;
}

.wt-ai-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.wt-ai-avatar-ring {
  position: relative;
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 107, 0, 0.25) 0%, rgba(255, 142, 0, 0.35) 100%);
  border: 1.5px solid rgba(255, 107, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.wt-ai-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #0f172a;
  border-radius: 50%;
}

.wt-ai-header-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.wt-ai-header-name {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wt-ai-header-status {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.wt-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wt-ai-btn-reset {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  cursor: pointer;
  padding: 5px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: all 0.2s ease;
  outline: none;
}

.wt-ai-btn-reset:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  transform: rotate(180deg);
}

.wt-ai-btn-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  outline: none;
}

.wt-ai-btn-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

/* ── 4. MESSAGES BODY ────────────────────────────────────────────────── */
.wt-ai-messages-body {
  flex: 1 1 0;
  min-height: 0;
  padding: 18px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.wt-ai-messages-body::-webkit-scrollbar {
  width: 5px;
}

.wt-ai-messages-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* Single Message Container */
.wt-msg-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: wtMsgFade 0.25s ease forwards;
}

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

.wt-msg-visitor {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.wt-msg-ai,
.wt-msg-admin {
  align-self: flex-start;
}

.wt-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.wt-msg-visitor .wt-msg-bubble {
  background: linear-gradient(135deg, #ff6b00 0%, #ff8e00 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(255, 107, 0, 0.25);
}

.wt-msg-ai .wt-msg-bubble {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
}

.wt-msg-admin .wt-msg-bubble {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #f8fafc;
  border: 1px solid rgba(255, 107, 0, 0.4);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(255, 107, 0, 0.15);
}

.wt-msg-admin-badge {
  display: inline-block;
  background: #ff6b00;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.wt-msg-system {
  align-self: center;
  max-width: 94%;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 16px;
  border-radius: 12px;
  text-align: center;
  margin: 4px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Grounding Source Pills */
.wt-sources-wrap {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wt-source-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #ff8e00;
  background: rgba(255, 107, 0, 0.12);
  border: 1px solid rgba(255, 107, 0, 0.3);
  padding: 3px 8px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.wt-source-pill:hover {
  background: #ff6b00;
  color: #ffffff;
}

/* Quick Action Suggestion Chips */
.wt-ai-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 0;
}

.wt-ai-quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 107, 0, 0.08);
  border: 1px solid rgba(255, 107, 0, 0.28);
  color: #ff8e00;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  outline: none;
}

.wt-ai-quick-chip:hover {
  background: #ff6b00;
  color: #ffffff;
  border-color: #ff6b00;
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(255, 107, 0, 0.3);
}

.wt-ai-quick-chip:active {
  transform: scale(0.96);
}

/* Typing Indicator */
.wt-ai-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #1e293b;
  padding: 10px 14px;
  border-radius: 14px;
  align-self: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.wt-typing-dot {
  width: 6px;
  height: 6px;
  background: #ff6b00;
  border-radius: 50%;
  animation: wtTyping 1.4s infinite ease-in-out;
}

.wt-typing-dot:nth-child(1) { animation-delay: 0s; }
.wt-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.wt-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes wtTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── 6. FOOTER INPUT ─────────────────────────────────────────────────── */
.wt-ai-window-footer {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.wt-ai-chat-form {
  display: flex;
  align-items: center;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 4px 6px 4px 12px;
  transition: border-color 0.2s ease;
}

.wt-ai-chat-form:focus-within {
  border-color: #ff6b00;
  box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.2);
}

#wt-ai-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #f8fafc;
  font-size: 13.5px;
  resize: none;
  outline: none;
  padding: 6px 0;
  max-height: 80px;
  line-height: 1.4;
  font-family: inherit;
}

#wt-ai-chat-input::placeholder {
  color: #64748b;
}

.wt-ai-send-btn {
  background: linear-gradient(135deg, #ff6b00 0%, #ff8e00 100%);
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  padding: 0;
  flex-shrink: 0;
}

.wt-ai-send-btn:hover {
  transform: scale(1.05);
}

.wt-ai-send-btn:active {
  transform: scale(0.95);
}

/* ── 6. PROFESSIONAL FOOTER BADGE ────────────────────────────────────── */
.wt-ai-footer-note {
  text-align: center;
  font-size: 10px;
  color: #64748b;
  margin-top: 6px;
}

.wt-ai-branding-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 8px;
  padding: 5px 14px 6px;
  background: rgba(255, 107, 0, 0.05);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 0 0 20px 20px;
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  letter-spacing: 0.3px;
  line-height: 1;
  font-family: var(--wt-heading-font-family, 'Outfit', sans-serif);
  transition: color 0.2s ease;
}

.wt-ai-branding-badge svg {
  opacity: 0.7;
  flex-shrink: 0;
  color: #ff6b00;
}

.wt-ai-branding-badge span {
  opacity: 0.7;
}

.wt-ai-badge-sep {
  opacity: 0.35;
  font-size: 13px;
  line-height: 1;
}

.wt-ai-branding-badge:hover span,
.wt-ai-branding-badge:hover svg {
  opacity: 1;
  color: #ff8e00;
}

/* ── 7. RESPONSIVE BREAKPOINTS (DESKTOP, TABLET & MOBILE) ─────────────── */

/* Tablet (481px to 768px) */
@media screen and (min-width: 481px) and (max-width: 768px) {
  .wt-ai-chat-root {
    right: 16px;
    bottom: 74px;
  }
  .wt-ai-chat-root.no-lang-float {
    bottom: 16px;
  }
  .wt-ai-window {
    right: 14px;
    bottom: 74px;
    width: 360px;
    height: 520px;
    max-height: calc(100vh - 100px);
    border-radius: 18px;
  }
  .wt-ai-chat-root.no-lang-float .wt-ai-window {
    bottom: 16px;
    max-height: calc(100vh - 40px);
  }
}

/* Mobile Screens (<= 480px) — Fullscreen Native App Experience */
@media screen and (max-width: 480px) {
  .wt-ai-chat-root {
    right: 16px;
    bottom: 70px;
  }
  
  .wt-ai-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    z-index: 999999;
  }

  .wt-ai-window-header {
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .wt-ai-avatar-ring {
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 16px;
  }

  .wt-ai-header-name {
    font-size: 13.5px;
  }

  .wt-ai-header-status {
    font-size: 10.5px;
  }

  .wt-ai-messages-body {
    padding: 14px 12px;
  }

  .wt-msg-row {
    max-width: 92%;
  }

  .wt-ai-window-footer {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  #wt-ai-chat-input {
    font-size: 14px;
  }
}
