/* ==========================================================================
   NORTON PARK - AI CHAT WIDGET STYLES
   Tuân thủ 100% Brand Tokens từ css/brand-tokens.css
   Kích thước dùng rem, không dùng px cố định (ngoại trừ viền 1px mỏng)
   ========================================================================== */

.np-chat-callout-dot {
  width: 0.5rem;
  height: 0.5rem;
  background: #22C55E;
  border-radius: 999px;
  display: inline-block;
  animation: np-pulse 1.8s infinite;
}

@keyframes np-pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 0.5rem rgba(34, 197, 94, 0.8); }
  100% { transform: scale(0.9); opacity: 0.8; }
}

/* --- Popup Khung Chat (Desktop & Mobile) --- */
.np-chat-popup {
  position: fixed;
  bottom: 6.5rem;
  right: 5.75rem;
  width: 23.75rem; /* ~380px */
  height: 35rem;   /* ~560px */
  max-width: calc(100vw - 2.5rem);
  max-height: calc(100vh - 7rem);
  background: var(--bg-0, #FBFAF6);
  border: 1px solid rgba(167, 128, 97, 0.25);
  border-radius: 1.125rem;
  box-shadow: 
    0 0.75rem 2.5rem rgba(89, 74, 66, 0.2),
    0 0.25rem 0.75rem rgba(89, 74, 66, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transform: translateY(1.25rem) scale(0.96);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.np-chat-popup.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header Khung Chat */
.np-chat-header {
  background: linear-gradient(135deg, var(--hoadau-brown, #594A42) 0%, var(--dark-pine, #5D614F) 100%);
  color: var(--tx-on-dark, #F4F0E7);
  padding: 1rem 1.125rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.np-chat-header-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.np-chat-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #B59A70, #8C7047);
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
}

.np-chat-avatar svg {
  width: 1.25rem;
  height: 1.25rem;
}

.np-chat-title-group h3 {
  font-family: 'The Seasons', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.02em;
  color: #FFFFFF;
}

.np-chat-status-text {
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.725rem;
  color: rgba(244, 240, 231, 0.8);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.np-chat-header-close {
  background: transparent;
  border: none;
  color: rgba(244, 240, 231, 0.7);
  cursor: pointer;
  padding: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  transition: color 0.2s, background 0.2s;
}

.np-chat-header-close:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.15);
}

/* Thân Khung Chat - Danh sách tin nhắn */
.np-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  background: var(--bg-0, #FBFAF6);
  scroll-behavior: smooth;
}

/* Từng dòng tin nhắn */
.np-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: np-msg-fade 0.3s ease forwards;
}

@keyframes np-msg-fade {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

.np-msg--bot {
  align-self: flex-start;
}

.np-msg--user {
  align-self: flex-end;
}

.np-msg-bubble {
  padding: 0.75rem 0.95rem;
  border-radius: 0.875rem;
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.45;
  word-break: break-word;
}

.np-msg--bot .np-msg-bubble {
  background: var(--bg-1, #F2EEE4);
  color: var(--hoadau-brown, #594A42);
  border: 1px solid rgba(89, 74, 66, 0.08);
  border-bottom-left-radius: 0.25rem;
}

.np-msg--user .np-msg-bubble {
  background: linear-gradient(135deg, var(--champagne-bronze, #A78061) 0%, var(--accent-deep, #8E6A4E) 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 0.25rem;
}

.np-msg-time {
  font-size: 0.6875rem;
  color: var(--tx-4, #A39A84);
  margin-top: 0.25rem;
  padding: 0 0.25rem;
}

.np-msg--user .np-msg-time {
  text-align: right;
}

/* Typing Indicator (Đang gõ) */
.np-typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-1, #F2EEE4);
  border-radius: 0.875rem;
  width: fit-content;
  border: 1px solid rgba(89, 74, 66, 0.08);
}

.np-typing-dot {
  width: 0.4rem;
  height: 0.4rem;
  background: var(--champagne-bronze, #A78061);
  border-radius: 999px;
  animation: np-bounce 1.4s infinite ease-in-out both;
}

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

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

/* Thinking Indicator (Đang suy nghĩ — shimmer + dots) */
.np-thinking {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.np-thinking-text {
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.8125rem;
  font-style: italic;
  letter-spacing: 0.01em;
  background: linear-gradient(
    90deg,
    var(--hoadau-brown, #594A42) 0%,
    var(--hoadau-brown, #594A42) 40%,
    var(--champagne-bronze, #A78061) 50%,
    var(--hoadau-brown, #594A42) 60%,
    var(--hoadau-brown, #594A42) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: np-shimmer 2.4s ease-in-out infinite;
}

.np-thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0.1rem;
}

.np-thinking-dots span {
  width: 0.3rem;
  height: 0.3rem;
  background: var(--champagne-bronze, #A78061);
  border-radius: 999px;
  opacity: 0.6;
  animation: np-bounce 1.4s infinite ease-in-out both;
}

.np-thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.np-thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes np-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Quick Chips (Gợi ý câu hỏi nhanh) */
.np-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.np-chip {
  background: var(--bg-0, #FBFAF6);
  border: 1px solid var(--champagne-bronze, #A78061);
  color: var(--hoadau-brown, #594A42);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.np-chip:hover {
  background: var(--champagne-bronze, #A78061);
  color: #FFFFFF;
  transform: translateY(-0.0625rem);
}

/* --- Inline Lead Card (Thu thập Tên + SĐT trong khung chat) --- */
.np-lead-card {
  margin-top: 0.625rem;
  background: #FFFFFF;
  border: 1px solid rgba(167, 128, 97, 0.35);
  border-radius: 0.75rem;
  padding: 0.875rem;
  box-shadow: 0 0.25rem 0.75rem rgba(89, 74, 66, 0.08);
}

.np-lead-card-title {
  font-family: 'The Seasons', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--hoadau-brown, #594A42);
  margin-bottom: 0.35rem;
}

.np-lead-card-desc {
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.775rem;
  color: var(--tx-3, #6E6455);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.np-lead-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.np-lead-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(89, 74, 66, 0.2);
  border-radius: var(--r-input, 0.5rem);
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.8125rem;
  background: var(--bg-0, #FBFAF6);
  color: var(--hoadau-brown, #594A42);
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.np-lead-input:focus {
  border-color: var(--champagne-bronze, #A78061);
  box-shadow: 0 0 0 .125rem rgba(167, 128, 97, 0.15);
}

.np-lead-btn-submit {
  width: 100%;
  padding: 0.6rem;
  background: linear-gradient(135deg, var(--champagne-bronze, #A78061) 0%, var(--accent-deep, #8E6A4E) 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--r-btn, 999px);
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: 0.25rem;
}

.np-lead-btn-submit:hover {
  transform: translateY(-0.0625rem);
  box-shadow: 0 0.25rem 0.625rem rgba(142, 106, 78, 0.35);
}

/* Quick Action Buttons (Zalo OA & Hotline) */
.np-quick-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.625rem;
  padding-top: 0.625rem;
  border-top: 1px dashed rgba(89, 74, 66, 0.15);
}

.np-quick-act-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.5rem;
  border-radius: 0.5rem;
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.725rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s;
}

.np-quick-act-btn--zalo {
  background: #EBF3FF;
  color: #0068FF;
  border: 1px solid rgba(0, 104, 255, 0.2);
}

.np-quick-act-btn--zalo:hover {
  background: #D9E8FF;
}

.np-quick-act-btn--call {
  background: #ECFDF5;
  color: #059669;
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.np-quick-act-btn--call:hover {
  background: #D1FAE5;
}

.np-quick-act-btn svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* --- Input Bar ở chân khung chat --- */
.np-chat-footer {
  padding: 0.75rem 1rem 0.875rem;
  background: #FFFFFF;
  border-top: 1px solid rgba(89, 74, 66, 0.1);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.np-chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.np-chat-input {
  flex: 1;
  padding: 0.65rem 0.875rem;
  border: 1px solid rgba(89, 74, 66, 0.2);
  border-radius: 999px;
  background: var(--bg-0, #FBFAF6);
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--hoadau-brown, #594A42);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.np-chat-input:focus {
  border-color: var(--champagne-bronze, #A78061);
  box-shadow: 0 0 0 .125rem rgba(167, 128, 97, 0.15);
}

.np-chat-send-btn {
  width: 2.375rem;
  height: 2.375rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--champagne-bronze, #A78061), var(--accent-deep, #8E6A4E));
  border: none;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.np-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.06);
}

.np-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.np-chat-footer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.35rem;
  font-family: 'Gotham', system-ui, sans-serif;
  font-size: 0.6875rem;
  color: var(--tx-4, #A39A84);
}

/* --- Backdrop cho Mobile --- */
.np-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(46, 40, 37, 0.4);
  backdrop-filter: blur(.125rem);
  z-index: 9997;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.np-chat-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* --- Mobile Responsive: Bottom Sheet --- */
@media (max-width: 640px) {
  .np-chat-popup {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 85vh;
    height: 85dvh;
    max-height: 85dvh;
    border-radius: 1.25rem 1.25rem 0 0;
    transform: translateY(100%);
    border-bottom: none;
  }

  .np-chat-popup.is-open {
    transform: translateY(0);
  }
}
.np-chat-reset{background:transparent;color:inherit;border:1px solid currentColor;border-radius:.375rem;padding:.3rem .5rem;font-size:.65rem;cursor:pointer;white-space:nowrap;margin-left:auto}
.np-msg-bubble{white-space:pre-wrap;overflow-wrap:anywhere}
.np-chat-consent{display:flex;align-items:flex-start;gap:.5rem;font-size:.75rem;line-height:1.5;text-align:left}
.np-chat-consent input{margin-top:.2rem;flex:none}.np-lead-error{color:#b42318;font-size:.8rem;margin:0}
.np-chat-media{display:grid;gap:.6rem;margin-top:.6rem}
.np-media-card{background:#fff;border:1px solid #d7cdbf;border-radius:.625rem;padding:.5rem;cursor:zoom-in;display:grid;gap:.4rem;text-align:left;width:100%;color:inherit}
.np-media-card img{width:100%;max-height:15rem;object-fit:contain}.np-media-card span{font-size:.8rem}
.np-image-dialog{max-width:95vw;max-height:95vh;padding:1rem;border:0;border-radius:.75rem}.np-image-dialog::backdrop{background:#000b}
.np-image-dialog img{max-width:90vw;max-height:80vh;object-fit:contain;display:block}.np-image-dialog button{float:right;margin-bottom:.5rem;cursor:pointer;padding:.5rem}
[data-contact-oa][hidden],[data-contact-hotline][hidden]{display:none!important}

.np-chat-popup *, .np-chat-popup *::before, .np-chat-popup *::after{box-sizing:border-box}
.np-chat-input{min-width:0}
.np-chat-messages{min-height:0;overscroll-behavior:contain}
.np-chat-popup :focus-visible{outline:.125rem solid var(--champagne-bronze,#A78061);outline-offset:.125rem}
@media(prefers-reduced-motion:reduce){.np-chat-popup,.np-chat-backdrop,.np-msg{transition:none;animation:none}.np-chat-messages{scroll-behavior:auto}.np-chat-callout-dot,.np-typing-dot,.np-thinking-text,.np-thinking-dots span{animation:none}}
