/* ==========================================
   WeFi戦記 グローバルチャット スタイル
   ========================================== */

/* タブの未読バッジ */
.chat-tab-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 7px;
  background: #f39c12;
  color: #fff;
  font-size: 9px;
  font-weight: bold;
  line-height: 14px;
  text-align: center;
  display: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.chat-tab-badge.is-visible {
  display: block;
}

/* タブボタンの相対位置設定用（バッジのため） */
#tab-chat-btn {
  position: relative;
}

/* チャットパネル本体（画面全体に被せる） */
.chat-panel {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(26, 16, 8, 0.95) 0%, rgba(18, 12, 4, 0.98) 100%);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 901;
  border-radius: inherit;
}

.chat-panel.is-open {
  display: flex;
}

/* パネルヘッダー */
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 200, 100, 0.18);
  flex-shrink: 0;
}

.chat-header-title {
  flex: 1;
  font-size: 14px;
  font-weight: bold;
  color: rgba(255, 200, 100, 0.9);
  letter-spacing: 0.05em;
}

/* ニックネーム表示・変更ボタン */
.chat-nick-display {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  -webkit-tap-highlight-color: transparent;
}

.chat-nick-display:active {
  background: rgba(255, 255, 255, 0.12);
}

/* ==========================================
   ニックネーム入力画面
   ========================================== */
.chat-nick-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 14px;
}

.chat-nick-screen.is-hidden {
  display: none;
}

.chat-nick-title {
  font-size: 16px;
  font-weight: bold;
  color: rgba(255, 200, 100, 0.9);
  text-align: center;
}

.chat-nick-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  line-height: 1.6;
}

.chat-nick-input {
  width: 80%;
  max-width: 240px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 200, 100, 0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
  text-align: center;
}

.chat-nick-input:focus {
  border-color: rgba(255, 200, 100, 0.7);
}

.chat-nick-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.chat-nick-submit {
  width: 80%;
  max-width: 240px;
  padding: 12px;
  background: linear-gradient(135deg, #c0392b, #8e1010);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.chat-nick-submit:active {
  opacity: 0.8;
}

/* ==========================================
   メッセージエリア
   ========================================== */
.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.chat-messages-area.is-hidden {
  display: none;
}

/* スクロールバー */
.chat-messages-area::-webkit-scrollbar {
  width: 4px;
}

.chat-messages-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages-area::-webkit-scrollbar-thumb {
  background: rgba(255, 200, 100, 0.2);
  border-radius: 2px;
}

/* 個別メッセージ */
.chat-message {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: chatMsgIn 0.2s ease;
}

@keyframes chatMsgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 自分のメッセージ */
.chat-message.is-mine {
  align-items: flex-end;
}

.chat-message-meta {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 11px;
}

.chat-message.is-mine .chat-message-meta {
  flex-direction: row-reverse;
}

.chat-message-nick {
  color: rgba(255, 200, 100, 0.7);
  font-weight: bold;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message.is-mine .chat-message-nick {
  color: rgba(100, 200, 255, 0.7);
}

.chat-message-time {
  color: rgba(255, 255, 255, 0.25);
}

.chat-message-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.95);
  word-break: break-all;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.chat-message.is-mine .chat-message-bubble {
  background: rgba(100, 160, 255, 0.14);
  border-color: rgba(100, 160, 255, 0.2);
}

/* システムメッセージ */
.chat-message.is-system {
  align-items: center;
}

.chat-message.is-system .chat-message-bubble {
  background: transparent;
  border: none;
  color: rgba(255, 200, 100, 0.45);
  font-size: 12px;
  padding: 2px 0;
}

/* 空メッセージ */
.chat-empty-hint {
  text-align: center;
  color: rgba(255, 255, 255, 0.2);
  font-size: 13px;
  margin: auto;
  line-height: 1.8;
}

/* ==========================================
   メッセージ入力エリア
   ========================================== */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 200, 100, 0.12);
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.chat-input-area.is-hidden {
  display: none;
}

.chat-text-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.chat-text-input:focus {
  border-color: rgba(255, 200, 100, 0.5);
}

.chat-text-input::placeholder {
  color: rgba(255, 255, 255, 0.22);
}

.chat-send-btn {
  padding: 0 12px;
  background: linear-gradient(135deg, #c0392b, #8e1010);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.chat-send-btn:active {
  opacity: 0.8;
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ==========================================
   ニックネーム変更モーダル
   ========================================== */
.chat-nick-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.chat-nick-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.chat-nick-modal {
  width: 280px;
  background: linear-gradient(160deg, #1a1008, #120c04);
  border: 1px solid rgba(255, 200, 100, 0.3);
  border-radius: 14px;
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
  transform: scale(0.9);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-nick-modal-overlay.is-open .chat-nick-modal {
  transform: scale(1);
}

.chat-nick-modal-title {
  font-size: 14px;
  font-weight: bold;
  color: rgba(255, 200, 100, 0.9);
  text-align: center;
}

.chat-nick-modal-input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 200, 100, 0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  text-align: center;
  transition: border-color 0.15s;
}

.chat-nick-modal-input:focus {
  border-color: rgba(255, 200, 100, 0.7);
}

.chat-nick-modal-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.chat-nick-modal-btns {
  display: flex;
  gap: 8px;
}

.chat-nick-modal-cancel {
  flex: 1;
  padding: 9px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chat-nick-modal-ok {
  flex: 1;
  padding: 9px;
  background: linear-gradient(135deg, #c0392b, #8e1010);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================
   接続エラー表示
   ========================================== */
.chat-error-bar {
  padding: 6px 10px;
  background: rgba(192, 57, 43, 0.3);
  border-top: 1px solid rgba(192, 57, 43, 0.4);
  color: rgba(255, 150, 100, 0.9);
  font-size: 11px;
  text-align: center;
  display: none;
  flex-shrink: 0;
}

.chat-error-bar.is-visible {
  display: block;
}

/* ==========================================
   お知らせ・注意書き表示
   ========================================== */
.chat-intro-notice {
  background: rgba(216, 161, 60, 0.08);
  border: 1px solid rgba(216, 161, 60, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.chat-intro-notice-title {
  font-size: 12px;
  font-weight: bold;
  color: rgba(216, 161, 60, 0.95);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-intro-notice-body {
  font-size: 11px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.72);
}
