/* ═══════════════════════════════════════════════════════════════════════
   AAH Chat Module — Complete Stylesheet
   All selectors scoped under #aah-chat-widget to prevent conflicts.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties (defaults, overridden inline by Customizer) ── */
#aah-chat-widget {
  --aah-chat-accent: #C6A15B;
  --aah-chat-header: #0A1726;
  --aah-chat-body: #F7F4EE;
  --aah-chat-launcher: 60px;
  --aah-chat-gold-bright: #D8B66E;
  --aah-chat-gold-pale: #E8D3A2;
  --aah-chat-ink: #0A1726;
  --aah-chat-navy: #0E2034;
  --aah-chat-navy-soft: #16304B;
  --aah-chat-bone: #F7F4EE;
  --aah-chat-paper: #FCFBF7;
  --aah-chat-text: #2A3540;
  --aah-chat-muted: #697785;
  --aah-chat-muted-navy: #A9BBCE;
  --aah-chat-line-dark: rgba(20,40,60,.10);
  --aah-chat-line-gold: rgba(198,161,91,.28);
  --aah-chat-ease: cubic-bezier(.22,.61,.36,1);
  --aah-chat-green: #25D366;
  --aah-chat-green-hover: #1eb959;
  --aah-chat-error: #e06a5a;
  --aah-chat-error-text: #c0392b;
  --aah-chat-success-bg: rgba(74,201,126,.1);
  --aah-chat-success-text: #2d8a56;
}

/* ── Widget Container ──────────────────────────────────────────────────── */
#aah-chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99999;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--aah-chat-text);
  -webkit-font-smoothing: antialiased;
}

#aah-chat-widget.aah-chat--left {
  right: auto;
  left: 24px;
}

/* ── Device Visibility ─────────────────────────────────────────────────── */
@media (min-width: 769px) {
  #aah-chat-widget.aah-chat--mobile-only { display: none !important; }
}
@media (max-width: 768px) {
  #aah-chat-widget.aah-chat--desktop-only { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════
   LAUNCHER BUTTON
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__launch {
  display: flex;
  align-items: center;
  gap: 12px;
  width: var(--aah-chat-launcher);
  height: var(--aah-chat-launcher);
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--aah-chat-gold-bright), var(--aah-chat-accent));
  color: var(--aah-chat-ink);
  cursor: pointer;
  position: relative;
  box-shadow: 0 16px 40px -12px rgba(198,161,91,.7);
  transition: transform .3s var(--aah-chat-ease), box-shadow .3s var(--aah-chat-ease);
  justify-content: center;
  padding: 0;
}

#aah-chat-widget .aah-chat__launch:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 50px -12px rgba(198,161,91,.85);
}

#aah-chat-widget .aah-chat__launch:focus-visible {
  outline: 2px solid var(--aah-chat-gold-bright);
  outline-offset: 3px;
}

#aah-chat-widget .aah-chat__launch-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

#aah-chat-widget .aah-chat__launch-label {
  display: none;
}

#aah-chat-widget .aah-chat__launch--hidden {
  transform: scale(.6);
  opacity: 0;
  pointer-events: none;
}

/* ── Badge ─────────────────────────────────────────────────────────────── */
#aah-chat-widget .aah-chat__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #e06a5a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  animation: aah-chat-badge-pulse 2s infinite;
}

@keyframes aah-chat-badge-pulse {
  0% { box-shadow: 0 0 0 0 rgba(224,106,90,.6); }
  70% { box-shadow: 0 0 0 8px rgba(224,106,90,0); }
  100% { box-shadow: 0 0 0 0 rgba(224,106,90,0); }
}

