/* =============================================
   CHAT WIDGET — chat-widget.css
   Place in: wwwroot/css/chat-widget.css
   ============================================= */

/* ── Google Fonts (load in <head> or keep here) ── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ========== FAB BUTTON ========== */
#chatFab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 60px;
  height: 60px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  z-index: 9999;
  background: linear-gradient(145deg, #1a3a8f, #0B1C4D);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s ease;
  box-shadow: 0 8px 24px rgba(11, 28, 77, .55), 0 2px 8px rgba(11, 28, 77, .25), inset 0 1px 0 rgba(255, 255, 255, .12);
}

#chatFab:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 16px 40px rgba(11, 28, 77, .65);
}

/* Ripple ring */
#chatFab::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 26px;
  border: 2px solid rgba(99, 179, 237, .35);
  animation: fabRing 2.6s ease-out infinite;
}

@keyframes fabRing {
  0%   { transform: scale(1);   opacity: .8; }
  70%  { transform: scale(1.3); opacity: 0;  }
  100% { transform: scale(1.3); opacity: 0;  }
}

#chatFab:hover::before {
  animation: none;
  opacity: 0;
}

/* Notification dot */
.notif-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 15px;
  height: 15px;
  background: #f43f5e;
  border-radius: 50%;
  border: 2.5px solid #fff;
  animation: dotPop .35s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes dotPop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* ========== CHAT WINDOW ========== */
#chatWindow {
  position: fixed;
  right: 28px;
  bottom: 104px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #f5f4f0;
  border-radius: 24px;
  box-shadow: 0 32px 96px rgba(0, 0, 0, .35), 0 8px 32px rgba(0, 0, 0, .18), 0 0 0 1px rgba(255, 255, 255, .08);
  display: none;
  flex-direction: column;
  z-index: 9999;
  font-family: 'DM Sans', sans-serif;
  overflow: hidden;
  transform-origin: bottom right;
}

#chatWindow.open {
  display: flex;
  animation: windowOpen .3s cubic-bezier(.34, 1.56, .64, 1) both;
}

#chatWindow.closing {
  animation: windowClose .22s ease forwards;
}

@keyframes windowOpen {
  from { opacity: 0; transform: scale(.86) translateY(16px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);    }
}

@keyframes windowClose {
  from { opacity: 1; transform: scale(1)   translateY(0);    }
  to   { opacity: 0; transform: scale(.88) translateY(12px); }
}

/* ========== HEADER ========== */
#chatHeader {
  flex: 0 0 auto;
  background: linear-gradient(135deg, #0d1f52 0%, #0B1C4D 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

/* Grain texture overlay */
#chatHeader::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* Decorative glow orb */
#chatHeader::before {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(99, 179, 237, .15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.avatar-shell {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(99, 179, 237, .25), rgba(11, 28, 77, .4));
  border: 1px solid rgba(255, 255, 255, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
}

.online-ring {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 13px;
  height: 13px;
  background: #22d3a0;
  border-radius: 50%;
  border: 2.5px solid #0B1C4D;
  box-shadow: 0 0 8px rgba(34, 211, 160, .6);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px  rgba(34, 211, 160, .5); }
  50%       { box-shadow: 0 0 16px rgba(34, 211, 160, .9); }
}

.header-text { line-height: 1.25; }

.header-text strong {
  font-family: 'Syne', sans-serif;
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  display: block;
  letter-spacing: .01em;
}

.header-text span {
  font-size: 11.5px;
  color: rgba(255, 255, 255, .5);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 5px;
}

.header-text span::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #22d3a0;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  position: relative;
  z-index: 1;
}

#closeChat {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, .13);
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .75);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .15s;
}

#closeChat:hover {
  background: rgba(255, 255, 255, .16);
  transform: scale(1.07);
}

/* ========== QUICK CHIPS ========== */
#quickChips {
  flex: 0 0 auto;
  padding: 10px 14px 6px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  background: #f5f4f0;
  scrollbar-width: none;
}

#quickChips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  border: 1.5px solid #dbd7d1;
  background: #fff;
  color: #3d3530;
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.chip:hover {
  border-color: #0B1C4D;
  color: #0B1C4D;
  background: #eef1f8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(11, 28, 77, .15);
}

/* ========== MESSAGES ========== */
#chatBody {
  flex: 1 1 auto;
  padding: 10px 14px;
  overflow-y: auto;
  background: #f5f4f0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#chatBody::-webkit-scrollbar       { width: 3px; }
#chatBody::-webkit-scrollbar-track { background: transparent; }
#chatBody::-webkit-scrollbar-thumb { background: #d0cbc3; border-radius: 4px; }

.msg {
  display: flex;
  gap: 8px;
  animation: msgIn .22s ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);   }
}

.msg.user { justify-content: flex-end; }
.msg.bot  { justify-content: flex-start; align-items: flex-end; }

.bot-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(145deg, #0d1f52, #1a3a8f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(11, 28, 77, .3);
}

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
}

