/* --- AI CHATBOT WIDGET STYLES --- */
.ai-chat-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--card-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 990;
  transition: transform var(--transition-fast), background-color var(--transition-normal);
}

.ai-chat-toggle:hover {
  transform: scale(1.08) translateY(-2px);
  background: var(--rose);
  color: #0F0F11;
}

[data-theme="dark"] .ai-chat-toggle:hover {
  background: var(--lime);
  color: #0F0F11;
}

.ai-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--rose);
  color: #0F0F11;
  font: 700 10px 'DM Mono', monospace;
  padding: 2px 6px;
  border-radius: 999px;
  border: 2px solid var(--paper);
}

[data-theme="dark"] .ai-chat-badge {
  background: var(--lime);
}

.ai-chat-window {
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: var(--shadow-md), 0 20px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.ai-chat-window.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
}

.ai-chat-mobile-backdrop {
  display: none;
}

@media (max-width: 680px) {
  .ai-chat-mobile-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--paper);
    z-index: 99998;
    pointer-events: auto;
    touch-action: none;
  }

  .ai-chat-mobile-backdrop.hidden {
    display: none;
  }
}

.ai-chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--glass-bg);
}

.ai-chat-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-status-dot {
  width: 9px;
  height: 9px;
  background: var(--badge-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--badge-green);
}

.ai-chat-header h3 {
  margin: 0;
  font: 700 15px 'Plus Jakarta Sans', sans-serif;
  color: var(--ink);
}

.ai-subtitle {
  font: 500 10px 'DM Mono', monospace;
  color: var(--muted);
  display: block;
}

.ai-chat-header-actions {
  display: flex;
  gap: 8px;
}

.ai-chat-header-actions button {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--transition-fast);
}

.ai-chat-header-actions button:hover {
  color: var(--ink);
}

.ai-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.ai-msg-assistant {
  align-self: flex-start;
}

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

.ai-msg-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
}

.ai-msg-assistant .ai-msg-content {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.ai-msg-user .ai-msg-content {
  background: var(--ink);
  color: var(--paper);
  border-bottom-right-radius: 4px;
}

.ai-typing span {
  display: inline-block;
  font-size: 20px;
  animation: typing 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 100% { opacity: 0.2; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.ai-chat-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: none;
}
.ai-chat-chips::-webkit-scrollbar { display: none; }

.ai-chip {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  font: 500 11px 'DM Mono', monospace;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-chip:hover {
  background: var(--rose);
  border-color: var(--rose);
  color: #0F0F11;
}

[data-theme="dark"] .ai-chip:hover {
  background: var(--lime);
  border-color: var(--lime);
}

.ai-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--glass-bg);
}

.ai-chat-input-area input {
  flex: 1;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.ai-chat-input-area input:focus {
  border-color: var(--rose);
}

[data-theme="dark"] .ai-chat-input-area input:focus {
  border-color: var(--lime);
}

.ai-chat-input-area button {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  font: 600 12px 'DM Mono', monospace;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.ai-chat-input-area button:hover {
  background: var(--rose);
  color: #0F0F11;
}


@media (max-width: 680px) {
  .ai-chat-toggle {
    right: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
  }

  .ai-chat-window {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    z-index: 99999;
    box-shadow: none;
    overscroll-behavior: contain;
    transition: none !important;
  }

  .ai-chat-header {
    padding: 12px 16px;
  }

  .ai-chat-header h3 {
    font-size: 14px;
  }

  .ai-chat-body {
    padding: 12px;
    gap: 10px;
  }

  .ai-msg {
    max-width: 92%;
  }

  .ai-msg-content {
    padding: 10px 14px;
    font-size: 14px;
  }

  .ai-chat-chips {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
  }

  .ai-chip {
    font-size: 11px;
    padding: 6px 10px;
    flex-shrink: 0;
  }

  .ai-chat-input-area {
    padding: 10px 12px;
  }

  .ai-chat-input-area input {
    padding: 10px 14px;
    font-size: 16px; /* Prevents auto-zoom on iOS Safari and mobile Chrome */
  }

  .ai-chat-input-area button {
    padding: 10px 14px;
    font-size: 12px;
  }
}
