/* ==============================================
   釣り無線機能のスタイル
   ============================================== */

/* ページ全体のスタイル */
body.nearby-chat-page {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

body.nearby-chat-page .main-content {
  padding: 0;
  margin: 0;
  max-width: none;
  height: 100%;
}

/* コンテナ */
.nearby-chat-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh; /* フォールバック */
  height: 100dvh;
  max-height: 100dvh;
  background-color: #f5f5f5;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* ヘッダー */
.nearby-chat-header {
  flex-shrink: 0; /* 縮小しない */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  z-index: 10;
}

.nearby-chat-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #f5f5f5;
  color: #333;
  text-decoration: none;
  transition: background-color 0.2s;
}

.nearby-chat-back-btn:hover {
  background-color: #e0e0e0;
}

.nearby-chat-header-info {
  flex: 1;
}

.nearby-chat-header-info h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: #333;
}

.nearby-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #666;
}

.nearby-chat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #4caf50;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.nearby-chat-status-expired {
  color: #f44336;
}

.nearby-chat-header-icon {
  color: #1877f2;
}

/* メッセージエリア */
.nearby-chat-messages {
  flex: 1;
  min-height: 0; /* flexboxで縮小を許可 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* システムメッセージ */
.nearby-chat-system-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  margin: 8px 0;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-radius: 12px;
  text-align: center;
}

.nearby-chat-system-message-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #1877f2;
  border-radius: 50%;
  color: #fff;
}

.nearby-chat-system-message-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nearby-chat-system-message-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1565c0;
}

.nearby-chat-system-message-text {
  margin: 0;
  font-size: 14px;
  color: #1976d2;
  line-height: 1.5;
}

.nearby-chat-system-message-warning {
  margin: 0;
  font-size: 13px;
  color: #c62828;
  font-weight: 500;
}

.nearby-chat-system-message-dismiss {
  padding: 8px 24px;
  background-color: #1877f2;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.nearby-chat-system-message-dismiss:hover {
  background-color: #166fe5;
}

/* 空状態 */
.nearby-chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  text-align: center;
  padding: 32px;
}

.nearby-chat-empty svg {
  margin-bottom: 16px;
  color: #ccc;
}

.nearby-chat-empty p {
  font-size: 16px;
  margin: 0 0 8px 0;
  color: #666;
}

.nearby-chat-empty span {
  font-size: 14px;
}

/* メッセージ */
.nearby-chat-message {
  display: flex;
  gap: 8px;
  max-width: 80%;
}

.nearby-chat-message.own {
  flex-direction: row-reverse;
  margin-left: auto;
}

/* アバター */
a.nearby-chat-message-avatar {
  display: block;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  text-decoration: none;
  transition: opacity 0.2s;
}

a.nearby-chat-message-avatar:hover {
  opacity: 0.8;
}

.nearby-chat-message-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.nearby-chat-message-avatar-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #1877f2;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

/* メッセージコンテンツ */
.nearby-chat-message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nearby-chat-message.own .nearby-chat-message-content {
  align-items: flex-end;
}

/* メッセージヘッダー */
.nearby-chat-message-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 12px;
}

.nearby-chat-message-name {
  font-size: 12px;
  font-weight: 500;
  color: #666;
  text-decoration: none;
  transition: color 0.2s;
}

.nearby-chat-message-name:hover {
  color: #1877f2;
  text-decoration: underline;
}

/* 電波強度アイコン */
.nearby-chat-message-signal {
  display: flex;
  align-items: center;
}

.signal-icon {
  display: block;
}

.signal-bar {
  fill: #e0e0e0;
  transition: fill 0.2s;
}

.signal-bar.active {
  fill: #4caf50;
}

.signal-bar.inactive {
  fill: #e0e0e0;
}

/* 電波強度レベルに応じた色分け */
[data-signal-strength-level-value="1"] .signal-bar.active {
  fill: #f44336; /* 赤（遠い） */
}

[data-signal-strength-level-value="2"] .signal-bar.active {
  fill: #ff9800; /* オレンジ（中間） */
}

[data-signal-strength-level-value="3"] .signal-bar.active {
  fill: #4caf50; /* 緑（近い） */
}

/* メッセージバブル */
.nearby-chat-message-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  background-color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.nearby-chat-message.own .nearby-chat-message-bubble {
  background-color: #1877f2;
  color: #fff;
}

.nearby-chat-message-bubble p {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
}

/* 課金ユーザーの魚アニメーション */
.nearby-chat-message-bubble.premium {
  position: relative;
  overflow: hidden;
}

.premium-fish-animation {
  position: absolute;
  top: 50%;
  left: -30px;
  transform: translateY(-50%);
  opacity: 0;
  color: rgba(24, 119, 242, 0.2);
  pointer-events: none;
  z-index: 0;
}

/* ベーシックプラン: 青色 */
.premium-basic .premium-fish-animation {
  color: rgba(24, 119, 242, 0.25);
}

/* プロプラン: 金色 */
.premium-pro .premium-fish-animation {
  color: rgba(218, 165, 32, 0.35);
}

/* 自分のメッセージ（青背景用） */
.nearby-chat-message.own .premium-basic .premium-fish-animation {
  color: rgba(255, 255, 255, 0.3);
}

.nearby-chat-message.own .premium-pro .premium-fish-animation {
  color: rgba(255, 215, 0, 0.35);
}