/* ═══════════════════════════════════════════════════════════════════════
   PANEL
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__panel {
  position: absolute;
  bottom: calc(var(--aah-chat-launcher) + 16px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 90px -25px rgba(8,18,30,.6);
  opacity: 0;
  transform: translateY(20px) scale(.97);
  pointer-events: none;
  transition: opacity .3s var(--aah-chat-ease), transform .3s var(--aah-chat-ease);
}

#aah-chat-widget.aah-chat--left .aah-chat__panel {
  right: auto;
  left: 0;
}

#aah-chat-widget .aah-chat__panel--open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__head {
  background: var(--aah-chat-header);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 13px;
  position: relative;
  flex-shrink: 0;
}

#aah-chat-widget .aah-chat__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--aah-chat-navy-soft);
  border: 1px solid var(--aah-chat-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

#aah-chat-widget .aah-chat__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#aah-chat-widget .aah-chat__avatar svg {
  color: var(--aah-chat-accent);
}

#aah-chat-widget .aah-chat__brand {
  flex: 1;
  min-width: 0;
}

#aah-chat-widget .aah-chat__brand strong {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#aah-chat-widget .aah-chat__brand small {
  color: var(--aah-chat-muted-navy);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#aah-chat-widget .aah-chat__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ac97e;
  flex-shrink: 0;
}

#aah-chat-widget .aah-chat__status-dot--offline {
  background: #8a9bb0;
}

#aah-chat-widget .aah-chat__close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: 0;
  color: var(--aah-chat-muted-navy);
  font-size: 0;
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color .2s, background .2s;
  flex-shrink: 0;
  padding: 0;
}

#aah-chat-widget .aah-chat__close:hover {
  color: #fff;
  background: rgba(255,255,255,.1);
}

#aah-chat-widget .aah-chat__close:focus-visible {
  outline: 2px solid var(--aah-chat-accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--aah-chat-line-dark);
  flex-shrink: 0;
}

#aah-chat-widget .aah-chat__tab {
  flex: 1;
  background: none;
  border: 0;
  padding: 12px 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--aah-chat-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
  white-space: nowrap;
  text-align: center;
}

#aah-chat-widget .aah-chat__tab:hover {
  color: var(--aah-chat-navy);
}

#aah-chat-widget .aah-chat__tab.active {
  color: var(--aah-chat-navy);
  border-bottom-color: var(--aah-chat-accent);
}

#aah-chat-widget .aah-chat__tab:focus-visible {
  outline: 2px solid var(--aah-chat-accent);
  outline-offset: -2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   VIEWS
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__view {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

#aah-chat-widget .aah-chat__view.active {
  display: flex;
}

/* ── Chat Body ─────────────────────────────────────────────────────────── */
#aah-chat-widget .aah-chat__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--aah-chat-body);
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

#aah-chat-widget .aah-chat__body--channels {
  gap: 10px;
  padding: 20px;
}

/* ── Chat Footer ───────────────────────────────────────────────────────── */
#aah-chat-widget .aah-chat__foot {
  border-top: 1px solid var(--aah-chat-line-dark);
  background: #fff;
  padding: 12px;
  flex-shrink: 0;
}

