/* ─────────────────────────────────────────────────────────────────────────────
   ZURI AI WIDGET — Abilities Finance Design System
   Navy #0A192F / Gold #D4AF37 — Matches site premium dark theme
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --zuri-navy:       #0A192F;
  --zuri-navy-dark:  #060f1e;
  --zuri-navy-light: #112240;
  --zuri-gold:       #D4AF37;
  --zuri-gold-dim:   rgba(212,175,55,0.18);
  --zuri-gold-border:rgba(212,175,55,0.30);
  --zuri-white:      rgba(255,255,255,0.90);
  --zuri-muted:      rgba(255,255,255,0.45);
  --zuri-green:      #22c55e;
  --zuri-red:        #ef4444;
  --zuri-shadow:     0 8px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(212,175,55,0.12);
  --zuri-ease:       cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── LAUNCHER (circular FAB) ─────────────────────────────────────────────── */
#zuri-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  font-family: 'Lato', 'Segoe UI', sans-serif;
}

#zuri-launcher {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--zuri-gold) 0%, #b89a2f 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(212,175,55,0.45), 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.25s var(--zuri-ease), box-shadow 0.25s var(--zuri-ease);
  padding: 0;
  outline: none;
}

#zuri-launcher:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(212,175,55,0.6), 0 4px 12px rgba(0,0,0,0.4);
}

#zuri-launcher:active {
  transform: scale(0.95);
}

#zuri-launcher:focus-visible {
  outline: 3px solid var(--zuri-gold);
  outline-offset: 3px;
}

#zuri-launcher img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
}

.zuri-icon-fallback {
  font-size: 28px;
  line-height: 1;
  display: none;
}

/* Notification badge */
#zuri-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--zuri-red);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid var(--zuri-navy-dark);
  animation: zuriPulse 2s infinite;
  pointer-events: none;
}

@keyframes zuriPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

/* ─── CHAT WINDOW ─────────────────────────────────────────────────────────── */
#zuri-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100svh - 120px);
  background: var(--zuri-navy);
  border: 1px solid var(--zuri-gold-border);
  border-radius: 16px;
  box-shadow: var(--zuri-shadow);
  display: none;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  animation: zuriSlideUp 0.28s var(--zuri-ease);
}

#zuri-window.open {
  display: flex;
}

@keyframes zuriSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* ─── HEADER ──────────────────────────────────────────────────────────────── */
#zuri-header {
  background: linear-gradient(135deg, var(--zuri-navy-dark) 0%, var(--zuri-navy-light) 100%);
  border-bottom: 1px solid var(--zuri-gold-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#zuri-header-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

#zuri-header-avatar img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--zuri-gold);
}

.zuri-header-online {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--zuri-green);
  border: 2px solid var(--zuri-navy-dark);
  animation: zuriPulse 2.5s ease-in-out infinite;
}

#zuri-header-info {
  flex: 1;
  min-width: 0;
}

#zuri-header-name {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  margin: 0 0 2px;
  line-height: 1.2;
}

#zuri-header-status {
  font-size: 11px;
  color: var(--zuri-green);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

#zuri-header-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--zuri-green);
  display: inline-block;
  flex-shrink: 0;
}

#zuri-close {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--zuri-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--zuri-ease);
  flex-shrink: 0;
  line-height: 1;
}

#zuri-close:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
  transform: rotate(90deg);
}

/* ─── MESSAGES CONTAINER ──────────────────────────────────────────────────── */
#zuri-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--zuri-navy);
  scroll-behavior: smooth;
}

#zuri-messages::-webkit-scrollbar       { width: 4px; }
#zuri-messages::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); }
#zuri-messages::-webkit-scrollbar-thumb { background: var(--zuri-gold-border); border-radius: 2px; }
#zuri-messages::-webkit-scrollbar-thumb:hover { background: rgba(212,175,55,0.5); }

/* ─── MESSAGE BUBBLES ─────────────────────────────────────────────────────── */
.zuri-msg {
  display: flex;
  gap: 8px;
  animation: zuriMsgIn 0.25s var(--zuri-ease);
  max-width: 88%;
}

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

.zuri-msg-assistant { align-self: flex-start; }
.zuri-msg-user      { align-self: flex-end; flex-direction: row-reverse; }

.zuri-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--zuri-gold-border);
  margin-top: 2px;
}

