/* ============================================================
   NK AI Chat Widget — Brand orange, compact
   ============================================================ */

#nk-chat-root,
#nk-chat-root * {
  box-sizing: border-box;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto",
    "Helvetica Neue", Arial, sans-serif;
}

#nk-chat-root {
  position: fixed !important;
  z-index: 2147483600 !important;
  bottom: 0;
  right: 0;
  pointer-events: none;
}

#nk-chat-root button,
#nk-chat-root textarea,
#nk-chat-root input,
#nk-chat-root a {
  pointer-events: auto;
}

/* ============================================================
   BUBBLE (compact, brand orange)
   ============================================================ */
.nk-chat-bubble {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  width: 52px !important;
  height: 52px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: linear-gradient(
    135deg,
    #f97316 0%,
    #ea580c 50%,
    #c2410c 100%
  ) !important;
  color: #fff !important;
  border: none !important;
  cursor: pointer !important;
  box-shadow:
    0 4px 16px rgba(249, 115, 22, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.1) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 2147483600 !important;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease !important;
  pointer-events: auto !important;
  outline: none !important;
}
.nk-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow:
    0 6px 20px rgba(249, 115, 22, 0.5),
    0 3px 6px rgba(0, 0, 0, 0.12) !important;
}
.nk-chat-bubble:active {
  transform: scale(0.95);
}
.nk-chat-bubble:focus-visible {
  outline: 3px solid #fdba74 !important;
  outline-offset: 3px !important;
}

.nk-chat-bubble-icon {
  width: 22px;
  height: 22px;
  color: #fff;
}
.nk-chat-bubble .nk-icon-close {
  display: none;
}

.nk-chat-root[data-state="open"] .nk-chat-bubble .nk-icon-open {
  display: none;
}
.nk-chat-root[data-state="open"] .nk-chat-bubble .nk-icon-close {
  display: block;
}

.nk-chat-bubble-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #dc2626;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}
.nk-chat-root[data-unread="true"] .nk-chat-bubble-badge {
  display: block;
}

.nk-chat-bubble.wiggle {
  animation: nk-wiggle 0.7s ease-in-out;
}
@keyframes nk-wiggle {
  0%,
  100% {
    transform: rotate(0);
  }
  20% {
    transform: rotate(-12deg);
  }
  50% {
    transform: rotate(12deg);
  }
  80% {
    transform: rotate(-6deg);
  }
}

/* ============================================================
   PANEL (compact, warm tones)
   ============================================================ */
.nk-chat-panel {
  position: fixed !important;
  bottom: 84px !important;
  right: 20px !important;
  width: 348px !important;
  height: 520px !important;
  max-height: calc(100vh - 110px) !important;
  background: #fff !important;
  border-radius: 14px !important;
  box-shadow:
    0 8px 32px rgba(124, 45, 18, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.06) !important;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483600 !important;
  font-size: 13.5px !important;
  color: #1c1917 !important;
  pointer-events: auto !important;
  transform: translateY(16px);
  opacity: 0;
  transition:
    transform 0.22s ease,
    opacity 0.22s ease;
  border: 1px solid #fed7aa;
}
.nk-chat-root[data-state="open"] .nk-chat-panel {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}

/* Header — brand orange gradient */
.nk-chat-header {
  padding: 11px 14px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 50%, #c2410c 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.nk-chat-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  color: #c2410c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.nk-chat-header-info {
  flex: 1;
  min-width: 0;
}
.nk-chat-header-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}
.nk-chat-header-status {
  font-size: 11px;
  opacity: 0.92;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nk-chat-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 4px rgba(74, 222, 128, 0.6);
}
.nk-chat-header-action {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    transform 0.15s;
  flex-shrink: 0;
}
.nk-chat-header-action:hover {
  background: rgba(255, 255, 255, 0.3);
}
.nk-chat-header-action:active {
  transform: scale(0.92);
}
.nk-chat-header-action svg {
  width: 16px;
  height: 16px;
}
.nk-chat-header-action + .nk-chat-header-action {
  margin-left: 4px;
}

/* Messages area — soft warm bg */
.nk-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}
.nk-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.nk-chat-messages::-webkit-scrollbar-thumb {
  background: #fed7aa;
  border-radius: 3px;
}
.nk-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #fdba74;
}