.user .bubble {
  background: linear-gradient(135deg, #1a3a8f, #0B1C4D);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 16px rgba(11, 28, 77, .3);
}

.bot .bubble {
  background: #fff;
  color: #1a1612;
  border: 1px solid #e8e4de;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .07);
}

/* Timestamps */
.msg-time {
  font-size: 10px;
  color: #b0a99e;
  margin-top: 3px;
  text-align: right;
  padding: 0 4px;
}

.msg.bot .msg-time {
  text-align: left;
  padding-left: 36px;
}

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 5px;
  padding: 13px 16px;
  background: #fff;
  border: 1px solid #e8e4de;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .07);
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: #b0a99e;
  border-radius: 50%;
  animation: typingDot 1.3s ease infinite;
}

.typing-dots span:nth-child(2) { animation-delay: .22s; }
.typing-dots span:nth-child(3) { animation-delay: .44s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0);    opacity: .4; }
  30%            { transform: translateY(-6px); opacity: 1;  }
}

/* ========== FOOTER / INPUT AREA ========== */
#chatFooter {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid #e8e4de;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Email row */
.email-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f5f4f0;
  border-radius: 12px;
  border: 1.5px solid #e8e4de;
  transition: border-color .15s, box-shadow .15s;
}

.email-row:focus-within {
  border-color: #0B1C4D;
  box-shadow: 0 0 0 3px rgba(11, 28, 77, .1);
}

.email-icon {
  width: 16px;
  height: 16px;
  color: #9f9690;
  flex-shrink: 0;
}

.email-row input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 12.5px;
  color: #1a1612;
  outline: none;
}

.email-row input::placeholder { color: #c0b9b2; }

/* Message input row */
.msg-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #f5f4f0;
  border-radius: 14px;
  border: 1.5px solid #e8e4de;
  transition: border-color .15s, box-shadow .15s;
}

.msg-input-row:focus-within {
  border-color: #0B1C4D;
  box-shadow: 0 0 0 3px rgba(11, 28, 77, .1);
}

#chatMessage {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: #1a1612;
  outline: none;
  resize: none;
  min-height: 20px;
  max-height: 80px;
  line-height: 1.45;
  overflow-y: auto;
}

#chatMessage::placeholder { color: #c0b9b2; }

#sendBtn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: none;
  background: linear-gradient(145deg, #1a3a8f, #0B1C4D);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s ease, opacity .2s;
  box-shadow: 0 4px 14px rgba(11, 28, 77, .35);
}

#sendBtn:hover:not(:disabled) {
  transform: scale(1.12) translateY(-1px);
  box-shadow: 0 8px 22px rgba(11, 28, 77, .5);
}

#sendBtn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

/* Bottom meta bar */
.footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#status {
  font-size: 11.5px;
  color: #6b6358;
  min-height: 14px;
}

#status.success { color: #059669; font-weight: 500; }
#status.error   { color: #dc2626; font-weight: 500; }

/* WhatsApp in-widget button */
.wa-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid #dcfce7;
  background: #f0fdf4;
  color: #166534;
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'Syne', sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .15s;
}

.wa-btn:hover {
  background: #dcfce7;
  transform: translateY(-1px);
  color: #166534;
  text-decoration: none;
}

.wa-btn svg { color: #16a34a; }

/* ========== SUPPORT ESCALATION PANEL ========== */
#supportPanel {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #f0f4ff, #f5f4f0);
  border-top: 1px solid #e8e4de;
  animation: slideUp .22s ease both;
}

#supportPanel.visible {
  display: flex;
}

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

.support-header {
  font-family: 'Syne', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #6b6358;
  display: flex;
  align-items: center;
  gap: 6px;
}

.support-header svg { color: #0B1C4D; }

#supportBtn {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #0d1f52, #0B1C4D);
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s ease, opacity .2s;
  box-shadow: 0 4px 16px rgba(11, 28, 77, .35);
  position: relative;
  overflow: hidden;
}

/* Shimmer sweep on hover */
#supportBtn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, .08) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform .4s ease;
}

#supportBtn:hover::before         { transform: translateX(100%); }

#supportBtn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(11, 28, 77, .45);
}

#supportBtn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

#supportStatus {
  font-size: 11.5px;
  min-height: 14px;
  text-align: center;
  color: #6b6358;
}

#supportStatus.success { color: #059669; font-weight: 600; }
#supportStatus.error   { color: #dc2626; font-weight: 600; }

/* ========== FLOATING WHATSAPP BUTTON ========== */
#waButton {
  position: fixed;
  right: 20px;
  bottom: 100px;
  width: 58px;
  height: 58px;
  background: #25D366;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .30);
  z-index: 10000;
  text-decoration: none;
  transition: transform .18s ease-in-out;
}

#waButton:hover { transform: scale(1.08); }

/* Tooltip bubble */
#waButton .waTooltip {
  position: absolute;
  right: 70px;
  top: 50%;
  transform: translateY(-50%);
  background: #111827;
  color: #fff;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease-in-out, transform .15s ease-in-out;
  box-shadow: 0 10px 20px rgba(0, 0, 0, .25);
}

/* Tooltip arrow */
#waButton .waTooltip::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent transparent #111827;
}

#waButton:hover .waTooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(-2px);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 420px) {
  #chatWindow {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    height: 92vh;
    max-height: 92vh;
  }

  #chatFab { right: 20px; bottom: 20px; }

  #waButton { right: 16px; bottom: 92px; }
  #waButton .waTooltip { display: none; }
}