.zuri-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.zuri-msg-text {
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Assistant bubble */
.zuri-msg-assistant .zuri-msg-text {
  background: var(--zuri-navy-light);
  color: var(--zuri-white);
  border: 1px solid var(--zuri-gold-border);
  border-top-left-radius: 4px;
}

/* User bubble */
.zuri-msg-user .zuri-msg-text {
  background: linear-gradient(135deg, var(--zuri-gold) 0%, #b89a2f 100%);
  color: var(--zuri-navy-dark);
  font-weight: 600;
  border-top-right-radius: 4px;
}

.zuri-msg-text strong { font-weight: 700; }
.zuri-msg-text em     { font-style: italic; }

.zuri-msg-text a {
  color: inherit;
  text-decoration: underline;
  opacity: 0.85;
}
.zuri-msg-text a:hover { opacity: 1; }

/* ─── TYPING INDICATOR ────────────────────────────────────────────────────── */
#zuri-typing {
  display: none;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  padding: 4px 0 2px;
  animation: zuriMsgIn 0.25s var(--zuri-ease);
}

#zuri-typing.active { display: flex; }

.zuri-typing-dots {
  background: var(--zuri-navy-light);
  border: 1px solid var(--zuri-gold-border);
  border-radius: 12px;
  border-top-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.zuri-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--zuri-gold);
  animation: zuriTyping 1.4s infinite;
  opacity: 0.5;
}
.zuri-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.zuri-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes zuriTyping {
  0%, 80%, 100% { transform: translateY(0);   opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1;   }
}

/* ─── QUICK REPLIES ───────────────────────────────────────────────────────── */
#zuri-quick-replies {
  padding: 8px 12px 4px;
  background: var(--zuri-navy-dark);
  border-top: 1px solid rgba(212,175,55,0.1);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex-wrap: nowrap;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#zuri-quick-replies::-webkit-scrollbar { display: none; }
#zuri-quick-replies:empty { display: none; }

.zuri-quick-btn {
  background: var(--zuri-gold-dim);
  border: 1px solid var(--zuri-gold-border);
  border-radius: 50px;
  padding: 5px 12px;
  font-family: 'Lato', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--zuri-gold);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s var(--zuri-ease);
}
.zuri-quick-btn:hover {
  background: rgba(212,175,55,0.28);
  border-color: var(--zuri-gold);
  transform: translateY(-1px);
}

/* ─── INPUT AREA ──────────────────────────────────────────────────────────── */
#zuri-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  background: var(--zuri-navy-dark);
  border-top: 1px solid rgba(212,175,55,0.15);
  flex-shrink: 0;
  align-items: center;
}

#zuri-input {
  flex: 1;
  background: var(--zuri-navy-light);
  border: 1px solid var(--zuri-gold-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: 'Lato', 'Segoe UI', sans-serif;
  color: var(--zuri-white);
  outline: none;
  transition: border-color 0.2s var(--zuri-ease), box-shadow 0.2s var(--zuri-ease);
  min-width: 0;
}

#zuri-input::placeholder {
  color: var(--zuri-muted);
  font-style: italic;
}

#zuri-input:focus {
  border-color: rgba(212,175,55,0.65);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.1);
}

#zuri-send {
  background: var(--zuri-gold);
  border: none;
  border-radius: 8px;
  color: var(--zuri-navy-dark);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--zuri-ease);
  padding: 0;
  flex-shrink: 0;
}

#zuri-send:hover {
  background: #c4a030;
  transform: scale(1.07);
  box-shadow: 0 3px 12px rgba(212,175,55,0.4);
}

#zuri-send:active  { transform: scale(0.93); }

#zuri-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#zuri-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ─── FOOTER ──────────────────────────────────────────────────────────────── */
#zuri-footer {
  padding: 6px 12px 8px;
  background: var(--zuri-navy-dark);
  font-size: 10.5px;
  color: rgba(255,255,255,0.22);
  text-align: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  border-top: 1px solid rgba(212,175,55,0.08);
}

