/**
 * Chat Widget Styles - WhatsApp-inspired design
 */

/* Chat Button */
.chat-widget-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-widget-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
}

.chat-widget-button svg {
  width: 28px;
  height: 28px;
  fill: white;
}

.chat-widget-button .close-icon {
  display: none;
}

.chat-widget-button.active .chat-icon {
  display: none;
}

.chat-widget-button.active .close-icon {
  display: block;
}

/* Chat Window */
.chat-widget-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 140px);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 9998;
  display: none;
  flex-direction: column;
  background: var(--chat-bg, #e5ddd5);
}

.chat-widget-window.active {
  display: flex;
  animation: slideUp 0.3s ease;
}

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

/* Dark theme support */
[data-theme="dark"] .chat-widget-window {
  --chat-bg: #0b141a;
  --chat-header-bg: #1f2c34;
  --chat-input-bg: #1f2c34;
  --chat-bubble-user: #005c4b;
  --chat-bubble-bot: #1f2c34;
  --chat-text: #e9edef;
  --chat-text-muted: #8696a0;
  --chat-border: #2a3942;
}

[data-theme="light"] .chat-widget-window,
.chat-widget-window {
  --chat-bg: #e5ddd5;
  --chat-header-bg: #075e54;
  --chat-input-bg: #f0f2f5;
  --chat-bubble-user: #dcf8c6;
  --chat-bubble-bot: #ffffff;
  --chat-text: #111b21;
  --chat-text-muted: #667781;
  --chat-border: #e9edef;
}

