/**
 * style.css - AI 聊天介面樣式（深色主題）
 */

/* 全域重置與盒模型 */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 頁面背景與字型 */
body {
  min-height: 100vh;
  font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
  background: linear-gradient(145deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
  color: #e8e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* 主聊天視窗：置中、圓角、陰影 */
.app {
  width: 100%;
  max-width: 720px;
  height: min(90vh, 800px);
  display: flex;
  flex-direction: column;
  background: rgba(22, 22, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

/* 頂部標題區 */
.app-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
}

.app-header h1 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subtitle {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: #8888aa;
}

/* 訊息列表：可捲動 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* 單則訊息容器 */
.message {
  display: flex;
  max-width: 85%;
  animation: fadeIn 0.25s ease;
}

/* 使用者訊息靠右 */
.message--user {
  align-self: flex-end;
}

/* AI 訊息靠左 */
.message--assistant {
  align-self: flex-start;
}

/* 載入中樣式 */
.message--loading .message-bubble {
  color: #a0a0c0;
  font-style: italic;
}

/* 訊息泡泡 */
.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.message--user .message-bubble {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message--assistant .message-bubble {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 4px;
}

/* 錯誤訊息樣式 */
.message--error .message-bubble {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

/* 底部輸入區 */
.chat-input-area {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.25);
}

.chat-form {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}

/* 文字輸入框 */
.chat-input {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 0.65rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #e8e8f0;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #6366f1;
}

.chat-input::placeholder {
  color: #6b6b80;
}

.chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 送出按鈕 */
.send-btn {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  opacity: 0.95;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 新訊息淡入動畫 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 捲軸樣式（WebKit） */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
