/* Discord Chat UI */

/* タイピングインジケータ */
.dc-typing-indicator {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 12px 4px;
}

.dc-typing-indicator[hidden] {
  display: none;
}

.dc-typing-indicator span:not(.dc-typing-label) {
  width: 6px;
  height: 6px;
  background: #6b7280;
  border-radius: 50%;
  animation: dc-typing-bounce 1.2s infinite ease-in-out;
  flex-shrink: 0;
}

.dc-typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.dc-typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

.dc-typing-label {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-left: 4px;
}

@keyframes dc-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.discord-chat-section {
  max-width: 800px;
  margin: 2em auto;
  padding: 0 1em;
}

.discord-chat-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
}

.discord-chat-subtitle {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1.2em;
}

/* チャットウィンドウ */
.discord-chat-window {
  background: var(--bg-card);
  border-radius: 12px;
  height: 480px;
  overflow-y: auto;
  padding: 16px;
  margin-bottom: 12px;
  scroll-behavior: smooth;
  border: 1px solid rgba(245,184,0,0.18);
}

@media (max-width: 640px) {
  .discord-chat-window {
    height: 360px;
  }
}

/* ローディング */
.discord-chat-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-light);
  font-size: 0.9rem;
  justify-content: center;
  padding: 2em 0;
}

.discord-chat-dots {
  display: inline-flex;
  gap: 4px;
}

.discord-chat-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f5b800;
  animation: dc-bounce 1.2s infinite;
}

.discord-chat-dots span:nth-child(2) { animation-delay: 0.2s; }
.discord-chat-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dc-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* メッセージ一覧 */
.discord-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 個別メッセージ */
.dc-msg {
  max-width: 80%;
  word-break: break-word;
  position: relative;
}

/* Discordからのメッセージ（左） */
.dc-msg--discord {
  align-self: flex-start;
}

/* 自分のメッセージ（右） */
.dc-msg--own {
  align-self: flex-end;
}

/* AI / コーチ バッジ（バブルの上に右寄せで表示） */
.dc-mode-badge {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0 2px;
  margin-bottom: 3px;
  white-space: nowrap;
}
.dc-mode-badge--ai {
  color: #7cb6ff;
}
.dc-mode-badge--coach {
  color: #c084fc;
}

/* AIモード送信バブル */
.dc-msg--own-ai .dc-msg-body {
  background: var(--bg-card-hi);
  border: 1px solid rgba(96,165,250,0.25);
}
/* コーチモード送信バブル */
.dc-msg--own-coach .dc-msg-body {
  background: var(--bg-card-hi);
  border: 1px solid rgba(192,132,252,0.25);
}

.dc-msg-author {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 2px;
  padding: 0 4px;
}

.dc-msg--coach .dc-msg-author {
  color: #a855f7;
}

.dc-msg-body {
  display: inline-block;
  font-size: 0.92rem;
  color: var(--text-main);
  line-height: 1.5;
  background: var(--bg-card-hi);
  border-radius: 12px;
  padding: 8px 12px;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  word-break: break-word;
  border: 1px solid rgba(255,255,255,0.06);
}

.dc-msg--own .dc-msg-body {
  background: var(--bg-card-hi);
  border: 1px solid rgba(245,184,0,0.4);
}

.dc-msg-body strong {
  font-weight: 700;
  color: var(--text-main);
}

.dc-msg-body em {
  font-style: italic;
  color: var(--text-main);
}

.dc-msg-body code {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-main);
}

.dc-msg-time {
  font-size: 0.62rem;
  color: rgba(156, 163, 175, 0.6);
  margin-left: 6px;
  vertical-align: bottom;
  white-space: nowrap;
}

/* フォームエリア */
.discord-chat-form-wrap {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(245,184,0,0.18);
}

.discord-chat-user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.discord-chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f5b800;
  color: #06070a;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.discord-chat-username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.discord-chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.discord-chat-input {
  flex: 1;
  background: var(--bg-white);
  border: 1px solid rgba(245,184,0,0.2);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 16px; /* iOS auto-zoom防止（16px未満だとタップ時にズームされる） */
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  overflow-y: hidden;
  max-height: 120px;
  overflow-y: auto;
}

.discord-chat-input:focus {
  border-color: #f5b800;
  box-shadow: 0 0 0 2px rgba(245,184,0,0.25);
}

.discord-chat-input::placeholder {
  color: var(--text-light);
}

.discord-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #f5b800;
  color: #06070a;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.discord-chat-send-btn:hover {
  background: #ffd54a;
}

.discord-chat-send-btn:disabled {
  background: #374151;
  cursor: not-allowed;
}

/* モード別入力欄カラー */
.discord-chat-input.dc-input--ai {
  border-color: rgba(96,165,250,0.5);
}

.discord-chat-input.dc-input--ai:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96,165,250,0.25);
}

.discord-chat-input.dc-input--coach {
  border-color: rgba(192,132,252,0.5);
}

.discord-chat-input.dc-input--coach:focus {
  border-color: #c084fc;
  box-shadow: 0 0 0 2px rgba(192,132,252,0.25);
}

/* ---- フローティングチャットウィジェット ---- */

/* バックドロップ（スマホのみ表示） */
.discord-float-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-fade);
  z-index: 9998;
}

.discord-float-backdrop.is-open {
  display: block;
}

