.chat-message.bot .message-content table {
  width: 100%;
  table-layout: fixed;
  word-break: break-word;
}

/* ========================================================== */
/*           テーブルのスタイル（<table>対応）                */
/* ========================================================== */

/* テーブル基本設定 */
.chat-message.bot .message-content table {
  border-collapse: collapse !important;
  margin: 12px 0;
}

/* テーブルヘッダー背景用の疑似要素 */
.chat-message.bot .message-content table thead {
  position: relative;
  border-bottom: 2px solid var(--user-bubble-bg);
}

.chat-message.bot .message-content table thead::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--user-bubble-bg);
  opacity: 0.1;
  pointer-events: none;
  z-index: 0;
}

/* ダークモード時のテーブルヘッダー背景 */
:root.dark-mode .chat-message.bot .message-content table thead::before {
  opacity: 0.2;
}

/* テーブルヘッダーセル */
.chat-message.bot .message-content table thead th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  position: relative;
  z-index: 1;
}

/* テーブルボディ */
.chat-message.bot .message-content table tbody tr {
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

/* 奇数行の背景色（ストライプ効果） */
.chat-message.bot .message-content table tbody tr:nth-child(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* ダークモード時の奇数行 */
:root.dark-mode .chat-message.bot .message-content table tbody tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.03);
}

/* 行のホバー効果用の疑似要素 */
.chat-message.bot .message-content table tbody tr::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--user-bubble-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 0;
}

.chat-message.bot .message-content table tbody tr:hover::before {
  opacity: 0.08;
}

:root.dark-mode .chat-message.bot .message-content table tbody tr:hover::before {
  opacity: 0.15;
}

/* テーブルセル */
.chat-message.bot .message-content table td {
  padding: 10px 12px;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  vertical-align: top;
  position: relative;
  z-index: 1;
}

/* テーブル内の強調テキスト */
.chat-message.bot .message-content table strong {
  font-weight: 600;
  color: var(--text-color);
}

/* テーブルのスクロール対応 */
.chat-message.bot .message-content table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 12px 0;
}

.chat-message.bot .message-content table thead,
.chat-message.bot .message-content table tbody,
.chat-message.bot .message-content table tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

/* モバイル用のテーブル調整 */
@media (max-width: 767px) {
  .chat-message.bot .message-content table {
    font-size: 0.85em;
  }

  .chat-message.bot .message-content table th,
  .chat-message.bot .message-content table td {
    padding: 8px;
  }
}

/* テーブルのスクロールバーのスタイル */
.chat-message.bot .message-content table::-webkit-scrollbar {
  height: 8px;
}

.chat-message.bot .message-content table::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

/* ダークモード時のスクロールバートラック */
:root.dark-mode .chat-message.bot .message-content table::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
}

/* スクロールバーサム（テーマカラー使用） */
.chat-message.bot .message-content table::-webkit-scrollbar-thumb {
  background-color: var(--user-bubble-bg);
  opacity: 0.3;
  border-radius: 4px;
}

.chat-message.bot .message-content table::-webkit-scrollbar-thumb:hover {
  opacity: 0.5;
}

/* ダークモード時のスクロールバーサム */
:root.dark-mode .chat-message.bot .message-content table::-webkit-scrollbar-thumb {
  opacity: 0.4;
}

:root.dark-mode .chat-message.bot .message-content table::-webkit-scrollbar-thumb:hover {
  opacity: 0.6;
}
