/* =========================================================
   Reset & Base Styles
   ========================================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #fff;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* =========================================================
   Chat Container
   ========================================================= */
.chat-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  background: #fff;
  z-index: 999;
}

.chat-container.hidden {
  display: none !important;
}

/* =========================================================
   Dark Mode Overrides
   ========================================================= */
.chat-container.dark-mode {
  background-color: #333;
  color: #f5f5f5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Dark mode header controls */
.chat-container.dark-mode .chat-header {
  background: #2f5c95;
}

/* Dark mode messages background */
.chat-container.dark-mode .chat-messages {
  background-color: #222;
}

/* Dark mode message bubbles */
.chat-container.dark-mode .message.agent {
  background-color: #444;
  border-color: #555;
  color: #f5f5f5;
}
.chat-container.dark-mode .message.agent::before {
  border-color: transparent #555 transparent transparent;
}
.chat-container.dark-mode .message.agent::after {
  border-color: transparent #444 transparent transparent;
}
.chat-container.dark-mode .message.user {
  color: #000;
}

/* Dark mode option buttons */
.chat-container.dark-mode .option-btn {
  background-color: #444;
  color: #f5f5f5;
}
.chat-container.dark-mode .option-btn:hover {
  background-color: #555;
}

/* Dark mode footer & inputs */
.chat-container.dark-mode .chat-footer {
  background-color: #333;
  border-color: #555;
}
.chat-container.dark-mode .chat-footer input[type="text"] {
  background-color: #4a4a4a;
  border: 1px solid #555;
  color: #f5f5f5;
}
.chat-container.dark-mode .chat-footer input[type="text"]::placeholder {
  color: #ccc;
  opacity: 1;
}
.chat-container.dark-mode .chat-footer button {
  background-color: #2f5c95;
  color: #fff;
}
.chat-container.dark-mode .chat-footer button:hover {
  background-color: #1f4f7a;
}
/* =========================================================
   Header
   ========================================================= */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #2f5c95;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
}
/* ダークモードトグルを完全に透過させる */
.chat-header .header-btn {
  background: transparent !important;
  border: none !important;
  padding: 4px; /* 必要に応じて調整 */
}

/* アイコン画像（もしあれば）にも余計な背景や影がつかないように */
.chat-header .header-btn .fullscreen-icon,
.chat-header .header-btn .fullscreen-exit-icon {
  background: transparent;
}
/* =========================================================
   Messages Area
   ========================================================= */
.chat-messages {
  flex: 1;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: 60px;
}

.chat-container.dark-mode .chat-messages {
  background-color: #222;
}

/* Spacing between adjacent message rows */
.chat-messages .message-row + .message-row {
  margin-top: 8px;
}

/* =========================================================
   Message Row & Avatar
   ========================================================= */
.message-row {
  display: flex;
  align-items: flex-start;
  padding: 0 2px;
  margin-bottom: 0;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.agent {
  justify-content: flex-start;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin-right: 8px;
}

.message-row.user .avatar {
  display: none;
}

/* =========================================================
   Message Bubble
   ========================================================= */
.message {
  max-width: 85%;
  padding: 8px 10px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.35;
  word-wrap: break-word;
  white-space: normal;
}

.message.user {
  background: #DCF8C6;
  border-radius: 14px 14px 0 14px;
  max-width: 75%;
}

.chat-container.dark-mode .message.user {
  color: #000 !important;
}

.message.agent {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 14px 14px 14px 0;
  max-width: 85%;
  position: relative;
}

.message.agent::before,
.message.agent::after {
  content: "";
  position: absolute;
  top: 10px;
  left: -7px;
  border-style: solid;
}

.message.agent::before {
  border-width: 7px 7px 7px 0;
  border-color: transparent #ddd transparent transparent;
}

.message.agent::after {
  border-width: 6px 6px 6px 0;
  border-color: transparent #fff transparent transparent;
}

.chat-container.dark-mode .message.agent {
  background-color: #444;
  border-color: #555;
  color: #f5f5f5;
}

.chat-container.dark-mode .message.agent::before {
  border-color: transparent #555 transparent transparent;
}

.chat-container.dark-mode .message.agent::after {
  border-color: transparent #444 transparent transparent;
}

/* =========================================================
   Option Buttons
   ========================================================= */
.options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.option-btn {
  padding: 5px 10px;
  margin: 5px 0;
  border: 1px solid #ddd;
  border-radius: 15px;
  background: #f0f0f0;
  cursor: pointer;
  transition: background 0.3s ease;
}

.option-btn:hover {
  background-color: #e0e0e0;
}

.option-btn.disabled {
  background-color: #ccc;
  cursor: not-allowed;
  opacity: 0.5;
}

.chat-container.dark-mode .option-btn {
  background-color: #444;
  color: #f5f5f5;
}

.chat-container.dark-mode .option-btn:hover {
  background-color: #555;
}

/* =========================================================
   Footer & Input Area
   ========================================================= */
.chat-footer {
  grid-row: 3;
  display: flex;
  padding: 4px 8px;
  border-top: 1px solid #ddd;
  background: #f9f9f9;
  position: sticky;    /* スクロールしても貼り付く */
  bottom: 0;           /* 画面下端に */
  z-index: 10;         /* メッセージより上に */
}

.chat-footer input[type="text"] {
  flex: 1;
  height: 26px;
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  outline: none;
}

.chat-footer input[type="text"]:focus {
  border-color: #2f5c95;
  box-shadow: 0 0 0 2px rgba(30,144,255,0.2);
}

/* Placeholder styles */
.chat-footer input[type="text"]::placeholder {
  color: #666;
  opacity: 1;
}

.chat-container.dark-mode .chat-footer input[type="text"] {
  background: #888;
  border: 1px solid #bbb;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
  color: #000;
}

.chat-container.dark-mode .chat-footer input[type="text"]::placeholder {
  color: #ccc;
  opacity: 1;
}

.chat-footer button {
  margin-left: 6px;
  padding: 0 10px;
  height: 26px;
  font-size: 13px;
  background: #2f5c95;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.chat-footer button:hover {
  background: #2f5c95;
}

.chat-footer button:active {
  transform: scale(0.95);
}

/* =========================================================
   Markdown Lists & Paragraphs
   ========================================================= */
#chat-messages .message ul {
  list-style-position: inside;
  list-style-type: disc;
  margin: 0.4em 0;
  padding-left: 1em;
}

#chat-messages .message li {
  margin-bottom: 0.3em;
}

#chat-messages .message p {
  margin: 0.3em 0;
  line-height: 1.4;
}

#chat-messages .message h3 {
  margin: 0.5em 0 0.3em;
  font-size: 1em;
}

