/* ============================================================
   Logic8 Aria Chatbot Widget
   Appended to <html> (not body) so position:fixed always uses
   the viewport as its containing block, regardless of any
   overflow:hidden on the body element.
   ============================================================ */

/* --- Reset for widget elements ----------------------------- */
/* Font must be explicit: widget lives on <html>, outside <body>,
   so it doesn't inherit the page's body font-family. */
.l8-widget-root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               Helvetica, Arial, sans-serif !important;
  font-size: 16px;
  line-height: 1.5;
  color: #e2e8f0;
}

.l8-widget-root *,
.l8-widget-root *::before,
.l8-widget-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: inherit;
}

/* --- Floating bubble button -------------------------------- */
.l8-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 2147483646;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px 14px 18px;
  background: linear-gradient(135deg, #00C0A5 0%, #0190D5 100%);
  border: none;
  border-radius: 56px;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 192, 165, 0.45), 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}

.l8-bubble:hover {
  transform: translateY(1px);
  box-shadow: 0 4px 16px rgba(0, 192, 165, 0.35), 0 1px 4px rgba(0,0,0,0.2);
}

.l8-bubble__label {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.l8-bubble__dot {
  width: 8px;
  height: 8px;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: l8-pulse 2.4s ease-in-out infinite;
}

@keyframes l8-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* Hide bubble when panel is open */
.l8-bubble.l8-hidden { display: none; }

/* --- Chat panel -------------------------------------------- */
.l8-panel {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 2147483647;
  width: 400px;
  max-width: calc(100vw - 24px);
  height: 580px;
  max-height: calc(100dvh - 56px);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: #0c0d1a;
  border: 1px solid rgba(255,255,255,0.09);
  box-shadow:
    0 32px 80px rgba(0,0,0,0.7),
    0 0 0 1px rgba(0,192,165,0.08),
    inset 0 1px 0 rgba(255,255,255,0.06);

  /* Hidden state */
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition:
    opacity 0.3s cubic-bezier(0.16,1,0.3,1),
    transform 0.3s cubic-bezier(0.16,1,0.3,1);
}

.l8-panel.l8-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* --- Header ----------------------------------------------- */
.l8-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px 18px;
  background: linear-gradient(135deg,
    rgba(0,192,165,0.18) 0%,
    rgba(1,144,213,0.15) 100%);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  overflow: hidden;
}

/* Subtle glow behind the header */
.l8-header::before {
  content: '';
  position: absolute;
  top: -30px; left: -30px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(0,192,165,0.25) 0%, transparent 70%);
  pointer-events: none;
}

.l8-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00C0A5 0%, #0190D5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,192,165,0.35);
  overflow: hidden;
  -webkit-mask-image: -webkit-radial-gradient(white,black);
}

/* Online indicator dot */
.l8-avatar::after {
  content: '';
  position: absolute;
  bottom: 2px; right: 2px;
  width: 10px; height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0c0d1a;
  box-shadow: 0 0 6px rgba(34,197,94,0.6);
}

.l8-header__info { flex: 1; min-width: 0; }

.l8-header__name {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.l8-header__status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #00C0A5;
  margin-top: 3px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.l8-header__status::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(34,197,94,0.7);
  flex-shrink: 0;
}

.l8-close {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.l8-close:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
  color: #fff;
}

/* --- Messages area ----------------------------------------- */
.l8-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
  background:
    radial-gradient(ellipse 60% 30% at 50% 0%, rgba(0,192,165,0.04) 0%, transparent 100%),
    #0c0d1a;
}

.l8-messages::-webkit-scrollbar { width: 4px; }
.l8-messages::-webkit-scrollbar-track { background: transparent; }
.l8-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* --- Individual messages ----------------------------------- */
.l8-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: l8-msg-in 0.2s ease;
}

@keyframes l8-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.l8-msg--user      { align-self: flex-end; align-items: flex-end; }
.l8-msg--assistant { align-self: flex-start; align-items: flex-start; }

.l8-msg__bubble {
  padding: 11px 15px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

.l8-msg--user .l8-msg__bubble {
  background: linear-gradient(135deg, #00C0A5 0%, #0190D5 100%);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 14px rgba(0,192,165,0.25);
}

.l8-msg--assistant .l8-msg__bubble {
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 4px 16px 16px 16px;
}

.l8-msg__bubble a {
  color: #00C0A5;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.l8-msg--user .l8-msg__bubble a {
  color: rgba(255,255,255,0.9);
}

/* --- Typing indicator -------------------------------------- */
.l8-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 13px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 4px 16px 16px 16px;
  width: fit-content;
  align-self: flex-start;
  animation: l8-msg-in 0.2s ease;
}

.l8-typing span {
  width: 7px; height: 7px;
  background: #475569;
  border-radius: 50%;
  animation: l8-bounce 1.4s ease-in-out infinite;
}

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

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

/* --- Input area -------------------------------------------- */
.l8-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 13px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.l8-textarea {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: #e2e8f0;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s, background 0.15s;
}

.l8-textarea::placeholder { color: #475569; }

.l8-textarea:focus {
  border-color: rgba(0,192,165,0.5);
  background: rgba(255,255,255,0.07);
  box-shadow: 0 0 0 3px rgba(0,192,165,0.08);
}

.l8-send {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #00C0A5, #0190D5);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,192,165,0.35);
  transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.l8-send:hover {
  transform: translateY(1px);
  opacity: 0.9;
  box-shadow: 0 2px 8px rgba(0,192,165,0.25);
}

.l8-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --- Voice button ------------------------------------------ */
.l8-voice {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  cursor: pointer;
  display: flex;          /* toggled to flex by JS when SDK loads */
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: background 0.15s, border-color 0.15s, color 0.15s,
              box-shadow 0.15s, transform 0.15s;
}

.l8-voice:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.2);
  color: #94a3b8;
  transform: translateY(1px);
}

/* Connecting — subtle pulse while waiting for call to start */
.l8-voice--connecting {
  color: #f59e0b;
  border-color: rgba(245,158,11,0.4);
  background: rgba(245,158,11,0.08);
  animation: l8-voice-pulse 1.2s ease-in-out infinite;
}

/* Active — call in progress */
.l8-voice--active {
  color: #ef4444;
  border-color: rgba(239,68,68,0.5);
  background: rgba(239,68,68,0.12);
  box-shadow: 0 0 0 0 rgba(239,68,68,0.4);
  animation: l8-voice-ring 1.6s ease-out infinite;
}

.l8-voice--active:hover {
  background: rgba(239,68,68,0.2);
  transform: translateY(1px);
}

@keyframes l8-voice-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

@keyframes l8-voice-ring {
  0%   { box-shadow: 0 0 0 0   rgba(239,68,68,0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(239,68,68,0);    }
  100% { box-shadow: 0 0 0 0   rgba(239,68,68,0);    }
}

/* --- Powered-by footer ------------------------------------- */
.l8-footer {
  padding: 7px 0 9px;
  text-align: center;
  font-size: 10px;
  color: #334155;
  background: rgba(0,0,0,0.25);
  flex-shrink: 0;
  font-family: system-ui, sans-serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* --- Mobile ------------------------------------------------ */
@media (max-width: 460px) {
  .l8-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 8px;
    border-radius: 16px;
    height: calc(100dvh - 80px);
  }

  .l8-bubble {
    right: 12px;
    bottom: 12px;
  }
}
