/* WhatsApp Web Replica Chat Interface for Sonu 567 Support */
:root {
  --wa-bg: #efeae2;
  --wa-header-bg: #075e54;
  --wa-header-dark: #128c7e;
  --wa-incoming: #ffffff;
  --wa-outgoing: #d9fdd3;
  --wa-accent: #25d366;
  --wa-text: #111b21;
  --wa-subtext: #667781;
  --wa-border: #e9edef;
  --wa-check: #53bdeb;
}

.chat-viewport {
  background-color: var(--wa-bg);
  background-image: radial-gradient(#d1d7db 0.75px, transparent 0.75px);
  background-size: 16px 16px;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  background: #ffffff;
}

@media (max-width: 640px) {
  .chat-container {
    height: 100dvh;
    border-radius: 0;
  }
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, #021812 0%, #04241b 100%);
  color: #ffffff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #f3ba2f;
  z-index: 20;
}

/* Message Bubbles */
.message-row {
  display: flex;
  margin-bottom: 0.65rem;
  padding: 0 0.5rem;
}

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

.message-row.agent {
  justify-content: flex-start;
}

.bubble {
  max-width: 82%;
  padding: 0.65rem 0.95rem;
  border-radius: 1rem;
  font-size: 0.925rem;
  line-height: 1.45;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  animation: bubblePop 0.25s ease-out;
}

@keyframes bubblePop {
  0% { transform: scale(0.96); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.bubble.user {
  background-color: var(--wa-outgoing);
  color: var(--wa-text);
  border-bottom-right-radius: 0.25rem;
}

.bubble.agent {
  background-color: var(--wa-incoming);
  color: var(--wa-text);
  border-bottom-left-radius: 0.25rem;
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--wa-subtext);
}

.double-check {
  color: var(--wa-check);
  font-size: 0.85rem;
}

/* Audio Player Bubble */
.audio-player-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.03);
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  min-width: 240px;
}

.audio-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e5b83b;
  color: #38000d;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: transform 0.2s;
}

.audio-play-btn:hover {
  transform: scale(1.08);
}

.audio-waveform-bar {
  flex: 1;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.audio-progress {
  height: 100%;
  width: 0%;
  background: #4a0516;
  transition: width 0.1s linear;
}

/* Typing Indicator */
.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.65rem 1rem;
  background: #ffffff;
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  margin-bottom: 0.5rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: jumpingDot 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Quick Replies */
.quick-pills {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 1rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  scrollbar-width: none;
}
.quick-pills::-webkit-scrollbar { display: none; }

.quick-pill-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 0.35rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-pill-btn:hover {
  background: #4a0516;
  color: #ffffff;
  border-color: #4a0516;
}

/* Voice Recording State */
.recording-active {
  background: #fee2e2 !important;
  color: #ef4444 !important;
  animation: recordPulse 1.5s infinite;
}

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

/* Clickable Links inside Chat Bubbles */
.chat-inline-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #04241b !important;
  background: rgba(243, 186, 47, 0.22);
  border: 1px solid rgba(243, 186, 47, 0.5);
  padding: 0.15rem 0.55rem;
  border-radius: 0.5rem;
  font-weight: 700;
  text-decoration: none !important;
  word-break: break-all;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.chat-inline-link:hover {
  background: #f3ba2f;
  color: #021812 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(243, 186, 47, 0.35);
}

/* Message Hover Actions (Reply & Copy) */
.bubble-wrapper {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  max-width: 84%;
}
.message-row.user .bubble-wrapper {
  align-items: flex-end;
}
.message-row.agent .bubble-wrapper {
  align-items: flex-start;
}

.message-actions-bar {
  display: none;
  position: absolute;
  top: -12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 2px 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  z-index: 10;
  gap: 4px;
}
.message-row:hover .message-actions-bar,
.message-row:focus-within .message-actions-bar {
  display: flex;
}
.message-row.user .message-actions-bar {
  right: 10px;
}
.message-row.agent .message-actions-bar {
  left: 10px;
}

.msg-action-btn {
  background: transparent;
  border: none;
  color: #64748b;
  padding: 4px 6px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s;
}
.msg-action-btn:hover {
  background: #f1f5f9;
  color: #04241b;
}

/* WhatsApp-Style Quoted Message Inside Bubble */
.quoted-snippet-box {
  background: rgba(0, 0, 0, 0.05);
  border-left: 3px solid #04241b;
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 0.78rem;
  line-height: 1.35;
  cursor: pointer;
}
.bubble.user .quoted-snippet-box {
  background: rgba(4, 36, 27, 0.08);
  border-left-color: #04241b;
}
.bubble.agent .quoted-snippet-box {
  background: rgba(243, 186, 47, 0.14);
  border-left-color: #c69214;
}
.quoted-author {
  font-weight: 700;
  font-size: 0.72rem;
  color: #04241b;
  margin-bottom: 2px;
}
.quoted-text {
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

/* Reply Preview Bar above Input Bar */
#reply-preview-bar {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  border-left: 4px solid #04241b;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideUp 0.2s ease-out;
}
#reply-preview-bar.hidden {
  display: none !important;
}
@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Toast Feedback */
.chat-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #021812;
  color: #f3ba2f;
  border: 1px solid rgba(243, 186, 47, 0.4);
  padding: 8px 16px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}
.chat-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Swipe Right to Reply Engine */
.swipe-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
}
.message-row.user .swipe-container {
  justify-content: flex-end;
}
.message-row.agent .swipe-container {
  justify-content: flex-start;
}

.swipe-reply-hint {
  position: absolute;
  left: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #04241b;
  color: #f3ba2f;
  border: 1px solid rgba(243, 186, 47, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.15s;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.swipe-reply-hint.active {
  background: #f3ba2f;
  color: #04241b;
  transform: scale(1.15);
  box-shadow: 0 0 16px rgba(243, 186, 47, 0.6);
}

.bubble {
  touch-action: pan-y;
  user-select: text;
  will-change: transform;
}
.bubble.swiping {
  transition: none !important;
}
.bubble.snap-back {
  transition: transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

/* WhatsApp Forward Modal Sheet */
.forward-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
@media (min-width: 640px) {
  .forward-sheet-backdrop {
    align-items: center;
  }
}
.forward-sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}
.forward-sheet {
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 440px;
  padding: 1.25rem;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (min-width: 640px) {
  .forward-sheet {
    border-radius: 20px;
    transform: scale(0.95);
  }
}
.forward-sheet-backdrop.active .forward-sheet {
  transform: translateY(0);
}
@media (min-width: 640px) {
  .forward-sheet-backdrop.active .forward-sheet {
    transform: scale(1);
  }
}

