/* assistant.css
   Q-Lift Ultimate AI Assistant — widget styling
   Uses the same CSS variables as the main page (ivory/cream/forest/brass/ink). */

#qlu-assistant-root {
  --qlu-ivory: #EFEAE1;
  --qlu-cream: #F8F5EE;
  --qlu-paper: #FAF7F1;
  --qlu-ink: #1C1814;
  --qlu-ink-soft: #3A322B;
  --qlu-ink-mute: #6E6458;
  --qlu-forest: #2D3A2E;
  --qlu-forest-deep: #1E2820;
  --qlu-brass: #A67F5B;
  --qlu-brass-soft: #C9A47B;
  --qlu-brass-pale: #E8D5BB;
  --qlu-hairline: rgba(28,24,20,0.18);
  --qlu-hairline-soft: rgba(28,24,20,0.08);

  --qlu-display: "Cormorant Garamond", "Times New Roman", serif;
  --qlu-body: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ─── LAUNCHER BUTTON ────────────────────────────────────────────────── */
#qlu-launcher {
  position: fixed;
  bottom: 18px;
  left: 18px;
  background: var(--qlu-forest);
  color: var(--qlu-ivory);
  border: none;
  padding: 0.85rem 1.25rem 0.85rem 1rem;
  border-radius: 999px;
  font-family: var(--qlu-body);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  box-shadow: 0 6px 20px rgba(45,58,46,0.35);
  z-index: 95;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
#qlu-launcher:hover {
  background: var(--qlu-forest-deep);
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(45,58,46,0.45);
}
#qlu-launcher svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.qlu-launcher-label {
  white-space: nowrap;
}

/* Don't collide with sticky mobile CTA bar */
@media (max-width: 720px) {
  #qlu-launcher {
    bottom: 84px;
    padding: 0.75rem 1.1rem 0.75rem 0.9rem;
    font-size: 0.85rem;
  }
}

/* ─── PANEL ──────────────────────────────────────────────────────────── */
#qlu-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--qlu-paper);
  z-index: 100;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#qlu-panel[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

/* On larger screens, show as a centred panel rather than full-screen */
@media (min-width: 720px) {
  #qlu-panel {
    top: 5vh;
    left: 50%;
    right: auto;
    bottom: 5vh;
    transform: translateX(-50%);
    width: 90vw;
    max-width: 720px;
    height: 90vh;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(28,24,20,0.25);
    border: 1px solid var(--qlu-hairline-soft);
  }
}

/* Backdrop on desktop */
@media (min-width: 720px) {
  #qlu-panel::before {
    content: "";
    position: fixed;
    top: -5vh;
    left: -50vw;
    right: -50vw;
    bottom: -5vh;
    background: rgba(28,24,20,0.5);
    z-index: -1;
    backdrop-filter: blur(2px);
  }
}

/* ─── HEADER ─────────────────────────────────────────────────────────── */
.qlu-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--qlu-forest);
  color: var(--qlu-ivory);
  flex-shrink: 0;
}
.qlu-panel-eyebrow {
  font-family: var(--qlu-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--qlu-brass-soft);
  margin-bottom: 0.15rem;
}
.qlu-panel-title {
  font-family: var(--qlu-display);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--qlu-ivory);
}
#qlu-close {
  background: transparent;
  border: none;
  color: var(--qlu-ivory);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
#qlu-close:hover {
  background: rgba(239,234,225,0.1);
}
#qlu-close svg {
  width: 22px;
  height: 22px;
}

/* ─── DISCLAIMER ─────────────────────────────────────────────────────── */
.qlu-disclaimer {
  background: var(--qlu-cream);
  padding: 0.6rem 1.25rem;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--qlu-ink-mute);
  text-align: center;
  border-bottom: 1px solid var(--qlu-hairline-soft);
  flex-shrink: 0;
}

/* ─── MESSAGES AREA ──────────────────────────────────────────────────── */
.qlu-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
  background: var(--qlu-paper);
  -webkit-overflow-scrolling: touch;
}

/* ─── MESSAGES ───────────────────────────────────────────────────────── */
.qlu-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 100%;
  animation: qlu-msg-in 0.25s ease;
}
@keyframes qlu-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.qlu-msg-user {
  justify-content: flex-end;
}
.qlu-msg-user .qlu-msg-bubble {
  background: var(--qlu-forest);
  color: var(--qlu-ivory);
  border-radius: 18px 18px 4px 18px;
  padding: 0.75rem 1rem;
  max-width: 85%;
  line-height: 1.5;
  font-size: 0.95rem;
}

