/* ================================================================
   AMANTECH — AI Chat Widget
   ================================================================ */

/* ── Variables ── */
:root {
  --chat-green:       #228058;
  --chat-green-dark:  #0a6336;
  --chat-green-light: #2da06a;
  --chat-bg:          #0b1a0e;
  --chat-surface:     #0f2214;
  --chat-border:      rgba(34, 128, 88, 0.25);
  --chat-text:        #ddeee4;
  --chat-muted:       rgba(221, 238, 228, 0.55);
  --chat-radius:      14px;
  --chat-shadow:      0 24px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(34,128,88,0.18);
}

/* ── Floating Trigger Button ── */
#aman-chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--chat-green);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(34, 128, 88, 0.45), 0 2px 8px rgba(0,0,0,0.4);
  z-index: 9998;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1),
              box-shadow 0.25s ease,
              background 0.2s ease;
  outline: none;
}

#aman-chat-trigger:hover {
  background: var(--chat-green-light);
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(34, 128, 88, 0.6), 0 2px 8px rgba(0,0,0,0.4);
}

#aman-chat-trigger:active {
  transform: scale(0.96);
}

#aman-chat-trigger svg {
  width: 30px;
  height: 26px;
  fill: #fff;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#aman-chat-trigger .icon-chat  { opacity: 1;  position: absolute; }
#aman-chat-trigger .icon-close { opacity: 0;  position: absolute; transform: rotate(-90deg); }

#aman-chat-trigger.is-open .icon-chat  { opacity: 0; transform: rotate(90deg); }
#aman-chat-trigger.is-open .icon-close { opacity: 1; transform: rotate(0deg);  }

/* Pulsing badge (new message / attention) */
#aman-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #ff4f4f;
  border-radius: 50%;
  border: 2px solid #060d08;
  display: none;
  animation: badge-pulse 1.8s infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%       { transform: scale(1.2); opacity: 0.8; }
}

/* ── Chat Panel ── */
#aman-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 370px;
  max-height: 560px;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow);
  z-index: 9999;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.88) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(.34,1.56,.64,1),
              opacity   0.22s ease;
}

#aman-chat-panel.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Panel Header ── */
#aman-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--chat-surface);
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--chat-green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header-avatar svg {
  width: 24px;
  height: 20px;
  fill: #fff;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-name {
  font-family: 'Arima Madurai', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--chat-text);
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.chat-header-status {
  font-size: 0.72rem;
  color: var(--chat-green-light);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-green-light);
  animation: online-pulse 2.5s infinite;
  flex-shrink: 0;
}

@keyframes online-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Messages Area ── */
#aman-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#aman-chat-messages::-webkit-scrollbar {
  width: 4px;
}
#aman-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
#aman-chat-messages::-webkit-scrollbar-thumb {
  background: var(--chat-border);
  border-radius: 4px;
}

/* Message bubbles */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: msg-in 0.22s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.msg-user  { align-self: flex-end;  align-items: flex-end; }
.chat-msg.msg-bot   { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-user .chat-bubble {
  background: var(--chat-green);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bot .chat-bubble {
  background: var(--chat-surface);
  color: var(--chat-text);
  border: 1px solid var(--chat-border);
  border-bottom-left-radius: 4px;
}

/* Render basic markdown-style formatting */
.chat-bubble strong { font-weight: 700; }
.chat-bubble em     { font-style: italic; }
.chat-bubble a      { color: var(--chat-green-light); text-decoration: underline; }

.chat-timestamp {
  font-size: 0.65rem;
  color: var(--chat-muted);
  margin-top: 4px;
  padding: 0 4px;
}

/* ── Typing indicator ── */
#aman-typing {
  display: none;
  align-self: flex-start;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

#aman-typing.is-visible {
  display: flex;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chat-green);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
  opacity: 0.7;
}

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

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1;   }
}

/* ── Quick reply chips ── */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chat-chip {
  background: transparent;
  border: 1px solid var(--chat-border);
  color: var(--chat-green-light);
  font-size: 0.76rem;
  padding: 5px 11px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.chat-chip:hover {
  background: rgba(34, 128, 88, 0.15);
  border-color: var(--chat-green);
}

/* ── Input area ── */
#aman-chat-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--chat-border);
  background: var(--chat-surface);
  flex-shrink: 0;
}

#aman-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  padding: 6px 8px 6px 14px;
  transition: border-color 0.2s;
}

#aman-chat-form:focus-within {
  border-color: var(--chat-green);
}

#aman-chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--chat-text);
  font-size: 0.875rem;
  line-height: 1.4;
  resize: none;
  max-height: 96px;
  padding: 4px 0;
  font-family: inherit;
}

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

#aman-chat-send {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--chat-green);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

#aman-chat-send:hover  { background: var(--chat-green-light); }
#aman-chat-send:active { transform: scale(0.94); }
#aman-chat-send:disabled { background: rgba(34, 128, 88, 0.3); cursor: not-allowed; }

#aman-chat-send svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

.chat-footer-note {
  text-align: center;
  font-size: 0.64rem;
  color: var(--chat-muted);
  margin-top: 8px;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  #aman-chat-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 80vh;
    border-radius: var(--chat-radius) var(--chat-radius) 0 0;
    transform-origin: bottom center;
  }

  #aman-chat-trigger {
    bottom: 20px;
    right: 20px;
  }
}
