/* ============================================
   Nurmela Consulting V3 — chatbot.css
   Floating chat widget — light + Odoo purple/teal
   ============================================ */

/* ===== WIDGET WRAPPER ===== */
.chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 14px;
}

/* ===== TOGGLE BUTTON ===== */
.chat-toggle {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #E05D1A;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(224, 93, 26, 0.45);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}
.chat-toggle:hover {
  background: #B54A14;
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(224, 93, 26, 0.55);
}
.chat-toggle:active { transform: scale(0.97); }
.chat-toggle svg { transition: opacity 0.15s ease, transform 0.15s ease; }
.chat-toggle .icon-open  { position: absolute; }
.chat-toggle .icon-close { position: absolute; opacity: 0; transform: rotate(-45deg) scale(0.7); }
.chat-widget.open .chat-toggle .icon-open  { opacity: 0; transform: rotate(45deg) scale(0.7); }
.chat-widget.open .chat-toggle .icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* Notification dot */
.chat-notif {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #EF4444;
  border: 2px solid #ffffff;
  animation: notifpulse 2s ease-in-out infinite;
}
.chat-widget.open .chat-notif { display: none; }
@keyframes notifpulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.15); opacity: 0.8; }
}

/* ===== CHAT WINDOW ===== */
.chat-window {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  max-height: 540px;
  background: #ffffff;
  border: 1px solid rgba(224, 93, 26, 0.12);
  border-top: 2px solid #E05D1A;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(224, 93, 26, 0.18), 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(12px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.chat-widget.open .chat-window {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 420px) {
  .chat-window {
    width: calc(100vw - 2rem);
    right: 0;
    max-height: 80svh;
  }
  .chat-widget {
    bottom: 1rem;
    right: 1rem;
  }
}

/* ===== HEADER ===== */
.chat-header {
  background: #faf7f4;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(224, 93, 26, 0.1);
  flex-shrink: 0;
}
.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #E05D1A 0%, #2C7A4A 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  font-weight: 600;
  font-size: 13px;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #7a7a8c;
  margin-top: 1px;
}
.chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22C55E;
  flex-shrink: 0;
}
.chat-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: rgba(224, 93, 26, 0.08);
  color: #7a7a8c;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.chat-close:hover { background: rgba(224, 93, 26, 0.15); color: #E05D1A; }

/* ===== MESSAGES AREA ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
  background: #fafafa;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(224,93,26,0.15); border-radius: 2px; }

/* Message bubbles */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.chat-bubble {
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  line-height: 1.55;
  font-size: 13.5px;
  word-break: break-word;
}
.chat-msg--bot .chat-bubble {
  background: #ffffff;
  color: #2d2d3f;
  border: 1px solid rgba(224, 93, 26, 0.12);
  border-bottom-left-radius: 4px;
}
.chat-msg--user .chat-bubble {
  background: #E05D1A;
  color: #ffffff;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}
.chat-bubble strong { font-weight: 700; color: #E05D1A; }
.chat-msg--user .chat-bubble strong { color: #ffffff; }
.chat-bubble br { display: block; content: ''; margin-top: 3px; }

/* ===== TYPING INDICATOR ===== */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.625rem 0.875rem;
  background: #ffffff;
  border: 1px solid rgba(224, 93, 26, 0.12);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-self: flex-start;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2C7A4A;
  display: block;
  animation: typingdot 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingdot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* ===== QUICK REPLIES ===== */
.chat-quick {
  padding: 0 1rem 0.625rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: #fafafa;
}
.chat-quick-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(224, 93, 26, 0.35);
  background: rgba(224, 93, 26, 0.05);
  color: #E05D1A;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.chat-quick-btn:hover {
  background: rgba(224, 93, 26, 0.12);
  border-color: #E05D1A;
}

/* ===== INPUT AREA ===== */
.chat-input-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(224, 93, 26, 0.1);
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  background: #ffffff;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: #f5f0eb;
  border: 1px solid rgba(224, 93, 26, 0.15);
  border-radius: 10px;
  padding: 0.625rem 0.875rem;
  font-size: 13px;
  color: #2d2d3f;
  resize: none;
  font-family: inherit;
  outline: none;
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.15s;
}
.chat-input::placeholder { color: #b09080; }
.chat-input:focus { border-color: rgba(224, 93, 26, 0.5); }

.chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #E05D1A;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}
.chat-send:hover  { background: #B54A14; }
.chat-send:active { transform: scale(0.93); }
.chat-send:disabled { opacity: 0.5; cursor: default; }

/* ===== DARK MODE SUPPORT ===== */
[data-theme="dark"] .chat-window {
  background: #1c1a18;
  border-color: rgba(224, 93, 26, 0.25);
}
[data-theme="dark"] .chat-header {
  background: #231f1a;
  border-bottom-color: rgba(224, 93, 26, 0.2);
}
[data-theme="dark"] .chat-header-name { color: #e8e0e6; }
[data-theme="dark"] .chat-header-status { color: #8a7a88; }
[data-theme="dark"] .chat-close { background: rgba(255,255,255,0.06); color: #8a7a88; }
[data-theme="dark"] .chat-close:hover { background: rgba(255,255,255,0.12); color: #e8e0e6; }
[data-theme="dark"] .chat-messages { background: #171411; }
[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb { background: rgba(224,93,26,0.3); }
[data-theme="dark"] .chat-msg--bot .chat-bubble {
  background: #231f1a;
  color: #d4ccd2;
  border-color: rgba(224, 93, 26, 0.2);
}
[data-theme="dark"] .chat-bubble strong { color: #f0a878; }
[data-theme="dark"] .chat-typing {
  background: #231f1a;
  border-color: rgba(224, 93, 26, 0.2);
}
[data-theme="dark"] .chat-quick { background: #171411; }
[data-theme="dark"] .chat-quick-btn {
  border-color: rgba(224, 93, 26, 0.4);
  background: rgba(224, 93, 26, 0.1);
  color: #f0a878;
}
[data-theme="dark"] .chat-quick-btn:hover {
  background: rgba(224, 93, 26, 0.2);
  border-color: #f0a878;
}
[data-theme="dark"] .chat-input-area { background: #1c1a18; border-top-color: rgba(224,93,26,0.2); }
[data-theme="dark"] .chat-input {
  background: #231f1a;
  border-color: rgba(224, 93, 26, 0.25);
  color: #e8e0e6;
}
[data-theme="dark"] .chat-input::placeholder { color: #4a3a28; }
[data-theme="dark"] .chat-input:focus { border-color: rgba(224, 93, 26, 0.55); }
[data-theme="dark"] .chat-notif { border-color: #1c1a18; }
