/* Tech Integra ERP — "Ask your ERP" hero chat window (index.html)
   Replaces the old terminal-style console look. Panel background stays the
   charcoal gradient set in refresh.css. */

.console.chat {
  --chat-surface: #2A2526;
  --chat-line: rgba(255,255,255,.08);
  --chat-text: #E9E4E4;
  --chat-muted: #9C9595;
  padding: 0;
  height: 440px; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 20px;
  font-family: var(--body); font-size: .97rem; line-height: 1.5;
  color: var(--chat-text);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}

/* ---- header ---- */
.chat__head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--chat-line);
  background: rgba(255,255,255,.02);
  flex: none;
}
.chat__who { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.chat__title {
  font-family: var(--display); font-weight: 700; font-size: 1rem;
  letter-spacing: -0.01em; color: #fff; text-transform: none;
}
.chat__status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--chat-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat__status i {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: #3FBF7F; box-shadow: 0 0 0 3px rgba(63,191,127,.16);
}

/* ---- avatars ---- */
.chat__avatar {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, #D2353E 0%, #8E2229 100%);
  box-shadow: 0 2px 8px -2px rgba(210,53,62,.55), inset 0 1px 0 rgba(255,255,255,.18);
}
.chat__avatar svg { width: 14px; height: 14px; }
.chat__avatar--head { width: 36px; height: 36px; }
.chat__avatar--head svg { width: 18px; height: 18px; }

/* ---- feed: anchored to bottom, older messages fade out at the top ---- */
.chat__feed {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 12px;
  padding: 20px 20px 14px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 64px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 64px);
}
.chat__row { display: flex; align-items: flex-end; gap: 10px; flex: none; }
.chat__row--user { justify-content: flex-end; }
.chat__row--ai { justify-content: flex-start; }

.chat__msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  overflow-wrap: anywhere;
}
.chat__msg--user {
  background: linear-gradient(160deg, #C8323F 0%, #B5323A 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 18px -10px rgba(200,50,63,.8);
}
.chat__msg--ai {
  background: var(--chat-surface);
  color: var(--chat-text);
  border: 1px solid rgba(255,255,255,.06);
  border-bottom-left-radius: 6px;
}
.chat__msg--ai b {
  color: #fff; font-weight: 700;
  background: rgba(210,53,62,.22);
  padding: 1px 6px; border-radius: 6px;
  white-space: nowrap;
}

/* entering rows grow in, so older messages glide upward instead of jumping */
.chat__row.is-new { animation: chatIn .42s cubic-bezier(.2,.7,.3,1) both; }
@keyframes chatIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.chat__grow { flex: none; display: grid; grid-template-rows: 0fr; transition: grid-template-rows .36s cubic-bezier(.2,.7,.3,1); }
.chat__grow.is-open { grid-template-rows: 1fr; }
.chat__grow > * { min-height: 0; overflow: hidden; }

/* typing indicator */
.chat__msg--typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.chat__msg--typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #A79F9F;
  animation: chatDot 1.2s ease-in-out infinite;
}
.chat__msg--typing span:nth-child(2) { animation-delay: .15s; }
.chat__msg--typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chatDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- fake composer ---- */
.chat__input {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px 16px;
  padding: 7px 7px 7px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  pointer-events: none; user-select: none;
}
.chat__field {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #fff; font-size: .94rem;
}
.chat__ph { color: #8E8787; }
.chat__caret {
  display: inline-block; width: 2px; height: 1.05em; margin-left: 1px;
  background: #D2353E; vertical-align: -3px;
  animation: chatCaret 1s steps(2) infinite;
}
@keyframes chatCaret { 50% { opacity: 0; } }
.chat__send {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.1); color: #A79F9F;
  transition: background .2s ease, color .2s ease;
}
.chat__input.is-ready .chat__send { background: #C8323F; color: #fff; }

/* screen-reader summary (the animated feed itself is aria-hidden) */
.chat__sr {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 900px) {
  .console.chat { height: 420px; }
}
@media (max-width: 480px) {
  .console.chat { height: 400px; border-radius: 18px; font-size: .94rem; }
  .chat__head { padding: 14px 16px; }
  .chat__feed { padding: 18px 14px 12px; gap: 10px; }
  .chat__msg { max-width: 86%; }
  .chat__input { margin: 0 12px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat__row.is-new, .chat__msg--typing span, .chat__caret { animation: none; }
  .chat__grow { transition: none; }
}
