/* ============================================================
   AI Assistant Chat Widget – WordPress plugin stylesheet v2.1
   ============================================================ */

.ai-assistant-root {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  box-sizing: border-box;
}

.ai-assistant-root *,
.ai-assistant-root *::before,
.ai-assistant-root *::after {
  box-sizing: inherit;
}

/* All SVGs inside the widget inherit stroke from their parent color */
.ai-assistant-root svg {
  display: block;
  flex-shrink: 0;
}

/* ── Card shell ─────────────────────────────── */
.aa-card {
  background: #0d1526;
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 48px -8px rgba(37, 99, 235, 0.25), 0 0 0 1px rgba(37, 99, 235, 0.1);
}

.aa-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(37,99,235,0.6), transparent);
}

/* ── Header ─────────────────────────────────── */
.aa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
}

.aa-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.aa-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(37, 99, 235, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.aa-avatar svg {
  width: 20px;
  height: 20px;
}

.aa-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.3;
}

.aa-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
}

.aa-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aa-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
}

.aa-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.aa-badge-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: aa-ping 1.2s cubic-bezier(0,0,.2,1) infinite;
  opacity: 0.75;
}

@keyframes aa-ping {
  75%, 100% { transform: scale(2); opacity: 0; }
}

.aa-badge-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── New conversation button ─────────────────── */
.aa-reset-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.aa-reset-btn:hover,
.aa-reset-btn:active {
  background: #1e293b;
  color: #e2e8f0;
}

.aa-reset-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Notice banner ───────────────────────────── */
.aa-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 24px;
  background: rgba(245, 158, 11, 0.08);
  border-top: 1px solid rgba(245, 158, 11, 0.15);
  border-bottom: 1px solid rgba(245, 158, 11, 0.15);
}

.aa-notice-icon {
  color: #f59e0b;
  flex-shrink: 0;
  margin-top: 1px;
}

.aa-notice-icon svg {
  width: 14px;
  height: 14px;
}

.aa-notice p {
  margin: 0;
  font-size: 11px;
  color: #f59e0b;
  line-height: 1.5;
}

.aa-notice strong { color: #fbbf24; }

/* ── Widget mode ─────────────────────────────── */
.aa-widget-mode {
  padding: 8px 24px 28px;
}

.aa-input-box {
  background: #111d35;
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.2s;
}

.aa-input-box:focus-within {
  border-color: rgba(37, 99, 235, 0.5);
}

.aa-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.aa-input-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.aa-input-icon svg {
  width: 20px;
  height: 20px;
}

.aa-main-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: #f1f5f9;
  width: 100%;
  font-family: inherit;
  min-width: 0;
}

