/* === JAGUAR AI ASSISTANT — CHATBOT WIDGET === */
:root {
  --jai-primary: var(--jai-color-primary, #1C2321);
  --jai-accent: var(--jai-color-accent, #C9A96E);
  --jai-white: #fff;
  --jai-light: #FAF8F5;
  --jai-border: #E8E4DE;
  --jai-text: #1C2321;
  --jai-text-light: #777;
  --jai-radius: 0;
  --jai-shadow: 0 8px 48px rgba(0, 0, 0, 0.12);
  --jai-font: 'Inter', -apple-system, sans-serif;
}

.jai-chatbot {
  position: fixed;
  z-index: 99999;
  font-family: var(--jai-font);
}

.jai-chatbot--bottom-right { bottom: 24px; right: 24px; }
.jai-chatbot--bottom-left { bottom: 24px; left: 24px; }

/* === TOGGLE BUTTON === */
.jai-toggle {
  width: 60px;
  height: 60px;
  border: none;
  background: var(--jai-primary);
  color: var(--jai-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--jai-shadow);
  position: relative;
}

.jai-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
}

.jai-toggle__close { display: none; }
.jai-chatbot.is-open .jai-toggle__open { display: none; }
.jai-chatbot.is-open .jai-toggle__close { display: flex; }

.jai-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  background: #e74c3c;
  color: var(--jai-white);
  font-size: 10px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  animation: jaiBounce 2s infinite;
}

.jai-badge.is-visible { display: flex; }

@keyframes jaiBounce {
  0%, 80%, 100% { transform: scale(1); }
  40% { transform: scale(1.2); }
}

/* === CHAT WINDOW === */
.jai-window {
  position: absolute;
  bottom: 76px;
  width: 400px;
  max-height: 560px;
  background: var(--jai-white);
  box-shadow: var(--jai-shadow);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.jai-chatbot--bottom-right .jai-window { right: 0; }
.jai-chatbot--bottom-left .jai-window { left: 0; }

.jai-chatbot.is-open .jai-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* === HEADER === */
.jai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--jai-primary);
  color: var(--jai-white);
  flex-shrink: 0;
}

.jai-header__info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.jai-header__avatar {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
}

.jai-header__name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.jai-header__status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  opacity: 0.8;
}

.jai-header__dot {
  width: 7px;
  height: 7px;
  background: #2ecc71;
  border-radius: 50%;
  display: inline-block;
}

.jai-header__actions {
  display: flex;
  gap: 4px;
}

.jai-header__btn {
  background: none;
  border: none;
  color: var(--jai-white);
  cursor: pointer;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.jai-header__btn:hover { opacity: 1; }

/* === MESSAGES === */
.jai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 300px;
  max-height: 340px;
  background: var(--jai-light);
}

.jai-messages::-webkit-scrollbar { width: 3px; }
.jai-messages::-webkit-scrollbar-track { background: transparent; }
.jai-messages::-webkit-scrollbar-thumb { background: var(--jai-border); }

/* Message bubbles */
.jai-msg {
  max-width: 85%;
  animation: jaiMsgIn 0.3s ease;
}

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

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

.jai-msg__bubble {
  padding: 11px 15px;
  font-size: 13px;
  line-height: 1.65;
}

.jai-msg--bot .jai-msg__bubble {
  background: var(--jai-white);
  color: var(--jai-text);
  border: 1px solid var(--jai-border);
}

.jai-msg--user .jai-msg__bubble {
  background: var(--jai-primary);
  color: var(--jai-white);
}

.jai-msg__bubble strong { font-weight: 600; }

.jai-msg__time {
  font-size: 10px;
  color: var(--jai-text-light);
  margin-top: 3px;
  padding: 0 4px;
}

.jai-msg--user .jai-msg__time { text-align: right; }

/* Quick replies */
.jai-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}

.jai-quick-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-family: var(--jai-font);
  font-weight: 500;
  background: var(--jai-white);
  color: var(--jai-text);
  border: 1px solid var(--jai-border);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}

.jai-quick-btn:hover {
  border-color: var(--jai-accent);
  color: var(--jai-accent);
}

/* Typing indicator */
.jai-typing {
  display: flex;
  gap: 4px;
  padding: 11px 15px;
  background: var(--jai-white);
  border: 1px solid var(--jai-border);
  align-self: flex-start;
}

.jai-typing span {
  width: 6px;
  height: 6px;
  background: var(--jai-accent);
  border-radius: 50%;
  animation: jaiDot 1.4s infinite;
}

.jai-typing span:nth-child(2) { animation-delay: 0.2s; }
.jai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes jaiDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* === INPUT AREA === */
.jai-input-area {
  display: flex;
  padding: 12px 14px;
  gap: 8px;
  border-top: 1px solid var(--jai-border);
  background: var(--jai-white);
  flex-shrink: 0;
}

.jai-input {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--jai-font);
  font-size: 13px;
  border: 1px solid var(--jai-border);
  background: var(--jai-light);
  outline: none;
  transition: border-color 0.2s;
}

.jai-input:focus { border-color: var(--jai-accent); }

.jai-send {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--jai-primary);
  color: var(--jai-white);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  opacity: 0.5;
}

.jai-send:not(:disabled) { opacity: 1; }
.jai-send:not(:disabled):hover { background: var(--jai-accent); }

/* === WHATSAPP LINK === */
.jai-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: #25D366;
  color: var(--jai-white);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
  flex-shrink: 0;
}

.jai-whatsapp:hover { background: #1da851; color: var(--jai-white); }

/* === PROACTIVE BUBBLE === */
.jai-proactive {
  position: absolute;
  bottom: 76px;
  right: 0;
  background: var(--jai-white);
  box-shadow: var(--jai-shadow);
  padding: 14px 18px;
  max-width: 280px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.3s ease;
}

.jai-chatbot--bottom-left .jai-proactive { right: auto; left: 0; }

.jai-proactive.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.jai-proactive__close {
  position: absolute;
  top: 4px;
  right: 8px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--jai-text-light);
  line-height: 1;
}

.jai-proactive__text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--jai-text);
  margin: 0;
  padding-right: 16px;
}

/* === RESPONSIVE === */
@media (max-width: 479px) {
  .jai-chatbot { bottom: 16px; right: 16px; left: auto; }
  .jai-chatbot--bottom-left { left: 16px; right: auto; }

  .jai-window {
    width: calc(100vw - 32px);
    max-height: 70vh;
  }

  .jai-toggle { width: 52px; height: 52px; }
  .jai-proactive { max-width: calc(100vw - 100px); }
}
