/* =========================================
   千葉県保険医協会 診療報酬Q&Aチャットボット (WP版)
   ========================================= */

.chiba-chatbot-wrap {
  --green-primary: #4a9d6f;
  --green-dark: #3a7d57;
  --green-light: #e8f4ed;
  --gray-bg: #f7f9f7;
  --gray-border: #d9e3dc;
  --text-main: #2c3e34;
  --text-sub: #6b7d72;
  --white: #ffffff;
  --radius: 12px;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  color: var(--text-main);
  background: var(--white);
  line-height: 1.6;
  font-size: 14px;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 20px 0;
}
.chiba-chatbot-wrap *,
.chiba-chatbot-wrap *::before,
.chiba-chatbot-wrap *::after { box-sizing: border-box; }

.chiba-chatbot-wrap .chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 700px;
  background: var(--white);
}
.chiba-chatbot-wrap .chat-sidebar {
  background: var(--white);
  border-right: 1px solid var(--gray-border);
  padding: 28px 20px;
}
.chiba-chatbot-wrap .sidebar-title { text-align: center; margin-bottom: 20px; }
.chiba-chatbot-wrap .sidebar-title h2 {
  font-size: 22px; color: var(--green-dark); font-weight: 700; margin: 0;
}
.chiba-chatbot-wrap .sidebar-title p { font-size: 13px; color: var(--text-sub); margin: 4px 0 0; }
.chiba-chatbot-wrap .btn-new-chat {
  width: 100%; background: var(--green-primary); color: var(--white); border: none;
  padding: 14px; border-radius: var(--radius); font-size: 14px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.chiba-chatbot-wrap .btn-new-chat:hover { background: var(--green-dark); }
.chiba-chatbot-wrap .sidebar-info {
  margin-top: 28px; padding: 16px;
  border: 1.5px dashed var(--gray-border); border-radius: var(--radius); background: var(--gray-bg);
}
.chiba-chatbot-wrap .info-title { font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
.chiba-chatbot-wrap .sidebar-info p { font-size: 12px; color: var(--text-sub); margin: 0 0 12px; }

.chiba-chatbot-wrap .btn-contact-mail {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--white);
  color: var(--green-dark);
  border: 1.5px solid var(--green-primary);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  box-sizing: border-box;
}
.chiba-chatbot-wrap .btn-contact-mail:hover {
  background: var(--green-primary);
  color: var(--white);
}

.chiba-chatbot-wrap .chat-main { display: flex; flex-direction: column; background: var(--white); }
.chiba-chatbot-wrap .chat-header {
  padding: 20px 28px; border-bottom: 1px solid var(--gray-border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap;
}
.chiba-chatbot-wrap .chat-header__title { display: flex; align-items: center; gap: 14px; }
.chiba-chatbot-wrap .chat-icon {
  width: 48px; height: 48px; background: var(--green-light); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.chiba-chatbot-wrap .chat-header__title h1 { font-size: 22px; color: var(--text-main); margin: 0; }
.chiba-chatbot-wrap .chat-header__title p { font-size: 13px; color: var(--text-sub); margin: 2px 0 0; }
.chiba-chatbot-wrap .chat-header__notice {
  background: var(--green-light); padding: 12px 16px; border-radius: 8px;
  font-size: 12px; color: var(--text-main); max-width: 480px;
}

.chiba-chatbot-wrap .chat-messages {
  flex: 1; padding: 28px;
  display: flex; flex-direction: column; gap: 20px;
  background: var(--white); min-height: 400px;
}
.chiba-chatbot-wrap .msg { display: flex; gap: 10px; max-width: 80%; }
.chiba-chatbot-wrap .msg-user { align-self: flex-end; flex-direction: row-reverse; }
.chiba-chatbot-wrap .msg-bot { align-self: flex-start; }
.chiba-chatbot-wrap .msg-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--green-primary); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 18px; overflow: hidden;
}
.chiba-chatbot-wrap .msg-bot .msg-avatar { background: var(--white); border: 1.5px solid var(--green-light); }
.chiba-chatbot-wrap .msg-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.chiba-chatbot-wrap .msg-body { flex: 1; }
.chiba-chatbot-wrap .msg-bubble {
  padding: 14px 18px; border-radius: 16px; font-size: 14px; line-height: 1.7;
}
.chiba-chatbot-wrap .msg-user .msg-bubble {
  background: var(--green-primary); color: var(--white); border-bottom-right-radius: 4px;
}
.chiba-chatbot-wrap .msg-bot .msg-bubble {
  background: var(--green-light); color: var(--text-main); border-bottom-left-radius: 4px;
}
.chiba-chatbot-wrap .msg-time { font-size: 11px; color: var(--text-sub); margin-top: 4px; text-align: right; }
.chiba-chatbot-wrap .msg-bot .msg-time { text-align: left; }
.chiba-chatbot-wrap .msg-bubble .section-label {
  font-weight: 700; color: var(--green-dark); margin-top: 10px; display: block;
}
.chiba-chatbot-wrap .msg-bubble .section-label:first-child { margin-top: 0; }
.chiba-chatbot-wrap .msg-refs {
  margin-top: 10px; padding: 12px;
  background: var(--white); border: 1px solid var(--gray-border); border-radius: 8px;
}
.chiba-chatbot-wrap .msg-refs__title { font-weight: 600; font-size: 12px; margin-bottom: 6px; }
.chiba-chatbot-wrap .msg-refs__list { display: flex; flex-wrap: wrap; gap: 6px; }
.chiba-chatbot-wrap .msg-refs__item {
  background: var(--green-light); padding: 6px 10px; border-radius: 6px;
  font-size: 12px; color: var(--green-dark);
}

.chiba-chatbot-wrap .chat-input-area {
  padding: 18px 28px 24px; border-top: 1px solid var(--gray-border); background: var(--white);
}
.chiba-chatbot-wrap .chat-input-wrap {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--gray-border); border-radius: 12px;
  padding: 8px 12px; background: var(--white);
}
.chiba-chatbot-wrap .chat-input-wrap:focus-within { border-color: var(--green-primary); }
.chiba-chatbot-wrap #chatInput {
  flex: 1; border: none; outline: none; font-size: 14px; padding: 8px; background: transparent;
}
.chiba-chatbot-wrap .btn-example {
  background: var(--white); color: var(--green-dark);
  border: 1px solid var(--green-primary);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.chiba-chatbot-wrap .btn-send {
  background: var(--green-primary); color: var(--white); border: none;
  padding: 10px 22px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.chiba-chatbot-wrap .btn-send:hover { background: var(--green-dark); }
.chiba-chatbot-wrap .btn-send:disabled { background: #aaa; cursor: not-allowed; }
.chiba-chatbot-wrap .chat-disclaimer { text-align: center; font-size: 11px; color: var(--text-sub); margin-top: 12px; }

.chiba-chatbot-wrap .typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.chiba-chatbot-wrap .typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green-primary); animation: chiba-blink 1.2s infinite ease-in-out;
}
.chiba-chatbot-wrap .typing span:nth-child(2) { animation-delay: 0.2s; }
.chiba-chatbot-wrap .typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chiba-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* タブレット */
/* レスポンシブ: タブレット / スマホ */
@media (max-width: 900px) {
  .chiba-chatbot-wrap .chat-layout {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }
  .chiba-chatbot-wrap .chat-main { order: 1; }
  .chiba-chatbot-wrap .chat-sidebar {
    order: 2;
    border-right: none;
    border-top: 1px solid var(--gray-border);
    padding: 20px 16px;
  }
  .chiba-chatbot-wrap .chat-sidebar .sidebar-title,
  .chiba-chatbot-wrap .chat-sidebar .btn-new-chat {
    display: none;
  }
  .chiba-chatbot-wrap .sidebar-info {
    margin-top: 0;
  }
}
/* スマホ最適化 */
@media (max-width: 768px) {
  .chiba-chatbot-wrap { margin: 12px 0; border-radius: 8px; }
  .chiba-chatbot-wrap .chat-header {
    padding: 14px 16px; flex-direction: column; gap: 12px;
  }
  .chiba-chatbot-wrap .chat-header__title h1 { font-size: 17px; }
  .chiba-chatbot-wrap .chat-header__title p { font-size: 12px; }
  .chiba-chatbot-wrap .chat-icon { width: 40px; height: 40px; font-size: 20px; }
  .chiba-chatbot-wrap .chat-header__notice {
    font-size: 11px; padding: 10px 12px; max-width: 100%;
  }
  .chiba-chatbot-wrap .chat-messages {
    padding: 16px; gap: 14px; max-height: none;
  }
  .chiba-chatbot-wrap .msg { max-width: 92%; }
  .chiba-chatbot-wrap .msg-bubble { font-size: 14px; padding: 12px 14px; }

  /* 入力エリア: Gridで「入力欄が上(全幅)、ボタン2つが下に横並び」 */
  .chiba-chatbot-wrap .chat-input-area { padding: 12px 14px 16px; }
  .chiba-chatbot-wrap .chat-input-wrap {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 8px;
    padding: 10px;
  }
  .chiba-chatbot-wrap #chatInput {
    grid-column: 1 / -1;
    width: 100%;
    padding: 12px 10px;
    font-size: 16px;
    border: 1px solid var(--gray-border);
    border-radius: 8px;
  }
  .chiba-chatbot-wrap .chat-input-wrap .btn-example,
  .chiba-chatbot-wrap .chat-input-wrap .btn-send {
    writing-mode: horizontal-tb;
    white-space: nowrap;
    padding: 12px 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }
  .chiba-chatbot-wrap .chat-disclaimer { font-size: 10px; margin-top: 10px; }
}