/* Chat Header */
.chat-widget-header {
  background: var(--chat-header-bg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-widget-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.chat-widget-header-info {
  flex: 1;
}

.chat-widget-header-name {
  color: white;
  font-weight: 600;
  font-size: 16px;
}

.chat-widget-header-status {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.chat-header-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 50%;
  transition: background 0.2s;
}
.chat-header-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

/* Chat Messages Area */
.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

[data-theme="dark"] .chat-widget-messages {
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Message Bubbles */
.chat-message {
  display: flex;
  margin-bottom: 8px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-message.bot {
  justify-content: flex-start;
}

.chat-message-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 8px;
  position: relative;
  word-wrap: break-word;
}

.chat-message.user .chat-message-bubble {
  background: var(--chat-bubble-user);
  color: var(--chat-text);
  border-bottom-right-radius: 2px;
}

.chat-message.bot .chat-message-bubble {
  background: var(--chat-bubble-bot);
  color: var(--chat-text);
  border-bottom-left-radius: 2px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.chat-message-text {
  font-size: 14px;
  line-height: 1.4;
}

.chat-message-time {
  font-size: 11px;
  color: var(--chat-text-muted);
  text-align: right;
  margin-top: 4px;
}

/* Typing Indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px;
}

.chat-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chat-text-muted);
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

.chat-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Chat Input Area */
.chat-widget-input-area {
  padding: 8px 16px;
  background: var(--chat-input-bg);
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--chat-border);
}

.chat-widget-input {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 16px;
  background: white;
  color: var(--chat-text);
  outline: none;
}

[data-theme="dark"] .chat-widget-input {
  background: #2a3942;
}

.chat-widget-input::placeholder {
  color: var(--chat-text-muted);
}

.chat-widget-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #25D366;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-widget-send:hover {
  background: #128C7E;
}

.chat-widget-send:disabled {
  background: var(--chat-text-muted);
  cursor: not-allowed;
}

.chat-widget-send svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* Verification Modal */
.chat-verify-modal {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.chat-verify-content {
  background: white;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  max-width: 320px;
}

[data-theme="dark"] .chat-verify-content {
  background: #1f2c34;
  color: #e9edef;
}

.chat-verify-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.chat-verify-text {
  font-size: 14px;
  color: var(--chat-text-muted);
  margin-bottom: 16px;
}

/* Delivery Options */
.chat-delivery-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.chat-delivery-btn {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: 2px solid var(--chat-border);
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.chat-delivery-btn:hover {
  border-color: #25D366;
  background: rgba(37, 211, 102, 0.1);
}

.chat-delivery-btn svg {
  width: 24px;
  height: 24px;
}

.chat-delivery-btn span {
  font-size: 12px;
  font-weight: 500;
}

/* Welcome Message */
.chat-welcome {
  text-align: center;
  padding: 24px 16px;
}

.chat-welcome-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin-bottom: 12px;
}

.chat-welcome-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--chat-text);
  margin-bottom: 4px;
}

.chat-welcome-text {
  font-size: 14px;
  color: var(--chat-text-muted);
}

/* Quick Replies - WhatsApp Business Style (inside bubble) */
.chat-quick-replies {
  display: flex;
  flex-direction: column;
  margin: 8px -12px -8px -12px;
  border-top: 1px solid var(--chat-border, #e9edef);
}

.chat-quick-reply-btn {
  background: transparent;
  border: none;
  border-top: 1px solid var(--chat-border, #e9edef);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #00a884;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease;
  line-height: 1.3;
}

.chat-quick-reply-btn:first-child {
  border-top: none;
}

.chat-quick-reply-btn:hover {
  background: rgba(0, 168, 132, 0.08);
}

.chat-quick-reply-btn:active {
  background: rgba(0, 168, 132, 0.15);
}

/* Dark mode */
[data-theme="dark"] .chat-quick-replies {
  border-top-color: #2a3942;
}

[data-theme="dark"] .chat-quick-reply-btn {
  border-top-color: #2a3942;
  color: #00a884;
}

[data-theme="dark"] .chat-quick-reply-btn:hover {
  background: rgba(0, 168, 132, 0.12);
}

[data-theme="dark"] .chat-quick-reply-btn:active {
  background: rgba(0, 168, 132, 0.2);
}

/* Push Notice */
.chat-push-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  border-radius: 8px;
  background: rgba(37, 211, 102, 0.1);
  border: 1px solid rgba(37, 211, 102, 0.3);
  font-size: 12px;
  line-height: 1.4;
  color: var(--chat-text);
}

.chat-push-notice svg {
  flex-shrink: 0;
  margin-top: 1px;
  fill: #25D366;
}

.chat-push-notice.warning {
  background: rgba(255, 193, 7, 0.1);
  border-color: rgba(255, 193, 7, 0.3);
}

.chat-push-notice.warning svg {
  fill: #ffc107;
}

[data-theme="dark"] .chat-push-notice {
  background: rgba(37, 211, 102, 0.15);
}

[data-theme="dark"] .chat-push-notice.warning {
  background: rgba(255, 193, 7, 0.15);
}

/* WhatsApp-only button (full width) */
.chat-delivery-btn.whatsapp-only {
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: #25D366;
  border-color: #25D366;
  color: white;
}

.chat-delivery-btn.whatsapp-only:hover {
  background: #128C7E;
  border-color: #128C7E;
}

.chat-delivery-btn.whatsapp-only svg {
  fill: white !important;
}

.chat-delivery-btn.whatsapp-only span {
  font-size: 14px;
}

/* WhatsApp link button inside chat bubble */
.chat-wa-link-btn {
  display: inline-block;
  background: #25D366;
  color: #fff !important;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  margin-top: 4px;
  transition: background 0.2s;
}
.chat-wa-link-btn:hover {
  background: #20bd5a;
}

/* Push Instructions Modal */
.chat-push-modal {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.2s ease;
}

.chat-push-modal-content {
  background: white;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  max-width: 300px;
  margin: 16px;
}

[data-theme="dark"] .chat-push-modal-content {
  background: #1f2c34;
  color: #e9edef;
}

.chat-push-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.chat-push-modal-text {
  font-size: 14px;
  color: var(--chat-text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.chat-push-modal-text strong {
  color: #25D366;
}

.chat-push-modal-buttons {
  display: flex;
  gap: 8px;
}

.chat-push-modal-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-push-modal-btn.secondary {
  background: var(--chat-border);
  color: var(--chat-text);
}

.chat-push-modal-btn.secondary:hover {
  background: var(--chat-text-muted);
  color: white;
}

.chat-push-modal-btn.primary {
  background: #25D366;
  color: white;
}

.chat-push-modal-btn.primary:hover {
  background: #128C7E;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chat-widget-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .chat-widget-button {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  /* Hide FAB when chat is open on mobile — header ✕ is sufficient */
  .chat-widget-button.active {
    display: none;
  }
}

/* Web Instructions Button */
.chat-delivery-btn.web-instructions-btn {
  background: #4A90D9;
  color: white;
  border: none;
}
.chat-delivery-btn.web-instructions-btn:hover {
  background: #3A7BC8;
}
.chat-delivery-btn.web-instructions-btn svg {
  fill: white;
}

/* Web Instructions Modal */
.web-instructions-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.web-instructions-modal {
  background: white;
  border-radius: 16px;
  max-width: 360px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
[data-theme="dark"] .web-instructions-modal {
  background: #1f2c34;
  color: #e9edef;
}
.web-instructions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  font-weight: 600;
  font-size: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
[data-theme="dark"] .web-instructions-header {
  border-color: rgba(255,255,255,0.1);
}
.web-instructions-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: inherit;
  padding: 4px 8px;
  border-radius: 8px;
}
.web-instructions-close:hover {
  background: rgba(0,0,0,0.1);
}
.web-instructions-body {
  padding: 16px;
}
.web-instructions-detected {
  background: #f0f2f5;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
[data-theme="dark"] .web-instructions-detected {
  background: #2a3942;
}
.web-instructions-status {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  line-height: 1.4;
}
.web-instructions-status.unsupported,
.web-instructions-status.needs-pwa {
  background: #fff3cd;
  color: #856404;
}
[data-theme="dark"] .web-instructions-status.unsupported,
[data-theme="dark"] .web-instructions-status.needs-pwa {
  background: #3d3520;
  color: #ffc107;
}
.web-instructions-status.ready {
  background: #d4edda;
  color: #155724;
}
[data-theme="dark"] .web-instructions-status.ready {
  background: #1e3a2a;
  color: #28a745;
}
.web-instructions-steps {
  font-size: 14px;
}
.web-instructions-steps strong {
  display: block;
  margin-bottom: 8px;
}
.web-instruction-step {
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  line-height: 1.4;
}
[data-theme="dark"] .web-instruction-step {
  border-color: rgba(255,255,255,0.05);
}
.web-instruction-step:last-child {
  border-bottom: none;
}
