/* ============================================================
   Creaters Hub — Storefront Live Chat & Concierge Styles
   Theme: Luxury Indian Artisan Boutique (Maroon / Gold / Slate)
   ============================================================ */

:root {
  --ch-chat-primary: #800020;
  --ch-chat-primary-hover: #9c0b2b;
  --ch-chat-gold: #c59b27;
  --ch-chat-dark: #0f172a;
  --ch-chat-slate: #334155;
  --ch-chat-light-bg: #f8fafc;
  --ch-chat-border: #e2e8f0;
  --ch-chat-bubble-user: #800020;
  --ch-chat-bubble-user-text: #ffffff;
  --ch-chat-bubble-admin: #ffffff;
  --ch-chat-bubble-admin-text: #1e293b;
  --ch-chat-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --ch-chat-shadow: 0 12px 36px -4px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.ch-chat-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999990;
  font-family: var(--ch-chat-font);
  pointer-events: none;
}

.ch-chat-root * {
  box-sizing: border-box;
}

/* ── Floating Launcher Bubble ── */
.ch-chat-launcher {
  pointer-events: auto;
  position: absolute;
  bottom: 0;
  right: 0;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #800020 0%, #a31238 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(128, 0, 32, 0.4);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  user-select: none;
}

.ch-chat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(128, 0, 32, 0.55);
}

.ch-launcher-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

/* Online Pulse Ring */
.ch-launcher-pulse {
  position: absolute;
  top: 0;
  right: 0;
  width: 15px;
  height: 15px;
  background-color: #10b981;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
}

.ch-launcher-pulse::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 2px solid #10b981;
  animation: chPulseAnimation 2s infinite;
}

@keyframes chPulseAnimation {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Unread Badge */
.ch-unread-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background-color: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  animation: chBounce 0.4s ease;
}

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

/* Proactive Greeting Tooltip */
.ch-greeting-bubble {
  position: absolute;
  bottom: 74px;
  right: 0;
  background: #ffffff;
  color: #1e293b;
  padding: 12px 34px 12px 16px;
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  font-size: 13px;
  line-height: 1.4;
  width: 260px;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  animation: chSlideUp 0.35s ease;
}

.ch-greeting-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  transform: rotate(45deg);
}

.ch-greeting-close {
  position: absolute;
  top: 8px;
  right: 10px;
  color: #94a3b8;
  font-size: 12px;
  padding: 2px 4px;
  cursor: pointer;
}

.ch-greeting-close:hover {
  color: #475569;
}

/* ── Expandable Chat Window Drawer ── */
.ch-chat-drawer {
  pointer-events: auto;
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: var(--ch-chat-shadow);
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: chDrawerOpen 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chDrawerOpen {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

/* Drawer Header */
.ch-drawer-header {
  background: linear-gradient(135deg, #800020 0%, #5e0018 100%);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ch-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ch-header-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.ch-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #800020;
  border-radius: 50%;
}

.ch-header-titles h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: #ffffff;
}

.ch-header-titles p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ch-live-indicator {
  color: #10b981;
  font-size: 9px;
}

.ch-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ch-wa-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #25d366;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.ch-wa-header-btn:hover {
  transform: scale(1.08);
  opacity: 0.95;
}

.ch-minimize-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.ch-minimize-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Quick Action Chips Bar */
.ch-chips-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #edf2f7;
  scrollbar-width: none;
  flex-shrink: 0;
}

.ch-chips-bar::-webkit-scrollbar {
  display: none;
}

.ch-chip {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 100px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.ch-chip:hover {
  border-color: var(--ch-chat-primary);
  color: var(--ch-chat-primary);
  background: #fff5f7;
}

/* Messages Feed */
.ch-messages-feed {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fbfcfe;
  scroll-behavior: smooth;
}

.ch-msg-time-divider {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  margin: 4px 0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Message Bubble */
.ch-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: chMsgIn 0.2s ease;
}

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

.ch-msg-row.ch-user {
  align-self: flex-end;
  align-items: flex-end;
}

.ch-msg-row.ch-admin,
.ch-msg-row.ch-bot {
  align-self: flex-start;
  align-items: flex-start;
}

.ch-msg-sender {
  font-size: 10.5px;
  color: #64748b;
  margin-bottom: 3px;
  font-weight: 600;
}

.ch-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}

.ch-user .ch-msg-bubble {
  background: linear-gradient(135deg, #800020 0%, #9b0c30 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ch-admin .ch-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.ch-bot .ch-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #f1f5f9;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}

.ch-msg-time {
  font-size: 10px;
  margin-top: 4px;
  color: #94a3b8;
  opacity: 0.9;
}

/* Rich Payload Cards (Coupons / Order Tracking) */
.ch-coupon-card {
  margin-top: 8px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px dashed #f59e0b;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ch-coupon-code {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #b45309;
  background: #ffffff;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-block;
  align-self: flex-start;
  border: 1px solid #fde68a;
}

.ch-coupon-desc {
  font-size: 11.5px;
  color: #78350f;
  margin: 0;
}

.ch-order-card {
  margin-top: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
}

.ch-order-card-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}

.ch-order-badge {
  background: #dcfce7;
  color: #166534;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  text-transform: uppercase;
}

/* Typing Indicator */
.ch-typing {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fbfcfe;
  flex-shrink: 0;
}

.ch-typing span {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: chTyping 1.2s infinite ease-in-out;
}

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

.ch-typing small {
  margin-left: 6px;
  color: #64748b;
  font-size: 11px;
}

@keyframes chTyping {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Chat Footer Input */
.ch-chat-footer {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #edf2f7;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.ch-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ch-input-wrapper:focus-within {
  border-color: var(--ch-chat-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.1);
}

.ch-input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  color: #1e293b;
  padding: 6px 0;
}

.ch-send-btn {
  background: var(--ch-chat-primary);
  color: #ffffff;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.ch-send-btn:hover {
  background: var(--ch-chat-primary-hover);
  transform: scale(1.05);
}

.ch-footer-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: #94a3b8;
  padding: 0 4px;
}