.nk-bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
  font-size: 13px;
  animation: nk-fade-in 0.2s ease;
}
@keyframes nk-fade-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.nk-bubble-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(249, 115, 22, 0.2);
}
.nk-bubble-ai {
  align-self: flex-start;
  background: #fff;
  color: #1c1917;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(124, 45, 18, 0.08);
  border: 1px solid #fed7aa;
}
.nk-bubble-ai strong {
  color: #c2410c;
  font-weight: 700;
}
.nk-bubble-user strong {
  color: #fff7ed;
  font-weight: 700;
}
.nk-bubble-system {
  align-self: center;
  background: #ffedd5;
  color: #9a3412;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 10px;
  max-width: 92%;
  text-align: center;
}

.nk-typing {
  align-self: flex-start;
  background: #fff;
  padding: 8px 12px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
  border: 1px solid #fed7aa;
  box-shadow: 0 1px 2px rgba(124, 45, 18, 0.08);
}
.nk-typing-label {
  font-size: 11.5px;
  color: #78716c;
  margin-right: 3px;
}
.nk-typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f97316;
  animation: nk-bounce 1.4s ease-in-out infinite;
}
.nk-typing-dot:nth-child(3) {
  animation-delay: 0.15s;
}
.nk-typing-dot:nth-child(4) {
  animation-delay: 0.3s;
}
@keyframes nk-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Quick replies — 1 hàng, chia đều, scroll ngang nếu dài */
.nk-quick-replies {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 5px 10px 6px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border-top: 1px solid rgba(254, 215, 170, 0.5);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.nk-quick-replies::-webkit-scrollbar {
  display: none;
}
.nk-quick-replies:empty {
  display: none;
}
.nk-quick-reply {
  flex: 1 1 0;
  min-width: 0;
  background: #fff;
  border: 1px solid #fdba74;
  color: #c2410c;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.3;
}
.nk-quick-reply:hover {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  border-color: #ea580c;
}

/* Lead form inline */
.nk-lead-form {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  align-self: stretch;
  box-shadow: 0 2px 6px rgba(124, 45, 18, 0.08);
  border: 1px solid #fed7aa;
}
.nk-lead-form h4 {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: #c2410c;
  font-weight: 600;
}
.nk-lead-form input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #fed7aa;
  border-radius: 7px;
  font-size: 12.5px;
  margin-bottom: 5px;
  outline: none;
  transition: border-color 0.15s;
}
.nk-lead-form input:focus {
  border-color: #f97316;
}
.nk-lead-form button {
  width: 100%;
  padding: 8px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  margin-top: 3px;
  transition: filter 0.15s;
}
.nk-lead-form button:hover {
  filter: brightness(1.05);
}

/* Escalate to Zalo */
.nk-escalate {
  background: #fff;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 10px;
  align-self: stretch;
}
.nk-escalate-title {
  font-size: 11.5px;
  color: #9a3412;
  margin-bottom: 6px;
  font-weight: 600;
}
.nk-escalate a {
  display: block;
  padding: 7px 10px;
  background: #0068ff;
  color: #fff !important;
  border-radius: 7px;
  text-decoration: none;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
}
.nk-escalate a:hover {
  background: #0052cc;
}
.nk-escalate a:last-child {
  margin-bottom: 0;
}

/* Input area */
.nk-chat-input-wrap {
  border-top: 1px solid #fed7aa;
  padding: 7px 10px 8px;
  background: #fff;
  flex-shrink: 0;
}
.nk-chat-input-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.nk-chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #fed7aa;
  border-radius: 16px;
  font-size: 13px;
  resize: none;
  max-height: 80px;
  min-height: 34px;
  outline: none;
  background: #fff7ed;
  line-height: 1.4;
  transition:
    background 0.15s,
    border-color 0.15s;
  color: #1c1917;
}
.nk-chat-input:focus {
  border-color: #f97316;
  background: #fff;
}
.nk-chat-input::placeholder {
  color: #a8a29e;
}
.nk-chat-send {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s;
}
.nk-chat-send:hover {
  filter: brightness(1.08);
}
.nk-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.nk-chat-send svg {
  width: 16px;
  height: 16px;
}

.nk-chat-footer-note {
  font-size: 10px;
  color: #78716c;
  text-align: center;
  margin-top: 4px;
}
.nk-chat-footer-note a {
  color: #c2410c;
  text-decoration: none;
  font-weight: 500;
}

/* ============================================================
   MOBILE (full-screen)
   ============================================================ */
@media (max-width: 640px) {
  .nk-chat-panel {
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
  }
  .nk-chat-bubble {
    bottom: 14px !important;
    right: 14px !important;
    width: 48px !important;
    height: 48px !important;
  }
}