/* ─── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #zuri-widget {
    bottom: 16px;
    right: 16px;
  }

  #zuri-launcher {
    width: 58px;
    height: 58px;
  }

  #zuri-launcher img {
    width: 44px;
    height: 44px;
  }

  #zuri-window {
    width: calc(100vw - 24px);
    height: calc(100svh - 100px);
    max-height: none;
    bottom: 84px;
    right: 12px;
    border-radius: 14px;
  }

  .zuri-msg-text { font-size: 13px; }
  #zuri-input    { font-size: 13px; }
  #zuri-header   { padding: 12px 14px; }
  #zuri-messages { padding: 12px; gap: 10px; }
}

@media (max-width: 360px) {
  #zuri-window {
    width: calc(100vw - 16px);
    right: 8px;
  }
}

/* ─── ACCESSIBILITY ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #zuri-launcher,
  #zuri-window,
  .zuri-msg,
  .zuri-typing-dots span,
  #zuri-badge {
    animation: none !important;
    transition: none !important;
  }
}

/* ─── GPU ACCELERATION ────────────────────────────────────────────────────── */
#zuri-launcher,
#zuri-window,
.zuri-msg {
  will-change: transform;
  transform: translateZ(0);
}

#zuri-messages {
  contain: layout style paint;
}


/* ─── WIDGET-SUFFIX ID ALIASES ────────────────────────────────────────────── */
/* These rules mirror the plain-ID rules above for the -widget suffix IDs     */
/* used in the HTML (e.g. id="zuri-window-widget" instead of id="zuri-window")*/

/* Window */
#zuri-window-widget {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-height: 580px;
  min-height: 420px;
  background: var(--zuri-navy-dark);
  border: 1px solid var(--zuri-gold-border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(212,175,55,0.08);
  z-index: 9998;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: zuriWindowIn 0.28s var(--zuri-ease) forwards;
}
#zuri-window-widget.open {
  display: flex;
}

/* Messages */
#zuri-messages-widget {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#zuri-messages-widget::-webkit-scrollbar       { width: 4px; }
#zuri-messages-widget::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); }
#zuri-messages-widget::-webkit-scrollbar-thumb { background: var(--zuri-gold-border); border-radius: 2px; }
#zuri-messages-widget::-webkit-scrollbar-thumb:hover { background: rgba(212,175,55,0.5); }

/* Typing indicator */
#zuri-typing-widget {
  display: none;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  padding: 4px 0 2px;
  animation: zuriMsgIn 0.25s var(--zuri-ease);
}
#zuri-typing-widget.active { display: flex; }

/* Input area container */
#zuri-input-area-widget {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  background: var(--zuri-navy-dark);
  border-top: 1px solid rgba(212,175,55,0.15);
  flex-shrink: 0;
  align-items: center;
}

/* Input field */
#zuri-input-widget {
  flex: 1;
  background: var(--zuri-navy-light);
  border: 1px solid var(--zuri-gold-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: 'Lato', 'Segoe UI', sans-serif;
  color: var(--zuri-white);
  outline: none;
  transition: border-color 0.2s var(--zuri-ease), box-shadow 0.2s var(--zuri-ease);
  min-width: 0;
}
#zuri-input-widget::placeholder {
  color: var(--zuri-muted);
  font-style: italic;
}
#zuri-input-widget:focus {
  border-color: rgba(212,175,55,0.65);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.1);
}

/* Send button */
#zuri-send-widget {
  background: var(--zuri-gold);
  border: none;
  border-radius: 8px;
  color: var(--zuri-navy-dark);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--zuri-ease);
  padding: 0;
  flex-shrink: 0;
}
#zuri-send-widget:hover {
  background: #c4a030;
  transform: scale(1.07);
  box-shadow: 0 3px 12px rgba(212,175,55,0.4);
}
#zuri-send-widget:active  { transform: scale(0.93); }
#zuri-send-widget:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
#zuri-send-widget svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Responsive overrides for -widget IDs */
@media (max-width: 480px) {
  #zuri-window-widget {
    width: calc(100vw - 24px);
    height: calc(100svh - 100px);
    max-height: none;
    bottom: 84px;
    right: 12px;
    border-radius: 14px;
  }
  #zuri-input-widget    { font-size: 13px; }
  #zuri-messages-widget { padding: 12px; gap: 10px; }
}
@media (max-width: 360px) {
  #zuri-window-widget {
    width: calc(100vw - 16px);
    right: 8px;
  }
}

/* GPU acceleration for -widget IDs */
#zuri-window-widget,
.zuri-msg {
  will-change: transform;
  transform: translateZ(0);
}
#zuri-messages-widget {
  contain: layout style paint;
}

/* Reduced motion for -widget IDs */
@media (prefers-reduced-motion: reduce) {
  #zuri-window-widget,
  #zuri-messages-widget {
    animation: none !important;
    transition: none !important;
  }
}
