/* ============================================================
   Norditec AI Chatbot Widget — chat-widget.css
   All selectors are prefixed with #ndt-chat- or .ndt-chat-
   to avoid ANY conflict with the WordPress theme.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ── CSS custom properties (scoped inside our wrapper) ───── */
#ndt-chat-root {
  --ndt-navy:        #0a2240;
  --ndt-navy-light:  #0f3060;
  --ndt-orange:      #e8520a;
  --ndt-orange-hover:#c9430a;
  --ndt-bg:          #ffffff;
  --ndt-surface:     #f4f6f9;
  --ndt-border:      #e2e6ed;
  --ndt-text:        #1a2b40;
  --ndt-text-muted:  #6b7a8d;
  --ndt-user-bg:     #0a2240;
  --ndt-user-text:   #ffffff;
  --ndt-bot-bg:      #f4f6f9;
  --ndt-bot-text:    #1a2b40;
  --ndt-shadow:      0 8px 32px rgba(10, 34, 64, 0.18);
  --ndt-radius:      16px;
  --ndt-font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ndt-z:           999999;

  /* Reset */
  box-sizing: border-box;
  font-family: var(--ndt-font);
}

#ndt-chat-root *,
#ndt-chat-root *::before,
#ndt-chat-root *::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

/* ── Launcher button ─────────────────────────────────────── */
#ndt-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--ndt-z);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ndt-orange);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(232, 82, 10, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  outline: none;
}

#ndt-chat-launcher:hover {
  transform: scale(1.08);
  background: var(--ndt-orange-hover);
  box-shadow: 0 6px 28px rgba(232, 82, 10, 0.5);
}

#ndt-chat-launcher:active {
  transform: scale(0.96);
}

#ndt-chat-launcher svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#ndt-chat-launcher .ndt-icon-open  { display: block; }
#ndt-chat-launcher .ndt-icon-close { display: none;  }

#ndt-chat-launcher.ndt-open .ndt-icon-open  { display: none;  }
#ndt-chat-launcher.ndt-open .ndt-icon-close { display: block; }

/* Notification dot */
#ndt-chat-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #2ecc71;
  border: 2px solid #fff;
  border-radius: 50%;
  animation: ndt-pulse 2s infinite;
}

@keyframes ndt-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%       { transform: scale(1.2); opacity: 0.7; }
}

/* ── Chat panel ──────────────────────────────────────────── */
#ndt-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: var(--ndt-z);
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--ndt-bg);
  border-radius: var(--ndt-radius);
  box-shadow: var(--ndt-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ndt-border);

  /* Hidden state */
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform-origin: bottom right;
}

#ndt-chat-panel.ndt-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Panel header */
#ndt-chat-header {
  background: linear-gradient(135deg, var(--ndt-navy) 0%, var(--ndt-navy-light) 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#ndt-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ndt-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#ndt-chat-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

#ndt-chat-header-info {
  flex: 1;
  min-width: 0;
}

#ndt-chat-header-name {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ndt-chat-header-status {
  color: rgba(255,255,255,0.65);
  font-size: 12px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

#ndt-chat-header-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #2ecc71;
  border-radius: 50%;
}

/* Messages area */
#ndt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#ndt-chat-messages::-webkit-scrollbar { width: 4px; }
#ndt-chat-messages::-webkit-scrollbar-track { background: transparent; }
#ndt-chat-messages::-webkit-scrollbar-thumb { background: var(--ndt-border); border-radius: 2px; }

/* Individual message */
.ndt-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: ndt-msg-in 0.2s ease both;
}

@keyframes ndt-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.ndt-msg.ndt-user { align-self: flex-end; align-items: flex-end; }
.ndt-msg.ndt-bot  { align-self: flex-start; align-items: flex-start; }

.ndt-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.ndt-user .ndt-msg-bubble {
  background: var(--ndt-user-bg);
  color: var(--ndt-user-text);
  border-bottom-right-radius: 4px;
}