.ch-footer-wa-link {
  color: #059669;
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}

.ch-footer-wa-link:hover {
  text-decoration: underline;
}

/* ── Guest Lead Capture Modal ── */
.ch-guest-modal {
  position: absolute;
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  z-index: 100;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  animation: chFadeIn 0.25s ease;
}

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

.ch-guest-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.ch-guest-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.ch-guest-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 6px 0;
}

.ch-guest-card p {
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
  margin: 0 0 16px 0;
}

.ch-form-group {
  text-align: left;
  margin-bottom: 12px;
}

.ch-form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}

.ch-form-group input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-size: 13px;
  color: #0f172a;
  outline: none;
  background: #f8fafc;
  transition: all 0.15s ease;
}

.ch-form-group input:focus {
  border-color: var(--ch-chat-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.12);
}

.ch-guest-btn {
  width: 100%;
  padding: 10px 16px;
  background: linear-gradient(135deg, #800020 0%, #9c0b2b 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(128, 0, 32, 0.25);
  transition: all 0.15s ease;
  margin-top: 14px;
}

.ch-guest-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(128, 0, 32, 0.35);
}

.ch-guest-skip {
  margin-top: 12px;
}

.ch-guest-skip button {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 11.5px;
  cursor: pointer;
  text-decoration: underline;
}

.ch-guest-skip button:hover {
  color: #64748b;
}

/* ── Mobile Responsive Overlay ── */
@media (max-width: 768px) {
  .ch-chat-root {
    /* Elevate cleanly above mobile bottom navigation tabs (Home, Categories, Wishlist, Cart, Account) */
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    right: 16px;
  }

  .ch-chat-launcher {
    width: 54px;
    height: 54px;
    box-shadow: 0 6px 20px rgba(128, 0, 32, 0.45);
  }

  .ch-greeting-bubble {
    width: min(280px, calc(100vw - 32px));
    bottom: 66px;
    right: 0;
    font-size: 12.5px;
    padding: 10px 32px 10px 14px;
    border-radius: 14px;
  }

  /* Full viewport bottom-sheet drawer on mobile */
  .ch-chat-drawer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    box-shadow: none !important;
    z-index: 999999 !important;
    animation: chMobileSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    display: flex;
    flex-direction: column;
  }

  @keyframes chMobileSlideUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* When drawer is active on mobile, hide floating launcher bubble */
  .ch-chat-root.ch-drawer-active .ch-chat-launcher {
    display: none !important;
  }

  /* Mobile Drawer Header with Safe-Area Inset */
  .ch-drawer-header {
    padding: max(14px, env(safe-area-inset-top, 14px)) 16px 14px 16px;
    border-radius: 0;
  }

  .ch-header-avatar {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .ch-header-titles h4 {
    font-size: 15px;
    font-weight: 700;
  }

  .ch-header-titles p {
    font-size: 11px;
    margin-top: 1px;
  }

  .ch-wa-header-btn {
    width: 36px;
    height: 36px;
  }

  .ch-minimize-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.22);
  }

  /* Horizontal Scrollable Chips on Mobile */
  .ch-chips-bar {
    padding: 8px 12px;
    gap: 6px;
    background: #f8fafc;
    -webkit-overflow-scrolling: touch;
  }

  .ch-chip {
    font-size: 11.5px;
    padding: 5px 12px;
    border-radius: 100px;
  }

  /* Message Feed with Touch Inertial Scrolling */
  .ch-messages-feed {
    padding: 14px 12px;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .ch-msg-row {
    max-width: 88%;
  }

  .ch-msg-bubble {
    font-size: 14px;
    line-height: 1.45;
    padding: 10px 14px;
    border-radius: 18px;
  }

  .ch-user .ch-msg-bubble {
    border-bottom-right-radius: 4px;
  }

  .ch-admin .ch-msg-bubble,
  .ch-bot .ch-msg-bubble {
    border-bottom-left-radius: 4px;
  }

  /* Input Footer Locked to Screen Bottom with Safe Area */
  .ch-chat-footer {
    padding: 8px 12px max(12px, env(safe-area-inset-bottom, 12px)) 12px;
    gap: 6px;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
  }

  .ch-input-wrapper {
    padding: 3px 4px 3px 14px;
    background: #f1f5f9;
    border-radius: 28px;
  }

  .ch-input-wrapper input {
    font-size: 16px; /* CRITICAL: Prevents unwanted page auto-zooming in mobile Safari */
    padding: 8px 0;
    color: #0f172a;
  }

  .ch-input-wrapper input::placeholder {
    font-size: 13.5px;
    color: #94a3b8;
  }

  .ch-send-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
  }

  .ch-footer-note {
    font-size: 10px;
    padding: 0 4px;
  }

  /* Guest Lead Capture Sheet on Mobile */
  .ch-guest-modal {
    top: 68px;
    padding: 24px 18px;
    overflow-y: auto;
  }

  .ch-guest-card {
    max-width: 100%;
  }

  .ch-guest-card h3 {
    font-size: 18px;
  }

  .ch-guest-btn {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 12px;
  }
}