#aah-chat-widget .aah-chat__foot--stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════
   MESSAGE BUBBLES
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__msg {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  animation: aah-chat-msgin .3s var(--aah-chat-ease);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

@keyframes aah-chat-msgin {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

#aah-chat-widget .aah-chat__msg--bot {
  background: #fff;
  border: 1px solid var(--aah-chat-line-dark);
  color: var(--aah-chat-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

#aah-chat-widget .aah-chat__msg--user {
  background: var(--aah-chat-navy);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* ── Typing Indicator ──────────────────────────────────────────────────── */
#aah-chat-widget .aah-chat__typing {
  display: flex;
  gap: 5px;
  padding: 11px 15px;
  background: #fff;
  border: 1px solid var(--aah-chat-line-dark);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  animation: aah-chat-msgin .3s var(--aah-chat-ease);
}

#aah-chat-widget .aah-chat__typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aah-chat-muted);
  animation: aah-chat-typing-bounce 1.2s infinite;
}

#aah-chat-widget .aah-chat__typing-dot:nth-child(2) { animation-delay: .15s; }
#aah-chat-widget .aah-chat__typing-dot:nth-child(3) { animation-delay: .3s; }

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

/* ═══════════════════════════════════════════════════════════════════════
   CHIPS
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#aah-chat-widget .aah-chat__chip {
  background: #fff;
  border: 1px solid var(--aah-chat-line-gold);
  color: var(--aah-chat-navy);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 9px 13px;
  border-radius: 30px;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .2s;
}

#aah-chat-widget .aah-chat__chip:hover {
  background: var(--aah-chat-accent);
  border-color: var(--aah-chat-accent);
  color: var(--aah-chat-ink);
  transform: translateY(-1px);
}

#aah-chat-widget .aah-chat__chip:focus-visible {
  outline: 2px solid var(--aah-chat-accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   WHATSAPP / EMAIL BUTTONS
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__wa-btn {
  width: 100%;
  background: var(--aah-chat-green);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 13px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .25s, transform .25s;
}

#aah-chat-widget .aah-chat__wa-btn:hover {
  background: var(--aah-chat-green-hover);
  transform: translateY(-1px);
}

#aah-chat-widget .aah-chat__wa-btn:focus-visible {
  outline: 2px solid var(--aah-chat-green);
  outline-offset: 2px;
}

#aah-chat-widget .aah-chat__email-btn {
  width: 100%;
  background: var(--aah-chat-ink);
  color: var(--aah-chat-gold-pale);
  border: 0;
  border-radius: 6px;
  padding: 13px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .25s, transform .25s;
}

#aah-chat-widget .aah-chat__email-btn:hover {
  background: #06101c;
  transform: translateY(-1px);
}

#aah-chat-widget .aah-chat__email-btn:focus-visible {
  outline: 2px solid var(--aah-chat-accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   FORM
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

#aah-chat-widget .aah-chat__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#aah-chat-widget .aah-chat__field label {
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--aah-chat-muted);
  font-weight: 600;
}

#aah-chat-widget .aah-chat__field input,
#aah-chat-widget .aah-chat__field textarea {
  border: 1px solid var(--aah-chat-line-dark);
  border-radius: 6px;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--aah-chat-text);
  transition: border-color .25s, box-shadow .25s;
  resize: vertical;
}

#aah-chat-widget .aah-chat__field textarea {
  min-height: 70px;
}

#aah-chat-widget .aah-chat__field input:focus,
#aah-chat-widget .aah-chat__field textarea:focus {
  outline: none;
  border-color: var(--aah-chat-accent);
  box-shadow: 0 0 0 3px rgba(198,161,91,.15);
}

#aah-chat-widget .aah-chat__field--err input,
#aah-chat-widget .aah-chat__field--err textarea {
  border-color: var(--aah-chat-error);
}

#aah-chat-widget .aah-chat__field-err {
  display: none;
  color: var(--aah-chat-error-text);
  font-size: 11px;
}

#aah-chat-widget .aah-chat__field--err .aah-chat__field-err {
  display: block;
}

/* ── Form Success State ────────────────────────────────────────────────── */
#aah-chat-widget .aah-chat__form-success {
  text-align: center;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#aah-chat-widget .aah-chat__form-success-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1.5px solid var(--aah-chat-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--aah-chat-accent);
  font-size: 24px;
  margin-bottom: 8px;
}

#aah-chat-widget .aah-chat__form-success p {
  color: var(--aah-chat-muted-navy);
  font-size: .92rem;
  margin: 0;
}

#aah-chat-widget .aah-chat__form-success p strong {
  color: #fff;
  font-size: 1.1rem;
}

/* ── Reset Button ──────────────────────────────────────────────────────── */
#aah-chat-widget .aah-chat__reset-btn {
  background: none;
  border: 1px solid var(--aah-chat-accent);
  color: var(--aah-chat-accent);
  padding: 10px 20px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background .25s, color .25s;
}

#aah-chat-widget .aah-chat__reset-btn:hover {
  background: var(--aah-chat-accent);
  color: var(--aah-chat-ink);
}

#aah-chat-widget .aah-chat__reset-btn:focus-visible {
  outline: 2px solid var(--aah-chat-accent);
  outline-offset: 2px;
}