.ndt-bot .ndt-msg-bubble {
  background: var(--ndt-bot-bg);
  color: var(--ndt-bot-text);
  border-bottom-left-radius: 4px;
}

/* Links inside bot messages */
.ndt-bot .ndt-msg-bubble a {
  color: var(--ndt-orange);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid rgba(232, 82, 10, 0.3);
  transition: border-color 0.15s;
}

.ndt-bot .ndt-msg-bubble a:hover {
  border-bottom-color: var(--ndt-orange);
}

/* Bold, italic inside bot messages */
.ndt-bot .ndt-msg-bubble strong { font-weight: 600; }
.ndt-bot .ndt-msg-bubble em { font-style: italic; }

/* Typing indicator */
#ndt-chat-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--ndt-bot-bg);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

#ndt-chat-typing.ndt-visible { display: flex; align-items: center; gap: 4px; }

.ndt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ndt-text-muted);
  animation: ndt-bounce 1.2s infinite;
}
.ndt-dot:nth-child(2) { animation-delay: 0.2s; }
.ndt-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ndt-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* Welcome / empty state */
#ndt-chat-welcome {
  text-align: center;
  padding: 24px 16px;
  color: var(--ndt-text-muted);
}

#ndt-chat-welcome .ndt-welcome-icon {
  width: 48px;
  height: 48px;
  background: var(--ndt-surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

#ndt-chat-welcome .ndt-welcome-icon svg {
  width: 24px;
  height: 24px;
  fill: var(--ndt-orange);
}

#ndt-chat-welcome h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ndt-text);
  margin-bottom: 6px;
}

#ndt-chat-welcome p {
  font-size: 13px;
  line-height: 1.5;
}

/* Quick suggestion chips */
#ndt-chat-suggestions {
  padding: 0 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.ndt-chip {
  padding: 6px 12px;
  background: var(--ndt-surface);
  border: 1px solid var(--ndt-border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--ndt-navy);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--ndt-font);
  white-space: nowrap;
}

.ndt-chip:hover {
  background: var(--ndt-navy);
  color: #fff;
  border-color: var(--ndt-navy);
}

/* Input area */
#ndt-chat-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--ndt-border);
  background: var(--ndt-bg);
  flex-shrink: 0;
}

#ndt-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--ndt-surface);
  border: 1.5px solid var(--ndt-border);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  transition: border-color 0.2s;
}

#ndt-chat-form:focus-within {
  border-color: var(--ndt-orange);
}

#ndt-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: 14px;
  font-family: var(--ndt-font);
  color: var(--ndt-text);
  line-height: 1.5;
  max-height: 120px;
  min-height: 24px;
  outline: none;
}

#ndt-chat-input::placeholder { color: var(--ndt-text-muted); }

#ndt-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--ndt-orange);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

#ndt-chat-send:hover  { background: var(--ndt-orange-hover); }
#ndt-chat-send:active { transform: scale(0.94); }
#ndt-chat-send:disabled { background: var(--ndt-border); cursor: not-allowed; }

#ndt-chat-send svg { width: 18px; height: 18px; fill: #fff; }

/* Error toast */
#ndt-chat-error {
  display: none;
  margin: 0 16px 8px;
  padding: 10px 14px;
  background: #fff0ee;
  border: 1px solid #ffc5b7;
  border-radius: 10px;
  font-size: 13px;
  color: #c0392b;
  flex-shrink: 0;
}
#ndt-chat-error.ndt-visible { display: block; }

/* Config-missing banner */
#ndt-chat-no-config {
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--ndt-text-muted);
}

/* Mobile */
@media (max-width: 420px) {
  #ndt-chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 84px;
    height: calc(100vh - 100px);
    border-radius: 12px;
  }
  #ndt-chat-launcher {
    right: 16px;
    bottom: 16px;
  }
}
