/* static/jomashop/chat.css - Jomashop Luxury Live Chat Styling */

:root {
  --chat-primary: #000000;
  --chat-primary-hover: #1a1a1a;
  --chat-accent: #2563eb;
  --chat-bg: #ffffff;
  --chat-bubble-visitor: #111827;
  --chat-bubble-visitor-text: #ffffff;
  --chat-bubble-staff: #f3f4f6;
  --chat-bubble-staff-text: #1f2937;
  --chat-border: #e5e7eb;
  --chat-online: #10b981;
  --chat-offline: #f59e0b;
}

/* 1. Floating Launcher Button */
.chat-launcher-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #000000;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999990;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background-color 0.2s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.chat-launcher-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  background: #1a1a1a;
}

.chat-launcher-btn:active {
  transform: scale(0.95);
}

.chat-launcher-icon {
  width: 28px;
  height: 28px;
  transition: transform 0.2s ease;
}

.chat-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  box-sizing: border-box;
}

.chat-status-dot-launcher {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: var(--chat-online);
}

.chat-status-dot-launcher.offline {
  background: var(--chat-offline);
}

/* 2. Main Chat Box */
.chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 570px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--chat-border);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999995;
  animation: chatSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.chat-window.open {
  display: flex;
}

@keyframes chatSlideUp {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Chat Header */
.chat-header {
  background: #000000;
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #222222;
  user-select: none;
}

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

.chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(255,255,255,0.15);
  flex-shrink: 0;
}

.chat-header-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-header-brand {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.chat-header-status {
  font-size: 11px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-status-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chat-online);
  display: inline-block;
}

.chat-status-pulse.offline {
  background: var(--chat-offline);
}

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

.chat-action-btn {
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.chat-action-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Offline Notice Banner */
.chat-offline-banner {
  background: #fffbeb;
  border-bottom: 1px solid #fef3c7;
  color: #92400e;
  font-size: 12px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

.chat-offline-banner svg {
  flex-shrink: 0;
}

/* Chat Messages Stream */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fafafa;
  position: relative;
  overscroll-behavior: contain;
}

.chat-welcome-card {
  background: #ffffff;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  margin-bottom: 8px;
}

.chat-welcome-title {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}

.chat-welcome-text {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.45;
}

.chat-date-separator {
  text-align: center;
  margin: 6px 0;
  position: relative;
}

.chat-date-separator span {
  font-size: 10px;
  font-weight: 600;
  color: #9ca3af;
  background: #fafafa;
  padding: 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Message Rows */
.chat-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  position: relative;
}

.chat-msg-row.visitor {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg-row.staff {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg-sender-name {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 3px;
  padding: 0 4px;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.chat-msg-row.visitor .chat-msg-bubble {
  background: var(--chat-bubble-visitor);
  color: var(--chat-bubble-visitor-text);
  border-bottom-right-radius: 3px;
}

.chat-msg-row.staff .chat-msg-bubble {
  background: var(--chat-bubble-staff);
  color: var(--chat-bubble-staff-text);
  border-bottom-left-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 10px;
  color: #9ca3af;
  padding: 0 4px;
}

.chat-status-icon {
  display: inline-flex;
  align-items: center;
}

.chat-status-read {
  color: #2563eb;
  font-weight: bold;
}

/* Typing Indicator */
.chat-typing-indicator {
  display: none;
  align-self: flex-start;
  align-items: center;
  gap: 4px;
  background: #f3f4f6;
  padding: 8px 12px;
  border-radius: 12px;
  border-bottom-left-radius: 2px;
  margin-bottom: 4px;
}

.chat-typing-indicator.active {
  display: flex;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* History Load Button */
.chat-load-more-btn {
  align-self: center;
  background: #ffffff;
  border: 1px solid var(--chat-border);
  color: #4b5563;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.chat-load-more-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  color: #111827;
}

/* Floating "New Messages" pill */
.chat-new-msg-pill {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #000000;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  display: none;
  align-items: center;
  gap: 5px;
  z-index: 10;
  animation: bounceIn 0.25s ease;
}

.chat-new-msg-pill.active {
  display: flex;
}

@keyframes bounceIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Chat Footer / Input Box */
.chat-footer {
  background: #ffffff;
  border-top: 1px solid var(--chat-border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #f9fafb;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  padding: 8px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.chat-input-row:focus-within {
  border-color: #111827;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.08);
}

.chat-textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 13px;
  color: #111827;
  line-height: 1.45;
  max-height: 100px;
  min-height: 22px;
  font-family: inherit;
  padding: 0;
}

.chat-textarea::placeholder {
  color: #9ca3af;
}

.chat-send-btn {
  background: #000000;
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.chat-send-btn:hover:not(:disabled) {
  background: #2563eb;
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

.chat-footer-note {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #9ca3af;
  padding: 0 4px;
}

/* Mobile Responsive Adaptations */
@media (max-width: 640px) {
  .chat-window {
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 9999999 !important;
  }

  .chat-header {
    padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
  }

  .chat-footer {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  }

  .chat-launcher-btn {
    bottom: 18px;
    right: 18px;
    width: 52px;
    height: 52px;
  }
}

/* 🎟️ Exclusive VIP Coupon Card in Chat */
.chat-coupon-card {
  background: linear-gradient(135deg, #18181b 0%, #27272a 100%);
  color: #ffffff;
  border-radius: 12px;
  padding: 16px;
  margin: 4px 0;
  border: 1px solid #3f3f46;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  min-width: 240px;
  max-width: 320px;
  text-align: left;
}

.chat-coupon-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #facc15;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-coupon-discount {
  font-size: 22px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.chat-coupon-code-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed #71717a;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  gap: 8px;
}

.chat-coupon-code {
  font-family: monospace;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #67e8f9;
}

.chat-coupon-copy-btn {
  background: #ffffff;
  color: #000000;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.chat-coupon-copy-btn:hover {
  opacity: 0.9;
}

.chat-coupon-meta {
  font-size: 11px;
  color: #a1a1aa;
  margin-bottom: 4px;
}

.chat-coupon-note {
  font-size: 11px;
  color: #71717a;
  margin-bottom: 12px;
}

.chat-coupon-apply-btn {
  width: 100%;
  background: #22c55e;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s ease;
}

.chat-coupon-apply-btn:hover {
  background: #16a34a;
}