/* ── Form Note ─────────────────────────────────────────────────────────── */
#aah-chat-widget .aah-chat__form-note {
  font-size: 11px;
  color: var(--aah-chat-muted);
  line-height: 1.6;
  margin: 8px 12px 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   CHANNEL CARDS
   ═══════════════════════════════════════════════════════════════════════ */
#aah-chat-widget .aah-chat__channel {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--aah-chat-line-dark);
  border-radius: 10px;
  text-decoration: none;
  color: var(--aah-chat-text);
  transition: border-color .25s, transform .25s, box-shadow .25s;
}

#aah-chat-widget .aah-chat__channel:hover {
  border-color: var(--aah-chat-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}

#aah-chat-widget .aah-chat__channel:focus-visible {
  outline: 2px solid var(--aah-chat-accent);
  outline-offset: 2px;
}

#aah-chat-widget .aah-chat__channel-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.2rem;
}

#aah-chat-widget .aah-chat__channel-icon--wa {
  background: var(--aah-chat-green);
  color: #fff;
}

#aah-chat-widget .aah-chat__channel-icon--email {
  background: var(--aah-chat-bone);
  color: var(--aah-chat-accent);
  border: 1px solid var(--aah-chat-line-gold);
}

#aah-chat-widget .aah-chat__channel-icon--phone {
  background: var(--aah-chat-bone);
  color: var(--aah-chat-accent);
  border: 1px solid var(--aah-chat-line-gold);
}

#aah-chat-widget .aah-chat__channel-text {
  flex: 1;
  min-width: 0;
}

#aah-chat-widget .aah-chat__channel-text strong {
  display: block;
  font-size: .95rem;
  margin-bottom: 2px;
}

#aah-chat-widget .aah-chat__channel-text span {
  font-size: .82rem;
  color: var(--aah-chat-muted);
}

#aah-chat-widget .aah-chat__channel-arrow {
  color: var(--aah-chat-accent);
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: transform .2s;
}

#aah-chat-widget .aah-chat__channel:hover .aah-chat__channel-arrow {
  transform: translateX(3px);
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */

/* ── ≤1024px ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  #aah-chat-widget .aah-chat__panel {
    width: 360px;
    height: 560px;
  }
}

/* ── ≤768px ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #aah-chat-widget {
    right: 12px;
    bottom: 12px;
  }
  #aah-chat-widget.aah-chat--left {
    left: 12px;
    right: auto;
  }
  #aah-chat-widget .aah-chat__panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
    bottom: calc(var(--aah-chat-launcher) + 12px);
    right: 0;
    border-radius: 14px;
  }
  #aah-chat-widget.aah-chat--left .aah-chat__panel {
    left: 0;
    right: auto;
  }
  #aah-chat-widget .aah-chat__launch {
    --aah-chat-launcher: 54px;
  }
}

/* ── ≤480px ────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #aah-chat-widget {
    right: 8px;
    bottom: 8px;
  }
  #aah-chat-widget .aah-chat__panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
    bottom: calc(var(--aah-chat-launcher) + 8px);
    border-radius: 12px;
  }
  #aah-chat-widget .aah-chat__head { padding: 14px 16px; }
  #aah-chat-widget .aah-chat__brand strong { font-size: 1.05rem; }
  #aah-chat-widget .aah-chat__body { padding: 16px; }
  #aah-chat-widget .aah-chat__msg { font-size: 13px; }
  #aah-chat-widget .aah-chat__chip { font-size: 12px; padding: 8px 12px; }
  #aah-chat-widget .aah-chat__tab { font-size: 11.5px; padding: 10px 6px; }
}

/* ── Safe area (notched phones) ────────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #aah-chat-widget {
    bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  #aah-chat-widget *,
  #aah-chat-widget *::before,
  #aah-chat-widget *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  #aah-chat-widget .aah-chat__panel {
    transition: none;
  }
}

/* ── Print ─────────────────────────────────────────────────────────────── */
@media print {
  #aah-chat-widget { display: none !important; }
}