/* ボタンのコンテナ（固定位置） */
.discord-float-chat {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 16px;
  z-index: 9999;
}

/* 開閉ボタン */
.discord-float-btn {
  background: #f5b800;
  color: #06070a;
  border: none;
  border-radius: 28px;
  padding: 12px 18px 12px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(245,184,0,0.45);
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.discord-float-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(245,184,0,0.6);
}

.discord-float-btn:active {
  transform: scale(0.97);
}

/* チャットパネル（PC: コーナーポップアップ） */
.discord-float-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-card);
  border-radius: 0;
  border: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform-origin: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease;
}

.discord-float-panel[aria-hidden="true"] {
  transform: scale(0.92) translateY(8px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.discord-float-panel[aria-hidden="false"] {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* ヘッダー */
.discord-float-header {
  background: linear-gradient(135deg, var(--bg-card-hi) 0%, var(--bg-card) 100%);
  border-bottom: 1px solid rgba(245,184,0,0.35);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.discord-float-header-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f5b800;
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.dc-float-user {
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.dc-float-sep {
  opacity: 0.5;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.discord-float-close {
  background: rgba(245,184,0,0.12);
  border: 1px solid rgba(245,184,0,0.25);
  color: #f5b800;
  font-size: 1rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.discord-float-close:hover,
.discord-float-close:active {
  background: rgba(245,184,0,0.25);
}

/* チャットウィンドウ */
.discord-float-window {
  flex: 1;
  height: auto;
  min-height: 0;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid rgba(245,184,0,0.18);
}

/* フォームエリア */
.discord-float-form-wrap {
  border-radius: 0;
  border: none;
  padding: 10px 12px;
}

/* デスクトップ: フローティングボタン本体のみ非表示（パネルはボトムナビの質問するから開く） */
@media (min-width: 641px) {
  .discord-float-btn {
    display: none !important;
  }
}

/* スマホ: ボトムシートスタイル */
@media (max-width: 640px) {
  /* フローティングボタンはボトムナビのDiscordタブで代替 */
  .discord-float-btn {
    display: none !important;
  }

  .discord-float-chat {
    bottom: calc(56px + env(safe-area-inset-bottom));
    right: 12px;
  }

  .discord-float-panel {
    /* モバイルでも全画面表示 */
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    transform-origin: center;
    max-height: none;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .discord-float-window {
    flex: 1;
    height: auto;
    min-height: 200px;
  }
}

/* リプライ引用ブロック */
.dc-reply-quote {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 8px;
  margin-bottom: 4px;
  border-left: 3px solid #f5b800;
  background: rgba(245,184,0,0.08);
  border-radius: 0 4px 4px 0;
  font-size: 0.82em;
  color: var(--text-light);
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}
.dc-reply-author {
  color: #f5b800;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
}
.dc-reply-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* 受信画像 */
.dc-msg-img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  margin-top: 6px;
  display: block;
  cursor: pointer;
}

/* 📎 ファイルボタン */
.discord-chat-file-btn {
  width: 40px;
  height: 40px;
  background: #383a40;
  border: 1px solid #4b4f57;
  border-radius: 8px;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.discord-chat-file-btn:hover {
  color: var(--text-main);
  border-color: var(--text-light);
}

/* 画像プレビュー */
.discord-chat-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 2px;
}

.discord-chat-preview[hidden] {
  display: none;
}

.discord-chat-preview img {
  height: 48px;
  width: 48px;
  object-fit: cover;
  border-radius: 6px;
}

.discord-chat-preview-remove {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  line-height: 1;
}

.discord-chat-preview-remove:hover {
  color: var(--text-main);
}

/* スクロールバー */
.discord-chat-window::-webkit-scrollbar {
  width: 6px;
}

.discord-chat-window::-webkit-scrollbar-track {
  background: var(--bg-card-hi);
}

.discord-chat-window::-webkit-scrollbar-thumb {
  background: rgba(245,184,0,0.3);
  border-radius: 3px;
}

/* ---- AI / コーチ モードトグル ---- */
.dc-mode-toggle {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
}

.dc-mode-btn {
  background: transparent;
  border: 1px solid rgba(245,184,0,0.2);
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 0;
  width: 42px;
  text-align: center;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.4;
}

.dc-mode-btn:hover {
  color: var(--text-main);
}

.dc-mode-btn--active[data-mode="ai"] {
  background: rgba(96,165,250,0.15);
  color: #7cb6ff;
  border-color: rgba(96,165,250,0.4);
}

.dc-mode-btn--active[data-mode="coach"] {
  background: rgba(192,132,252,0.15);
  color: #c084fc;
  border-color: rgba(192,132,252,0.4);
}

.dc-mode-suffix {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---- スワイプ返信アイコン ---- */
.dc-swipe-icon {
  position: absolute;
  right: -30px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f5b800;
  background: rgba(245,184,0,0.15);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

/* ---- リプライインジケータバー ---- */
.discord-reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(245,184,0,0.08);
  border-left: 3px solid #f5b800;
  font-size: 0.8em;
}
.discord-reply-bar[hidden] {
  display: none;
}
.discord-reply-bar-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
#discord-reply-bar-author {
  color: #f5b800;
  font-weight: 700;
  font-size: 0.9em;
}
#discord-reply-bar-content {
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#discord-reply-bar-cancel {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 1.1em;
  padding: 0 4px;
  flex-shrink: 0;
}