.qlu-msg-assistant {
  justify-content: flex-start;
  align-items: flex-end;
}
.qlu-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--qlu-brass);
  color: var(--qlu-paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--qlu-display);
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.qlu-msg-assistant .qlu-msg-bubble {
  background: var(--qlu-cream);
  color: var(--qlu-ink);
  border-radius: 18px 18px 18px 4px;
  padding: 0.75rem 1rem;
  max-width: 85%;
  line-height: 1.5;
  font-size: 0.95rem;
  border: 1px solid var(--qlu-hairline-soft);
}
.qlu-msg-assistant .qlu-msg-bubble p {
  margin: 0 0 0.5rem;
}
.qlu-msg-assistant .qlu-msg-bubble p:last-child {
  margin-bottom: 0;
}

/* Blinking caret while streaming */
.qlu-streaming-caret {
  display: inline-block;
  width: 7px;
  height: 1em;
  background: var(--qlu-brass);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: qlu-caret-blink 0.9s infinite;
  border-radius: 1px;
  opacity: 0.85;
}
@keyframes qlu-caret-blink {
  0%, 50% { opacity: 0.85; }
  51%, 100% { opacity: 0; }
}

/* ─── MEDIA WITHIN MESSAGES ──────────────────────────────────────────── */
.qlu-media {
  margin: 0.75rem 0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--qlu-hairline-soft);
}
.qlu-media:first-child { margin-top: 0; }
.qlu-media:last-child { margin-bottom: 0; }

.qlu-media-image {
  position: relative;
  background: var(--qlu-paper);
}
.qlu-media-image img {
  display: block;
  width: 100%;
  height: auto;
}
.qlu-media-stamp {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: rgba(45,58,46,0.85);
  color: var(--qlu-ivory);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  text-transform: uppercase;
}

.qlu-media-video {
  background: var(--qlu-paper);
  padding: 0.5rem;
}
.qlu-media-label {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--qlu-brass);
  margin-bottom: 0.45rem;
}

.qlu-video-frame {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  background: var(--qlu-ink);
}
.qlu-video-frame.is-vertical {
  padding-bottom: 0;
  height: auto;
  aspect-ratio: 9 / 16;
  max-width: 220px;
  margin: 0 auto;
}
.qlu-video-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ─── TYPING INDICATOR ───────────────────────────────────────────────── */
.qlu-typing {
  display: flex;
  gap: 4px;
  padding: 0.2rem 0;
}
.qlu-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--qlu-brass);
  opacity: 0.4;
  animation: qlu-bounce 1.4s infinite ease-in-out;
}
.qlu-typing span:nth-child(2) { animation-delay: 0.15s; }
.qlu-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes qlu-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ─── SUGGESTIONS CHIPS ──────────────────────────────────────────────── */
.qlu-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1.25rem 0.75rem;
  background: var(--qlu-paper);
  flex-shrink: 0;
}
.qlu-chip {
  background: transparent;
  border: 1px solid var(--qlu-brass);
  color: var(--qlu-forest);
  font-family: var(--qlu-body);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.qlu-chip:hover {
  background: var(--qlu-forest);
  border-color: var(--qlu-forest);
  color: var(--qlu-ivory);
}

/* ─── INPUT ──────────────────────────────────────────────────────────── */
.qlu-input-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--qlu-paper);
  border-top: 1px solid var(--qlu-hairline-soft);
  flex-shrink: 0;
}
#qlu-input {
  flex: 1;
  font-family: var(--qlu-body);
  font-size: 1rem;
  color: var(--qlu-ink);
  background: var(--qlu-cream);
  border: 1px solid var(--qlu-hairline);
  border-radius: 24px;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
}
#qlu-input:focus {
  border-color: var(--qlu-forest);
}
#qlu-send {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--qlu-forest);
  color: var(--qlu-ivory);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}
#qlu-send:hover:not(:disabled) {
  background: var(--qlu-forest-deep);
  transform: scale(1.05);
}
#qlu-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#qlu-send svg {
  width: 18px;
  height: 18px;
}

/* ─── SAFE AREA INSETS (iPhone notch / home indicator) ──────────────── */
@supports (padding: max(0px)) {
  .qlu-input-form {
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
  }
  #qlu-launcher {
    bottom: max(18px, env(safe-area-inset-bottom));
  }
  @media (max-width: 720px) {
    #qlu-launcher {
      bottom: max(84px, calc(env(safe-area-inset-bottom) + 70px));
    }
  }
}