.aa-main-input::placeholder { color: #475569; }

/* Ask AI button */
.aa-ask-btn {
  width: 100%;
  height: 48px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.15s, opacity 0.15s;
  box-shadow: 0 4px 14px rgba(37,99,235,0.25);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.aa-ask-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.aa-ask-btn:not(:disabled):hover,
.aa-ask-btn:not(:disabled):active { filter: brightness(1.1); }

.aa-btn-icon {
  display: flex;
  align-items: center;
}

.aa-btn-icon svg,
.aa-ask-btn svg {
  width: 16px;
  height: 16px;
}

/* Scope note */
.aa-scope-note {
  margin: 12px 0 0;
  font-size: 11px;
  color: #475569;
  text-align: center;
  font-style: italic;
}

/* ── Quick questions ─────────────────────────── */
.aa-quick-label {
  margin: 20px 0 10px;
  font-size: 11px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.aa-quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.aa-pill {
  padding: 8px 14px;
  border-radius: 9999px;
  border: 1px solid #334155;
  background: rgba(30, 41, 59, 0.4);
  color: #cbd5e1;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.aa-pill:hover,
.aa-pill:active {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #475569;
}

/* ── Chat mode ───────────────────────────────── */
.aa-chat-mode {
  display: flex;
  flex-direction: column;
}

.aa-messages {
  padding: 8px 20px 16px;
  max-height: 420px;
  overflow-y: auto;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
}

.aa-messages::-webkit-scrollbar { width: 4px; }
.aa-messages::-webkit-scrollbar-track { background: transparent; }
.aa-messages::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }

/* Message rows */
.aa-msg-row {
  display: flex;
  width: 100%;
  animation: aa-fade-up 0.2s ease;
}

@keyframes aa-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.aa-msg-row--user { justify-content: flex-end; }
.aa-msg-row--bot  { justify-content: flex-start; align-items: flex-start; }

.aa-bot-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(37,99,235,0.2);
  border: 1px solid rgba(37,99,235,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  margin-top: 2px;
  flex-shrink: 0;
}

.aa-bot-icon svg {
  width: 14px;
  height: 14px;
}

.aa-bubble {
  max-width: 78%;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: break-word;
}

.aa-bubble--user {
  color: #ffffff;
  border-top-right-radius: 4px;
}

.aa-bubble--bot {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(51, 65, 85, 0.6);
  color: #e2e8f0;
  border-top-left-radius: 4px;
}

.aa-bubble--bot strong { color: #f1f5f9; }
.aa-bubble--bot em     { color: #cbd5e1; }
.aa-bubble--bot code   {
  background: rgba(15,23,42,0.8);
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: 'SF Mono', Consolas, 'Courier New', monospace;
  color: #93c5fd;
}

.aa-link {
  color: #60a5fa;
  text-decoration: underline;
  text-decoration-color: rgba(96, 165, 250, 0.4);
  word-break: break-all;
}
.aa-link:hover { color: #93c5fd; }

/* Typing dots */
.aa-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.aa-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748b;
  animation: aa-bounce 0.8s ease-in-out infinite;
}

.aa-dot:nth-child(2) { animation-delay: 0.15s; }
.aa-dot:nth-child(3) { animation-delay: 0.30s; }

@keyframes aa-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}

/* ── CTA action row ──────────────────────────── */
.aa-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid rgba(30,41,59,0.6);
  background: #0d1526;
}

.aa-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: rgba(30,41,59,0.5);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.aa-cta-btn:hover,
.aa-cta-btn:active {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #475569;
}

.aa-cta-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.aa-cta-icon svg,
.aa-cta-btn svg {
  width: 14px;
  height: 14px;
}

/* ── Chat input bar ──────────────────────────── */
.aa-input-bar {
  padding: 16px 20px;
  border-top: 1px solid rgba(30,41,59,0.6);
  background: rgba(15,23,42,0.4);
}

.aa-chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #111d35;
  border: 1px solid rgba(51,65,85,0.6);
  transition: border-color 0.2s;
}

.aa-chat-input-wrap:focus-within {
  border-color: rgba(37,99,235,0.5);
}

.aa-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  color: #f1f5f9;
  font-family: inherit;
  min-width: 0;
  line-height: 1.5;
}

.aa-chat-input::placeholder { color: #475569; }
.aa-chat-input:disabled { opacity: 0.5; }

/* Send button */
.aa-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #ffffff;
  transition: filter 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.aa-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.aa-send-btn:not(:disabled):hover,
.aa-send-btn:not(:disabled):active { filter: brightness(1.15); }

.aa-send-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.aa-send-icon svg,
.aa-send-btn svg {
  width: 15px;
  height: 15px;
}

.aa-disclaimer {
  text-align: center;
  font-size: 10px;
  color: #334155;
  margin-top: 8px;
  margin-bottom: 0;
  line-height: 1.4;
}

/* ── Shortcode modal overlay ─────────────────── */
.aa-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.aa-modal-overlay--visible {
  opacity: 1;
}

.aa-modal {
  background: #ffffff;
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  transform: translateY(0);
  -webkit-overflow-scrolling: touch;
}

.aa-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e5e7eb;
}

.aa-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* !important overrides prevent WordPress themes from styling this as a
   coloured submit/button element */
.aa-modal-close,
#aa-modal-overlay .aa-modal-close {
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 32px !important;
  height: 32px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  border-radius: 6px !important;
  color: #6b7280 !important;
  transition: background 0.15s, color 0.15s !important;
  padding: 0 !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
  line-height: 1 !important;
  text-transform: none !important;
  font-size: inherit !important;
  letter-spacing: normal !important;
  -webkit-tap-highlight-color: transparent;
}

.aa-modal-close:hover,
.aa-modal-close:active,
#aa-modal-overlay .aa-modal-close:hover,
#aa-modal-overlay .aa-modal-close:active {
  background: #f3f4f6 !important;
  color: #111827 !important;
}

.aa-modal-close svg,
#aa-modal-overlay .aa-modal-close svg {
  width: 18px !important;
  height: 18px !important;
  display: block !important;
  pointer-events: none;
}

.aa-modal-body {
  padding: 20px;
  color: #374151;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* Ensure form plugin styles don't bleed — reset common form elements */
.aa-modal-body input[type="text"],
.aa-modal-body input[type="email"],
.aa-modal-body input[type="tel"],
.aa-modal-body input[type="url"],
.aa-modal-body textarea,
.aa-modal-body select {
  font-family: inherit;
  font-size: 14px;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 600px) {
  .aa-header        { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
  .aa-widget-mode   { padding: 8px 16px 24px; }
  .aa-messages      { padding: 8px 12px 12px; max-height: 340px; }
  .aa-cta-row       { padding: 10px 12px; gap: 6px; }
  .aa-input-bar     { padding: 12px 12px; }
  .aa-title         { font-size: 14px; }
  .aa-cta-btn       { font-size: 11px; padding: 8px 10px; }
  .aa-bubble        { max-width: 88%; font-size: 13px; }
  .aa-badge         { display: none; } /* hide on very small screens to save space */
}

@media (max-width: 380px) {
  .aa-cta-row       { flex-direction: column; }
  .aa-cta-btn       { width: 100%; justify-content: center; }
}
