/* ============================================================================
   LIVECHAT WIDGET — Urbance Support Chat
   All styles scoped under .urb-livechat
   ============================================================================ */

/* ─── Overlay / Backdrop ─── */
.urb-livechat__overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.urb-livechat__overlay--open {
  opacity: 1;
  visibility: visible;
}

/* ─── Widget Container (Desktop: right-side drawer) ─── */
.urb-livechat__widget {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  box-shadow: -4px 0 32px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.25s ease;

  /* Desktop: right-side drawer */
  top: 0;
  right: 0;
  width: 420px;
  height: 100dvh;
  border-radius: 0;
  transform: translateX(100%);
}

.urb-livechat__widget--open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* ─── Header ─── */
.urb-livechat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: #FFFFFF;
  border-bottom: 1px solid #E5E7EB;
  flex-shrink: 0;
}

.urb-livechat__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2F80ED, #1D6FD3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.urb-livechat__avatar svg {
  width: 20px;
  height: 20px;
  color: #FFFFFF;
}

.urb-livechat__header-info {
  flex: 1;
  min-width: 0;
}

.urb-livechat__header-title {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #111111;
  line-height: 1.3;
  margin: 0;
}

.urb-livechat__header-status {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #6B7280;
  line-height: 1.3;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.urb-livechat__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22C55E;
  display: inline-block;
  flex-shrink: 0;
}

.urb-livechat__close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  flex-shrink: 0;
  color: #6B7280;
}

.urb-livechat__close:hover {
  background: #F3F4F6;
  color: #111111;
}

.urb-livechat__close:focus-visible {
  outline: 2px solid #2F80ED;
  outline-offset: 2px;
}

/* ─── Messages Area ─── */
.urb-livechat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #F9FAFB;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar */
.urb-livechat__messages::-webkit-scrollbar {
  width: 5px;
}

.urb-livechat__messages::-webkit-scrollbar-track {
  background: transparent;
}

.urb-livechat__messages::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 4px;
}

/* ─── Welcome Card ─── */
.urb-livechat__welcome {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 14px;
  padding: 20px;
  text-align: center;
}

.urb-livechat__welcome-title {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #111111;
  margin: 0 0 6px 0;
}

.urb-livechat__welcome-sub {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: #6B7280;
  margin: 0 0 16px 0;
  line-height: 1.5;
}

/* ─── Quick Action Pills ─── */
.urb-livechat__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.urb-livechat__pill {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #2F80ED;
  background: #EAF2FF;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
  line-height: 1;
}

.urb-livechat__pill:hover {
  background: #D6E6FF;
  border-color: #2F80ED;
}

.urb-livechat__pill:active {
  transform: scale(0.97);
}

.urb-livechat__pill:focus-visible {
  outline: 2px solid #2F80ED;
  outline-offset: 2px;
}

/* ─── Message Bubbles ─── */
.urb-livechat__msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: urbLivechatFadeIn 0.25s ease;
}

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

/* Assistant (left-aligned) */
.urb-livechat__msg--assistant {
  align-self: flex-start;
}

.urb-livechat__msg--assistant .urb-livechat__bubble {
  background: #FFFFFF;
  color: #111111;
  border: 1px solid #E5E7EB;
  border-radius: 4px 14px 14px 14px;
}

/* User (right-aligned) */
.urb-livechat__msg--user {
  align-self: flex-end;
}

.urb-livechat__msg--user .urb-livechat__bubble {
  background: #2F80ED;
  color: #FFFFFF;
  border: none;
  border-radius: 14px 14px 4px 14px;
}

.urb-livechat__bubble {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  padding: 12px 16px;
  word-break: break-word;
}

.urb-livechat__msg-time {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: #9CA3AF;
  margin-top: 4px;
  padding: 0 4px;
}

.urb-livechat__msg--user .urb-livechat__msg-time {
  text-align: right;
}

/* ─── Typing Indicator ─── */
.urb-livechat__typing {
  display: flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  padding: 12px 18px;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 4px 14px 14px 14px;
  animation: urbLivechatFadeIn 0.25s ease;
}

.urb-livechat__typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9CA3AF;
  animation: urbLivechatBounce 1.2s infinite;
}

.urb-livechat__typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.urb-livechat__typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

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

/* ─── Error Message ─── */
.urb-livechat__error {
  align-self: center;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #EF4444;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 10px;
  padding: 10px 16px;
  text-align: center;
  animation: urbLivechatFadeIn 0.25s ease;
}

/* ─── Composer / Input Area ─── */
.urb-livechat__composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid #E5E7EB;
  background: #FFFFFF;
  flex-shrink: 0;
}

.urb-livechat__input-wrap {
  flex: 1;
  position: relative;
}

.urb-livechat__input {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: #111111;
  background: #F5F7FA;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  padding: 12px 16px;
  resize: none;
  outline: none;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.45;
  overflow-y: auto;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.urb-livechat__input::placeholder {
  color: #9CA3AF;
}

.urb-livechat__input:focus {
  border-color: #2F80ED;
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.1);
  background: #FFFFFF;
}

.urb-livechat__send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: #2F80ED;
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.urb-livechat__send:hover {
  background: #1D6FD3;
}

.urb-livechat__send:active {
  transform: scale(0.95);
}

.urb-livechat__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.urb-livechat__send:focus-visible {
  outline: 2px solid #2F80ED;
  outline-offset: 2px;
}

.urb-livechat__send svg {
  width: 18px;
  height: 18px;
}

/* ─── Footer Note ─── */
.urb-livechat__footer-note {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: #9CA3AF;
  text-align: center;
  padding: 6px 16px 12px;
  background: #FFFFFF;
  flex-shrink: 0;
}

/* ─── Body Scroll Lock ─── */
body.urb-livechat--locked {
  overflow: hidden !important;
}

/* ============================================================================
   RESPONSIVE — Mobile Bottom Sheet
   ============================================================================ */

@media (max-width: 600px) {
  .urb-livechat__widget {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 85dvh;
    max-height: 85dvh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
  }

  .urb-livechat__widget--open {
    transform: translateY(0);
  }

  /* Drag handle visual */
  .urb-livechat__header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #D1D5DB;
  }

  .urb-livechat__header {
    position: relative;
    padding-top: 22px;
  }

  .urb-livechat__widget {
    border-radius: 20px 20px 0 0;
  }

  .urb-livechat__input {
    font-size: 16px; /* Prevent iOS zoom */
  }

  .urb-livechat__bubble {
    font-size: 15px;
  }

  .urb-livechat__msg {
    max-width: 88%;
  }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .urb-livechat__overlay,
  .urb-livechat__widget,
  .urb-livechat__msg,
  .urb-livechat__typing,
  .urb-livechat__error {
    transition: none !important;
    animation: none !important;
  }

  .urb-livechat__typing-dot {
    animation: none !important;
    opacity: 0.6;
  }
}