.premium-fish-animation.swimming {
  animation: premium-fish-swim 2.5s ease-in-out forwards;
}

@keyframes premium-fish-swim {
  0% {
    left: -30px;
    opacity: 0;
    transform: translateY(-50%) scaleX(1);
  }
  10% {
    opacity: 1;
  }
  50% {
    transform: translateY(-50%) scaleX(1) translateY(-3px);
  }
  90% {
    opacity: 1;
  }
  100% {
    left: calc(100% + 30px);
    opacity: 0;
    transform: translateY(-50%) scaleX(1);
  }
}

.nearby-chat-message-bubble.premium p {
  position: relative;
  z-index: 1;
}

/* 送信時刻 */
.nearby-chat-message-time {
  font-size: 11px;
  color: #999;
  padding: 0 12px;
}

/* 入力エリア */
.nearby-chat-input-area {
  flex-shrink: 0; /* 縮小しない */
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background-color: #fff;
  border-top: 1px solid #e0e0e0;
}

.nearby-chat-input-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nearby-chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.nearby-chat-input:focus {
  border-color: #1877f2;
}

.nearby-chat-input:disabled {
  background-color: #f5f5f5;
  color: #999;
}

.nearby-chat-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background-color: #1877f2;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, opacity 0.2s;
}

.nearby-chat-send-btn:hover:not(:disabled) {
  background-color: #166fe5;
}

.nearby-chat-send-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.nearby-chat-input-hint {
  font-size: 11px;
  color: #999;
  text-align: right;
  margin-top: 4px;
  padding-right: 56px;
}

/* レスポンシブ */
@media (max-width: 480px) {
  .nearby-chat-message {
    max-width: 85%;
  }

  .nearby-chat-header {
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }

  .nearby-chat-messages {
    padding: 12px;
    gap: 12px;
  }

  .nearby-chat-input-area {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

/* キーボード表示時のレイアウト維持 */
@supports (height: 100dvh) {
  .nearby-chat-container {
    height: 100dvh;
  }
}

/* チェックイン詳細画面の通信ボタン */
.check-in-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  margin-top: 16px;
  border: none;
  border-radius: 8px;
  background-color: #1877f2;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s;
}

.check-in-chat-btn:hover {
  background-color: #166fe5;
  color: #fff;
}

.check-in-chat-btn svg {
  flex-shrink: 0;
}

.check-in-chat-btn-disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.check-in-chat-btn-disabled:hover {
  background-color: #ccc;
}

/* 釣果通知メッセージ */
.nearby-chat-notification {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border-radius: 12px;
  margin: 8px 16px;
}

/* 非表示になった釣果通知 */
.nearby-chat-notification-hidden {
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

.nearby-chat-notification-icon-hidden {
  background-color: #9e9e9e;
}

.nearby-chat-notification-text-hidden {
  color: #757575;
  font-style: italic;
}

.nearby-chat-notification-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #4caf50;
  border-radius: 50%;
  color: #fff;
}

/* 釣果通知のアバター */
a.nearby-chat-notification-avatar {
  display: block;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  text-decoration: none;
  transition: opacity 0.2s;
}

a.nearby-chat-notification-avatar:hover {
  opacity: 0.8;
}

.nearby-chat-notification-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.nearby-chat-notification-content {
  flex: 1;
  min-width: 0;
}

.nearby-chat-notification-text {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 500;
  color: #2e7d32;
}

.nearby-chat-notification-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background-color: #fff;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.2s, transform 0.2s;
}

.nearby-chat-notification-card:hover {
  background-color: #f5f5f5;
  transform: translateX(2px);
}

.nearby-chat-notification-image {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
}

.nearby-chat-notification-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nearby-chat-notification-info {
  flex: 1;
  min-width: 0;
}

.nearby-chat-notification-fish {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nearby-chat-notification-size {
  display: block;
  font-size: 12px;
  color: #666;
}

.nearby-chat-notification-comment {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  color: #555;
  margin-top: 4px;
  line-height: 1.3;
}

.nearby-chat-notification-arrow {
  flex-shrink: 0;
  color: #999;
}

.nearby-chat-notification-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.nearby-chat-notification-time {
  font-size: 11px;
  color: #66bb6a;
}

/* 返信ボタン */
.nearby-chat-reply-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: none;
  border: 1px solid #4caf50;
  border-radius: 14px;
  color: #4caf50;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.nearby-chat-reply-btn:hover {
  background-color: #4caf50;
  color: #fff;
}

/* 返信インジケーター（メッセージ内） */
.nearby-chat-reply-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  background-color: #e8f5e9;
  border-radius: 8px;
  font-size: 11px;
  color: #2e7d32;
}

.nearby-chat-reply-indicator svg {
  flex-shrink: 0;
}

/* 入力エリアの返信インジケーター */
.nearby-chat-replying-to {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background-color: #e8f5e9;
  border-radius: 8px;
  font-size: 13px;
  color: #2e7d32;
}

.nearby-chat-replying-to svg {
  flex-shrink: 0;
}

.nearby-chat-replying-to span {
  flex: 1;
}

.nearby-chat-cancel-reply {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 50%;
  color: #666;
  cursor: pointer;
  transition: background-color 0.2s;
}

.nearby-chat-cancel-reply:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

@media (max-width: 480px) {
  .nearby-chat-notification {
    margin: 6px 12px;
    padding: 10px;
  }

  .nearby-chat-notification-image {
    width: 64px;
    height: 64px;
  }
}
