/**
 * NPC Chat Modal Styles
 *
 * Styling for the freeform AI chat modal.
 * Uses HexUI CSS variables for consistency.
 */

/* Container */
.npc-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 450px;
  gap: 12px;
}

/* Header with NPC info */
.npc-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-dark, rgba(212, 175, 55, 0.2));
}

.npc-chat-portrait {
  width: 56px;
  height: 56px;
  border: 2px solid var(--border-light, rgba(212, 175, 55, 0.4));
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.npc-chat-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.npc-chat-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.npc-chat-name {
  font-size: 16px;
  font-weight: bold;
  color: var(--text-accent, #d4af37);
}

.npc-chat-title {
  font-size: 12px;
  color: var(--text-secondary, #a0a0a0);
}

/* Messages area */
.npc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
}

/* Scrollbar styling */
.npc-chat-messages::-webkit-scrollbar {
  width: 8px;
}

.npc-chat-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.npc-chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-dark, rgba(212, 175, 55, 0.3));
  border-radius: 4px;
}

.npc-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--border-light, rgba(212, 175, 55, 0.5));
}

/* Intro message */
.npc-chat-intro {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary, #a0a0a0);
}

.npc-chat-intro p {
  margin: 0 0 8px;
}

.npc-chat-intro .npc-chat-hint {
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted, #707070);
}

/* Message bubbles */
.npc-chat-message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: messageSlideIn 0.2s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.npc-chat-message.from-npc {
  align-self: flex-start;
}

.npc-chat-message.from-player {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.npc-chat-message.system-message {
  align-self: center;
  max-width: 90%;
}

/* Avatar */
.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--border-dark, rgba(212, 175, 55, 0.3));
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Chat bubble */
.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 100%;
}

.from-npc .chat-bubble {
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--border-dark, rgba(212, 175, 55, 0.25));
  border-radius: 12px 12px 12px 4px;
}

.from-player .chat-bubble {
  background: rgba(100, 149, 237, 0.2);
  border: 1px solid rgba(100, 149, 237, 0.3);
  border-radius: 12px 12px 4px 12px;
}

.system-message .chat-bubble {
  background: rgba(128, 128, 128, 0.2);
  border: 1px solid rgba(128, 128, 128, 0.3);
  font-style: italic;
}

.chat-sender {
  display: block;
  font-size: 11px;
  font-weight: bold;
  margin-bottom: 4px;
  opacity: 0.8;
}

.from-npc .chat-sender {
  color: var(--text-accent, #d4af37);
}

.from-player .chat-sender {
  color: #6495ed;
}

.chat-text {
  margin: 0;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Input area */
.npc-chat-input-area {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-dark, rgba(212, 175, 55, 0.2));
}

.npc-chat-input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-dark, rgba(212, 175, 55, 0.3));
  border-radius: 20px;
  color: var(--text-primary, #e0e0e0);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.npc-chat-input:focus {
  border-color: var(--border-light, rgba(212, 175, 55, 0.5));
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.1);
}

.npc-chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.npc-chat-input::placeholder {
  color: var(--text-muted, #707070);
}

.npc-chat-send-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--button-bg, rgba(212, 175, 55, 0.2));
  border: 1px solid var(--border-light, rgba(212, 175, 55, 0.4));
  border-radius: 50%;
  color: var(--text-accent, #d4af37);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.npc-chat-send-btn:hover:not(:disabled) {
  background: var(--button-hover, rgba(212, 175, 55, 0.3));
  transform: scale(1.05);
}

.npc-chat-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.npc-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.npc-chat-send-btn svg {
  width: 20px;
  height: 20px;
}

/* Status area */
.npc-chat-status {
  min-height: 20px;
  font-size: 12px;
  color: var(--text-secondary, #a0a0a0);
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.npc-chat-status.visible {
  opacity: 1;
}

/* Typing indicator animation */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.typing-indicator .dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 2px;
}

.typing-indicator .dots span {
  animation: dotBounce 1.4s infinite ease-in-out both;
}

.typing-indicator .dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator .dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes dotBounce {
  0%, 80%, 100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}
