/* =============================================
   CBS PEWOSA CHAT WIDGET — chat-widget.css
   Place in: wwwroot/css/chat-widget.css
   Requires: Syne + DM Sans fonts in _Layout
   ============================================= */

/* ========== FAB BUTTON ========== */
#chatFab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  z-index: 9999;
  background: linear-gradient(145deg, #b8860b, #8f1564);
  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(143, 21, 100, .45), 0 2px 8px rgba(143, 21, 100, .2), inset 0 1px 0 rgba(255, 255, 255, .15);
}

#chatFab:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 16px 40px rgba(143, 21, 100, .6);
}

#chatFab::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 24px;
  border: 2px solid rgba(184, 134, 11, .45);
  animation: fabRing 2.8s 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; }

.notif-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  background: #b8860b;
  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;
  width: 375px;
  max-width: calc(100vw - 32px);
  height: 570px;
  max-height: calc(100vh - 120px);
  background: #faf9f7;
  border-radius: 22px;
  box-shadow: 0 32px 96px rgba(0, 0, 0, .28), 0 8px 32px rgba(0, 0, 0, .14), 0 0 0 1px rgba(143, 21, 100, .08);
  display: none;
  flex-direction: column;
  z-index: 9999;
  font-family: 'Poppins', 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, #5d0d41 0%, #8f1564 60%, #b0197b 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

#chatHeader::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(184, 134, 11, .15) 0%, transparent 55%);
  pointer-events: none;
}

#chatHeader::before {
  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='.04'/%3E%3C/svg%3E");
  pointer-events: none;
}

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

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

.avatar-shell {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(184, 134, 11, .35), rgba(143, 21, 100, .5));
  border: 1px solid rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15);
}

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

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

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

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

.header-text span {
  font-size: 11px;
  color: rgba(255, 255, 255, .55);
  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 { position: relative; z-index: 1; }

#closeChat {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .15);
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .15s;
}

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

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

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

.chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  border: 1.5px solid #e0d9d0;
  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: #8f1564;
  color: #8f1564;
  background: #fff5f5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(143, 21, 100, .15);
}

/* ========== MESSAGES ========== */
#chatBody {
  flex: 1 1 auto;
  padding: 10px 13px;
  overflow-y: auto;
  background: #faf9f7;
  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: #d5cfc6; 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, #5d0d41, #8f1564);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(143, 21, 100, .3);
}

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

.user .bubble {
  background: linear-gradient(135deg, #8f1564, #5d0d41);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 16px rgba(143, 21, 100, .28);
}

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

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

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

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

.typing-dots span {
  width: 7px;
  height: 7px;
  background: #c4a882;
  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 ========== */
#chatFooter {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid #ede8e1;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.email-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  background: #faf9f7;
  border-radius: 11px;
  border: 1.5px solid #ede8e1;
  transition: border-color .15s, box-shadow .15s;
}

.email-row:focus-within {
  border-color: #8f1564;
  box-shadow: 0 0 0 3px rgba(143, 21, 100, .1);
}

.email-icon {
  width: 15px;
  height: 15px;
  color: #b0a99e;
  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: #c8c0b6; }

.msg-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 11px;
  background: #faf9f7;
  border-radius: 13px;
  border: 1.5px solid #ede8e1;
  transition: border-color .15s, box-shadow .15s;
}

.msg-input-row:focus-within {
  border-color: #8f1564;
  box-shadow: 0 0 0 3px rgba(143, 21, 100, .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: #c8c0b6; }

#sendBtn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: none;
  background: linear-gradient(145deg, #b0197b, #8f1564);
  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(143, 21, 100, .35);
}

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

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

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

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

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

.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;
}

/* ========== SUPPORT PANEL ========== */
#supportPanel {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 11px 13px;
  background: linear-gradient(135deg, #fff8f0, #faf9f7);
  border-top: 1px solid #ede8e1;
}

#supportPanel.visible {
  display: flex;
  animation: slideUp .22s ease both;
}

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

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

.support-header svg { color: #8f1564; }

#supportBtn {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #5d0d41, #8f1564);
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .03em;
  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(143, 21, 100, .3);
  position: relative;
  overflow: hidden;
}

#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(143, 21, 100, .4); }
#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; }

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