/* AP Product AI Sales — Chat UI (v3) */
/* Minimal, production-ready styles */

/* =========================
   GLOBAL RESET & BASE
   ========================= */

.apais-overlay,
.apais-window,
.apais-support-launcher {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  line-height: 1.5;
}

.apais-overlay *,
.apais-window *,
.apais-support-launcher * {
  box-sizing: border-box;
}

/* =========================
   Z-INDEX (Above everything)
   ========================= */

.apais-overlay,
.apais-window,
.apais-support-launcher {
  z-index: 2147483000 !important; /* Max safe z-index */
}

/* =========================
   MODAL OVERLAY (Product Chat)
   ========================= */

.apais-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: rgba(0, 0, 0, 0.55);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
}

/* =========================
   CHAT WINDOW
   ========================= */

.apais-window {
  position: relative;
  width: min(560px, 96vw);
  max-height: min(78vh, 720px);
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(0, 0, 0, 0.10);
}

/* Floating support window */
.apais-window--floating {
  position: fixed !important;
  right: 18px !important;
  bottom: 88px !important;
  width: min(420px, 94vw);
  max-height: min(70vh, 680px);
}

/* =========================
   HEADER
   ========================= */

.apais-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #111;
  color: #fff;
  flex-shrink: 0;
}

.apais-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1.2;
  margin: 0;
}

.apais-close {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 36px;
  height: 32px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  font-weight: 900;
  padding: 0;
  transition: background 0.2s;
}

.apais-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* =========================
   SUBHEADER (Product info)
   ========================= */

.apais-subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #111;
  color: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.apais-subheader a {
  color: #fff;
  text-decoration: underline;
  font-size: 13px;
  opacity: 0.95;
}

.apais-subheader a:hover {
  opacity: 1;
}

/* =========================
   BODY (Messages container)
   ========================= */

.apais-body {
  flex: 1;
  overflow: hidden;
  background: #f6f7f8;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.apais-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Scrollbar styling */
.apais-messages::-webkit-scrollbar { width: 8px; }
.apais-messages::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.05); }
.apais-messages::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.2); border-radius: 4px; }
.apais-messages::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.3); }

/* =========================
   TYPING INDICATOR
   ========================= */

.apais-typing {
  padding: 10px 14px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.55);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: none;
  flex-shrink: 0;
}

/* =========================
   MESSAGE BUBBLES
   ========================= */

.apais-msg { display: flex; flex-direction: column; gap: 8px; }
.apais-msg--user { align-items: flex-end; }
.apais-msg--assistant,
.apais-msg--manager { align-items: flex-start; }

.apais-bubble {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.35;
  font-size: 14px;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.apais-msg--user .apais-bubble {
  background: #111;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.10);
}

.apais-msg--assistant .apais-bubble {
  background: #f6f7f9;
  color: #111;
}

.apais-msg--manager .apais-bubble {
  background: #fff7e6;
  color: #111;
  border-color: rgba(0, 0, 0, 0.10);
}

.apais-bubble a { color: inherit; text-decoration: underline; }
.apais-bubble a:hover { opacity: 0.8; }

.apais-bubble code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.06);
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
}

/* =========================
   FOOTER (Input area)
   ========================= */

.apais-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  flex-shrink: 0;
}

.apais-input {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  outline: none;
  font-size: 14px;
  line-height: 1.25;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.2s;
}

.apais-input:focus { border-color: rgba(0, 0, 0, 0.28); }
.apais-input::placeholder { color: rgba(0, 0, 0, 0.4); }

.apais-footer > div {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

/* =========================
   BUTTONS
   ========================= */

.apais-send,
.apais-human {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #111;
  color: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
  font-family: inherit;
  transition: filter 0.2s, opacity 0.2s;
}

.apais-human { background: #fff; color: #111; }
.apais-send:hover { filter: brightness(1.06); }
.apais-human:hover { background: #f3f4f6; }
.apais-send:disabled,
.apais-human:disabled { opacity: 0.5; cursor: not-allowed; }

/* =========================
   CTA BUTTON (Product pages)
   ========================= */

.apais-talk-btn {
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.2s, box-shadow 0.2s;
}

.apais-talk-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* =========================
   SUPPORT LAUNCHER
   ========================= */

.apais-support-launcher {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  padding: 14px 18px;
  background: #111;
  color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 50px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.apais-support-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

/* =========================
   ✅ CRITICAL FIX: ICON BUTTONS (TTS + MIC)
   ========================= */

.apais-voice-btn,
.apais-tts-toggle {
  text-indent: 0 !important;
  letter-spacing: 0 !important;
  font-size: 18px !important;
  line-height: 1 !important;
  font-weight: 900 !important;
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial,Apple Color Emoji,Segoe UI Emoji,Noto Color Emoji !important;
  overflow: visible !important;
}

.apais-voice-btn::before,
.apais-voice-btn::after,
.apais-tts-toggle::before,
.apais-tts-toggle::after {
  content: none !important;
}

/* =========================
   MOBILE
   ========================= */

@media (max-width: 768px) {
  .apais-window { width: 96vw !important; max-height: 85vh !important; }
  .apais-window--floating { bottom: 72px !important; right: 12px !important; width: calc(100vw - 24px) !important; max-height: 70vh !important; }
  .apais-support-launcher { bottom: 16px !important; right: 16px !important; padding: 12px 16px !important; font-size: 13px !important; }
  .apais-bubble { max-width: 90%; }
}

@media print {
  .apais-overlay,
  .apais-window,
  .apais-support-launcher,
  .apais-talk-btn { display: none !important; }
}

/* ===== Voice buttons (mic / sound) ===== */
.apais-voice-btn{
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(0,0,0,0.14);
  background: #fff;
  color: #111;
  border-radius: 14px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  user-select: none;
}

.apais-voice-btn:hover{ background:#f3f4f6; }

.apais-voice-btn.is-off{
  opacity: .75;
  filter: grayscale(1);
}

/* optional: mažas "OFF" badge */
.apais-voice-btn.is-off::after{
  content: "OFF";
  position: absolute;
  transform: translate(14px, 14px);
  font-size: 9px;
  font-weight: 900;
  background: #111;
  color: #fff;
  padding: 2px 4px;
  border-radius: 8px;
}

.apais-tts-toggle, .apais-voice-btn { position: relative !important; }
.apais-tts-toggle::before, .apais-tts-toggle::after,
.apais-voice-btn::before, .apais-voice-btn::after { content:none !important; }