/* AscendedOps — Chat widget styles */

/* ── Widget container ── */
#chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* Push up on mobile to clear the sticky CTA bar */
@media (max-width: 899px) {
  #chat-widget {
    bottom: 100px;
  }
}

/* ── Bubble button ── */
#chat-bubble {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  transition: transform var(--duration-fast) ease-out,
              background var(--duration-fast) ease-out;
  flex-shrink: 0;
}

#chat-bubble:hover {
  background: var(--accent-hover);
  transform: scale(1.06);
}

#chat-bubble:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

#chat-bubble svg {
  width: 22px;
  height: 22px;
  color: #0A0A0A;
  flex-shrink: 0;
}

/* Bubble morphs to X when panel is open */
#chat-bubble .icon-chat { display: block; }
#chat-bubble .icon-close { display: none; }
#chat-widget.is-open #chat-bubble .icon-chat { display: none; }
#chat-widget.is-open #chat-bubble .icon-close { display: block; }

/* ── Panel ── */
#chat-panel {
  width: 360px;
  height: 500px;
  background: var(--bg-1);
  border: 1px solid var(--rule);
  border-radius: 12px 12px 0 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* entry animation */
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 220ms ease-out, transform 220ms ease-out;
  pointer-events: none;
}

#chat-panel:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* hidden attr: still render for animation, but remove from flow when truly hidden */
#chat-panel[hidden] {
  display: flex !important; /* override UA hidden style so animation works */
  visibility: hidden;
}

@media (max-width: 500px) {
  #chat-panel {
    width: calc(100vw - 32px);
    height: 420px;
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #chat-panel {
    transition: none;
    opacity: 1;
    transform: none;
  }
}

/* ── Panel header ── */
.chat-panel__header {
  background: var(--bg-2);
  border-bottom: 1px solid var(--rule);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-panel__title {
  font-family: var(--font-display);
  font-weight: var(--weight-heading);
  font-size: 15px;
  color: var(--accent);
  letter-spacing: -0.01em;
  line-height: 1;
}

.chat-panel__title .brand__ops {
  color: var(--text-primary);
}

.chat-panel__sub {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1;
  flex: 1;
}

.chat-panel__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--duration-fast) ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-panel__close:hover {
  color: var(--text-primary);
}

.chat-panel__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Message area ── */
.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-panel__messages::-webkit-scrollbar {
  width: 4px;
}
.chat-panel__messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-panel__messages::-webkit-scrollbar-thumb {
  background: var(--rule-heavy);
  border-radius: 2px;
}

/* ── Message bubbles ── */
.chat-msg {
  max-width: 88%;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
}

.chat-msg--bot {
  align-self: flex-start;
  background: transparent;
  padding: 0;
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  padding: 9px 13px;
  border-radius: 12px 12px 0 12px;
}

/* ── Typing indicator ── */
.chat-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}

.chat-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-pulse 1.2s ease-in-out infinite;
}

.chat-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40%            { opacity: 1;   transform: scale(1);    }
}

@media (prefers-reduced-motion: reduce) {
  .chat-typing__dot {
    animation: none;
    opacity: 0.6;
  }
}

/* ── Input row ── */
.chat-panel__input-row {
  border-top: 1px solid var(--rule);
  background: var(--bg-2);
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  background: var(--bg-1);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 11px;
  resize: none;
  overflow-y: hidden;
  transition: border-color var(--duration-fast) ease-out;
  min-height: 36px;
  max-height: calc(3 * 1.5 * 14px + 16px);
}

#chat-input::placeholder {
  color: var(--text-muted);
}

#chat-input:focus {
  outline: none;
  border-color: var(--rule-heavy);
}

#chat-send {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #0A0A0A;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: var(--weight-medium);
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) ease-out,
              opacity var(--duration-fast) ease-out;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 5px;
}

#chat-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

#chat-send:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#chat-send svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
