/* Dashboard — chat with your agents */

.fx-chat-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 20px;
  min-height: min(72vh, 640px);
  align-items: stretch;
}

.fx-chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--fx-bg, #fff);
  border: 1px solid var(--fx-border, rgba(0, 0, 0, 0.08));
  border-radius: var(--fx-radius-lg, 12px);
  padding: 18px;
  box-shadow: var(--fx-shadow-sm);
}

.fx-chat-sidebar .form-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fx-text-secondary, #6b7280);
}

.fx-chat-sidebar #btn-new-chat {
  flex: 0 0 auto;
  align-self: flex-start;
  width: auto;
  min-height: 0;
  height: auto;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  border-radius: 6px;
}

.fx-chat-thread-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
  max-height: 420px;
}

.fx-chat-thread-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--fx-text, #12121a);
  transition: background 0.15s, border-color 0.15s;
}

.fx-chat-thread-btn:hover {
  background: var(--fx-bg-soft, #f5f5f7);
}

.fx-chat-thread-btn.is-active {
  background: var(--fx-bg-muted, #eef1f4);
  border-color: var(--fx-border, rgba(0, 0, 0, 0.08));
  font-weight: 600;
}

.fx-chat-thread-btn small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--fx-text-secondary, #6b7280);
  margin-top: 4px;
}

.fx-chat-main {
  display: flex;
  flex-direction: column;
  background: var(--fx-bg, #fff);
  border: 1px solid var(--fx-border, rgba(0, 0, 0, 0.08));
  border-radius: var(--fx-radius-lg, 12px);
  box-shadow: var(--fx-shadow-sm);
  overflow: hidden;
  min-height: 480px;
}

.fx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fafbfc;
}

.fx-chat-empty {
  margin: auto;
  text-align: center;
  color: var(--fx-text-secondary, #6b7280);
  font-size: 14px;
  line-height: 1.55;
  max-width: 320px;
}

.fx-chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.fx-chat-bubble--user {
  align-self: flex-end;
  background: var(--fx-accent, #12121a);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.fx-chat-bubble--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--fx-border, rgba(0, 0, 0, 0.08));
  color: var(--fx-text, #12121a);
  border-bottom-left-radius: 4px;
}

.fx-chat-typing {
  min-width: 56px;
  padding: 14px 18px;
}

.fx-chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 10px;
}

.fx-chat-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fx-text-secondary, #9ca3af);
  animation: fx-chat-typing-bounce 1.2s ease-in-out infinite;
}

.fx-chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.fx-chat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes fx-chat-typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.fx-chat-bubble.fx-chat-revealing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--fx-text-secondary, #6b7280);
  animation: fx-chat-cursor-blink 0.8s step-end infinite;
}

@keyframes fx-chat-cursor-blink {
  50% {
    opacity: 0;
  }
}

.fx-chat-compose {
  display: flex;
  gap: 12px;
  padding: 16px 18px;
  border-top: 1px solid var(--fx-border, rgba(0, 0, 0, 0.08));
  background: #fff;
  align-items: flex-end;
}

.fx-chat-compose textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 14px;
  border: 1px solid var(--fx-border, rgba(0, 0, 0, 0.12));
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

.fx-chat-compose .btn {
  flex-shrink: 0;
}

.fx-chat-send--working {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding-left: 0;
  padding-right: 0;
  cursor: pointer;
}

.fx-send-spinner {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
}

.fx-send-spinner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: fx-send-spin 0.7s linear infinite;
}

.fx-send-spinner::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 2px;
}

@keyframes fx-send-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .fx-chat-layout {
    grid-template-columns: 1fr;
  }

  .fx-chat-thread-list {
    max-height: 200px;
  }
}
