/* ============================================
   ATAMAP ASSOCIATES — Friday AI Chatbot
   Apple HIG–calibrated tokens applied
   ============================================ */

/* ---- Chat Toggle Button ---- */
.chat-toggle {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-overlay);
  width: var(--chat-toggle-size);
  height: var(--chat-toggle-size);
  border-radius: 50%;
  background: var(--color-accent);
  color: #0d1117;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--elevation-2);
  transition: transform var(--duration-base) var(--ease-standard),
              box-shadow var(--duration-base) var(--ease-standard);
}

.chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: var(--elevation-3), 0 0 30px rgba(200, 164, 92, 0.3);
}

.chat-toggle:active {
  transform: scale(0.95);
  transition-duration: var(--duration-fast);
}

.chat-toggle svg {
  width: var(--icon-nav);
  height: var(--icon-nav);
}

.chat-toggle__badge {
  position: absolute;
  top: calc(-1 * var(--space-1));
  right: calc(-1 * var(--space-1));
  width: var(--space-2-5);
  height: var(--space-2-5);
  background: var(--color-danger);
  border-radius: 50%;
  border: var(--space-0-5) solid #141b2d;
  display: none;
}

.chat-toggle__badge.is-visible {
  display: block;
}

/* ---- Chat Window ---- */
.chat-window {
  position: fixed;
  bottom: var(--chat-offset);
  right: var(--space-5);
  z-index: var(--z-modal);
  width: 380px;
  max-width: calc(100vw - var(--space-12));
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #141b2d;
  border: 1px solid #374151;
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(var(--space-4)) scale(0.95);
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-standard),
              transform var(--duration-base) var(--ease-standard);
}

.chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---- Chat Header ---- */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: #1a2332;
  border-bottom: 1px solid #374151;
  flex-shrink: 0;
}

.chat-header__info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-header__avatar {
  width: var(--touch-target-xs);
  height: var(--touch-target-xs);
  border-radius: 50%;
  background: var(--color-accent-dim);
  border: 1px solid var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
}

.chat-header__title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: #f9fafb;
}

.chat-header__status {
  font-size: var(--font-size-xs);
  color: var(--color-success);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.chat-header__status::before {
  content: '';
  width: var(--space-1-5);
  height: var(--space-1-5);
  border-radius: 50%;
  background: var(--color-success);
  display: inline-block;
}

.chat-close {
  width: var(--touch-target-xs);
  height: var(--touch-target-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: #6b7280;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) var(--ease-standard),
              background var(--duration-fast) var(--ease-standard);
}

.chat-close:hover {
  color: #f9fafb;
  background: #243049;
}

.chat-close svg {
  width: var(--icon-inline);
  height: var(--icon-inline);
}

/* ---- Chat Messages ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chat-messages::-webkit-scrollbar {
  width: var(--space-1);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: var(--space-1);
}

.chat-message {
  max-width: 85%;
  animation: chatMessageIn var(--duration-base) var(--ease-standard) both;
}

@keyframes chatMessageIn {
  from {
    opacity: 0;
    transform: translateY(var(--space-2));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message--bot {
  align-self: flex-start;
}

.chat-message--user {
  align-self: flex-end;
}

.chat-message__bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
}

.chat-message--bot .chat-message__bubble {
  background: #1e293b;
  border: 1px solid #374151;
  color: #e5e7eb;
  border-bottom-left-radius: var(--radius-sm);
}

.chat-message--user .chat-message__bubble {
  background: var(--color-accent);
  color: #0d1117;
  border-bottom-right-radius: var(--radius-sm);
}

.chat-message__time {
  font-size: var(--font-size-3xs);
  color: #6b7280;
  margin-top: var(--space-1);
  padding-inline: var(--space-1);
}

.chat-message--bot .chat-message__time {
  text-align: left;
}

.chat-message--user .chat-message__time {
  text-align: right;
}

/* Quick reply buttons inside bot messages */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.chat-quick-reply {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-full);
  background: transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
  font-family: var(--font-family);
}

.chat-quick-reply:hover {
  background: var(--color-accent-dim);
}

/* ---- Typing Indicator ---- */
.chat-typing {
  align-self: flex-start;
  display: none;
  padding: var(--space-3) var(--space-4);
  background: #1e293b;
  border: 1px solid #374151;
  border-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-sm);
}

.chat-typing.is-visible {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.chat-typing__dot {
  width: var(--space-1-5);
  height: var(--space-1-5);
  border-radius: 50%;
  background: #6b7280;
  animation: typingBounce 1.4s var(--ease-in-out-smooth) infinite;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(calc(-1 * var(--space-1))); }
}

/* ---- Chat Input ---- */
.chat-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid #374151;
  background: #1a2332;
  flex-shrink: 0;
}

.chat-input__field {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: #141b2d;
  border: 1px solid #374151;
  border-radius: var(--radius-full);
  color: #f9fafb;
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-standard);
}

.chat-input__field:focus {
  border-color: var(--color-accent);
}

.chat-input__field::placeholder {
  color: #6b7280;
}

.chat-input__send {
  width: var(--touch-target-sm);
  height: var(--touch-target-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--color-accent);
  color: #0d1117;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-emphasis);
  flex-shrink: 0;
}

.chat-input__send:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
}

.chat-input__send:active {
  transform: scale(0.95);
}

.chat-input__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.chat-input__send svg {
  width: var(--icon-inline);
  height: var(--icon-inline);
}

/* ---- Chat Disclaimer ---- */
.chat-disclaimer {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-3xs);
  color: #6b7280;
  text-align: center;
  background: #0d1117;
  border-top: 1px solid rgba(55, 65, 81, 0.3);
  flex-shrink: 0;
}

/* ---- Mobile adjustments ---- */
@media (max-width: 480px) {
  .chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .chat-toggle {
    bottom: var(--space-4);
    right: var(--space-4);
    width: var(--touch-target-lg);
    height: var(--touch-target-lg);
  }

  .chat-input__field {
    font-size: var(--font-size-base); /* Prevent iOS zoom */
  }
}

/* Touch-friendly quick replies */
@media (pointer: coarse) {
  .chat-quick-reply {
    min-height: var(--touch-target-sm);
    padding: var(--space-2) var(--space-4);
  }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
  .chat-window {
    transition: none;
  }

  .chat-message {
    animation: none;
  }

  .chat-typing__dot {
    animation: none;
  }
}
