/* Ask the Guide chat widget */
:root {
  --ag-emerald: #1B4D3E;
  --ag-red: #B91C1C;
  --ag-cream: #FAF7EE;
  --ag-card: #F7F1E1;
  --ag-dark: #252A28;
  --ag-gold: #D9A83D;
}

.ag-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  background: var(--ag-emerald);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: background 0.2s;
}
.ag-toggle-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.ag-toggle:hover { background: #163d31; }
.ag-toggle:focus-visible { outline: 3px solid var(--ag-gold); outline-offset: 2px; }

.ag-tooltip {
  position: absolute;
  right: 60px;
  bottom: 50%;
  transform: translateY(50%);
  background: var(--ag-dark);
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.ag-toggle:hover .ag-tooltip,
.ag-toggle:focus-visible .ag-tooltip { opacity: 1; }

.ag-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 360px;
  height: 480px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  background: var(--ag-cream);
  display: flex;
  flex-direction: column;
  z-index: 8999;
  visibility: hidden;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.22s, transform 0.22s, visibility 0s 0.22s;
  overflow: hidden;
}
.ag-panel.ag-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.22s, transform 0.22s;
}

.ag-header {
  background: var(--ag-emerald);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ag-header-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}
.ag-header-sub {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 1px;
}
.ag-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.ag-close:hover { opacity: 1; }
.ag-close:focus-visible { outline: 2px solid var(--ag-gold); }

.ag-messages {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  gap: 8px;
}

.ag-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.ag-bubble.ag-user {
  background: var(--ag-emerald);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.ag-bubble.ag-bot {
  background: var(--ag-card);
  color: var(--ag-dark);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.ag-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
  background: var(--ag-card);
  border-radius: 8px;
  border-bottom-left-radius: 2px;
}
.ag-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ag-emerald);
  opacity: 0.4;
  animation: ag-pulse 1.2s ease-in-out infinite;
}
.ag-typing span:nth-child(2) { animation-delay: 0.2s; }
.ag-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ag-pulse {
  0%, 80%, 100% { opacity: 0.4; transform: scale(1); }
  40% { opacity: 1; transform: scale(1.2); }
}

.ag-input-row {
  display: flex;
  padding: 8px;
  gap: 8px;
  border-top: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}
.ag-input {
  flex: 1;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
  color: var(--ag-dark);
  outline: none;
  transition: border-color 0.15s;
}
.ag-input:focus { border-color: var(--ag-emerald); }
.ag-input:disabled { background: #f0f0f0; cursor: not-allowed; }
.ag-send {
  background: var(--ag-red);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.ag-send:hover:not(:disabled) { background: #a01919; }
.ag-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ag-send:focus-visible { outline: 2px solid var(--ag-gold); outline-offset: 2px; }

.ag-credit {
  text-align: center;
  font-size: 10px;
  color: #888;
  padding: 4px 8px;
  flex-shrink: 0;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ag-panel {
    background: var(--ag-dark);
  }
  :root:not([data-theme="light"]) .ag-bubble.ag-bot {
    background: #333a37;
    color: #f0ede4;
  }
  :root:not([data-theme="light"]) .ag-input {
    background: #1e2422;
    border-color: #444;
    color: #f0ede4;
  }
  :root:not([data-theme="light"]) .ag-input-row {
    border-top-color: rgba(255,255,255,0.1);
  }
  :root:not([data-theme="light"]) .ag-credit { color: #666; }
}
[data-theme="dark"] .ag-panel { background: var(--ag-dark); }
[data-theme="dark"] .ag-bubble.ag-bot { background: #333a37; color: #f0ede4; }
[data-theme="dark"] .ag-input { background: #1e2422; border-color: #444; color: #f0ede4; }
[data-theme="dark"] .ag-input-row { border-top-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .ag-credit { color: #666; }

/* Mobile */
@media (max-width: 480px) {
  .ag-panel {
    width: 100%;
    right: 0;
    bottom: 0;
    border-radius: 12px 12px 0 0;
    height: 70vh;
    max-height: 520px;
  }
  .ag-panel .ag-header { border-radius: 12px 12px 0 0; }
  .ag-toggle {
    bottom: 16px;
    right: 16px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ag-typing span { animation: none; opacity: 0.6; }
  .ag-panel { transition: none; }
}
