/* base.css : 全画面共通の基本スタイル ＋ チャットUI ＋フォーム */

/* 全体 */
html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
}

/* コンテンツの箱 */
.container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
  margin-bottom: 260px;  /* 下の入力欄に隠れないよう余白 */
}

h1 {
  font-size: 20px;
  margin-top: 0;
  margin-bottom: 8px;
}

.desc {
  font-size: 13px;
  color: #555;
  margin-bottom: 16px;
  line-height: 1.4;
}

/* ============================
   チャットログ（吹き出し＋アイコン）
============================ */
.chat-log {
  border-top: 1px solid #eee;
  margin-top: 10px;
  padding-top: 10px;
  font-size: 14px;
}

.msg {
  display: flex;
  margin-bottom: 12px;
}

.msg-user {
  justify-content: flex-end;
}

.msg-ai {
  justify-content: flex-start;
}

.msg-inner {
  display: flex;
  align-items: flex-end;
  max-width: 80%;
}

.msg-user .msg-inner {
  flex-direction: row-reverse;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #66cdaa, #000080);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff !important;  /* グラデーション上で文字が沈まないよう強制 */
  margin: 0 8px;
  flex-shrink: 0;
}

.bubble {
  padding: 8px 10px;
  border-radius: 12px;
  background: #e5f0ff;            /* ユーザー用 */
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.msg-ai .bubble {
  background: #f1f5f9;
}

.bubble-header {
  font-size: 11px;
  margin-bottom: 2px;
  color: #6b7280;
}

.bubble-text {
  font-size: 16px;
  line-height: 1.5;
}

.msg-meta {
  font-size: 11px;
  color: #777;
  margin-top: 4px;
}

/* ============================
   フォーム＆ボタン
============================ */
.input-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

label {
  font-size: 13px;
  display: block;
  margin: 8px 0 4px;
}

input[type="text"],
textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  font-size: 14px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

input[type="file"] {
  font-size: 13px;
}

button {
  margin-top: 10px;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 4px;
  border: none;
  background: #2563eb;
  color: white;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status {
  font-size: 12px;
  color: #666;
}

/* ============================
   画像プレビュー
============================ */
#imagePreviewArea {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-item {
  position: relative;
  display: inline-block;
}

.preview-item img {
  max-width: 160px;
  max-height: 160px;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  line-height: 20px;
  padding: 0;
}

/* ============================
   レイアウト（フォーム横並び）
============================ */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}

.form-col {
  flex: 1;
}

@media (max-width: 640px) {
  .form-row {
    flex-direction: column;
  }
}

/* ---- Markdown 調整（ChatGPT風） ---- */
.bubble-text p {
  margin: 0.3em 0;
  line-height: 1.5;
}

.bubble-text ul,
.bubble-text ol {
  margin: 0.3em 0 0.3em 1.2em;
  line-height: 1.5;
}

.bubble-text li {
  margin: 0.2em 0;
}

.bubble-text h1,
.bubble-text h2,
.bubble-text h3,
.bubble-text h4 {
  margin: 0.4em 0 0.25em 0;
  line-height: 1.25;
}

/* ---- AI / USER アバター共通 ---- */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin: 0 8px;
  flex-shrink: 0;
}

/* ユーザーのアイコン（絵文字） */
.avatar-user {
  color: #2563eb;
}

/* AI（花子先生）のアイコン画像 */
.avatar-ai {
  background-image: url("/img/hanako.webp");
  background-size: cover;
  background-position: center;
  color: transparent; /* 絵文字を消す */
}
