﻿/* リセットCSS */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Noto Sans JP","Hiragino Sans","Hiragino Kaku Gothic ProN","BIZ UDPGothic",Meiryo,sans-serif
    Roboto, "Noto Sans JP","Hiragino Sans","Hiragino Kaku Gothic ProN","BIZ UDPGothic",Meiryo,"Noto Sans JP","Hiragino Sans","Hiragino Kaku Gothic ProN","BIZ UDPGothic",Meiryo,sans-serif;
  background-color: #f3f3f5;
}

/* ヘッダー */
.header {
  background-color: #2c3e50;
  color: white;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 60px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
  line-height: 1;
}

.menu-toggle:hover {
  background-color: #34495e;
}

.logo {
  font-size: 18px;
  font-weight: 500;
}

/* ドロップダウン */
.dropdown {
  position: relative;
}

.dropdown-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.2s;
  font-size: 14px;
}

.dropdown-btn:hover {
  background-color: #34495e;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background-color: white;
  min-width: 180px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  overflow: hidden;
  z-index: 1001;
}

.dropdown:hover .dropdown-content,
.dropdown.active .dropdown-content {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  text-decoration: none;
  color: #333;
  transition: background-color 0.2s;
}

.dropdown-item:hover {
  background-color: #f1f1f1;
}

/* ============ サイドバー（デスクトップ常時表示 / スマホはハンバーガー） ============ */
.mypage-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100%;
  background: #2c3e50;
  z-index: 9000;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.mypage-sidebar.active {
  transform: translateX(0);
}

.mypage-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #1a252f;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  height: 60px;
}

.sidebar-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
  line-height: 1;
}

.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mypage-sidebar nav a {
  display: block;
  padding: 14px 20px;
  color: #ecf0f1;
  text-decoration: none;
  font-size: 15px;
  transition: background-color 0.2s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mypage-sidebar nav a:hover {
  background-color: #34495e;
}

.mypage-sidebar nav a.active {
  background-color: #34495e;
  border-right: 4px solid #06c755;
}

.mypage-sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 8999;
}

.mypage-sidebar-overlay.active {
  display: block;
}

/* ============ デスクトップ：サイドバー常時表示 ============ */
@media (min-width: 768px) {
  .mypage-sidebar {
    transform: translateX(0) !important; /* 常に表示 */
    z-index: 100;
  }

  .mypage-sidebar-header .sidebar-close-btn {
    display: none; /* デスクトップでは✕ボタン不要 */
  }

  .menu-toggle {
    display: none; /* デスクトップではハンバーガー不要 */
  }

  .mypage-sidebar-overlay {
    display: none !important; /* オーバーレイ不要 */
  }

  .main-content {
    margin-left: 240px; /* サイドバー幅分だけ右へ */
  }
}

/* メインコンテンツ */
.main-content {
  margin-top: 60px;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.chat-header {
  background-color: white;
  border-bottom: 1px solid #e5e5e7;
  padding: 20px;
  padding-bottom: 5px;
}

.chat-header h2 {
  color: #333;
  font-size: 18px;
  font-weight: 500;
  border-left: 4px solid #db3487;
  padding-left: 12px;
}

/* チャットエリア */
.chat-area {
  background: linear-gradient(to bottom, #7494c0, #6684b0);
}

.chat-messages {
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* メッセージコンテナ */
.message-container {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  max-width: 80%;
}

.message-container.user-message {
  flex-direction: row-reverse;
  margin-left: auto;
  margin-right: 6px;
}

.message-container.admin-message {
  flex-direction: row;
  margin-right: auto;
}

.message-avatar {
  transform: translateY(-12px);
  flex-shrink: 0;
}

.message-avatar img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-message .message-content {
  align-items: flex-end;
}

.admin-message .message-content {
  align-items: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 20px;
  word-wrap: break-word;
  max-width: 100%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: visible;
}

/* 吹き出し尻尾 */
.admin-bubble::before { color: rgba(255,255,255,0.95); }
.user-bubble::before  { color: rgba(255,255,255,0.95); }

.admin-bubble::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 0;
  border-style: solid;
  border-width: 0 16px 14px 0;
  border-color: transparent white transparent transparent;
  translate: -100% calc(-50% - 0.6px);
  transform: skew(0, 20deg);
  transform-origin: right;
}

.user-bubble::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 0;
  border-style: solid;
  border-width: 0 0 16px 14px;
  border-color: transparent transparent transparent #06c755;
  translate: 100% calc(-50% - 0.6px);
  transform: skew(0, -20deg);
  transform-origin: left;
}

.user-bubble {
  background-color: #06c755;
  color: white;
  border-top-right-radius: 8px;
}

.admin-bubble {
  background-color: white;
  color: #333;
  border-top-left-radius: 8px;
}

.message-bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.message-bubble a {
  word-break: break-all;
  text-decoration: underline;
  color: inherit;
}

.message-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
  padding: 0 4px;
}

.message-file {
  margin-top: 8px;
}

.message-file img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  object-fit: cover;
}

.message-file a {
  color: inherit;
  text-decoration: underline;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* メッセージ入力エリア */
.message-input-area {
  background-color: white;
  border-top: 1px solid #e5e5e7;
  padding: 16px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.selected-file-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #f8f9fa;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.selected-file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #666;
  font-size: 14px;
}

.clear-file-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 18px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.clear-file-btn:hover {
  background-color: #e9ecef;
  color: #666;
}

.input-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#messageInput {
  border: 1px solid #d1d5db;
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  min-height: 60px;
  max-height: 120px;
}

#messageInput:focus {
  border-color: #06c755;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-count {
  font-size: 12px;
  color: #666;
  padding-left: 8px;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.file-btn,
.send-btn {
  border: none;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  width: 40px;
  height: 40px;
}

.file-btn {
  background-color: transparent;
  color: #666;
}

.file-btn:hover {
  background-color: #f1f1f1;
  color: #333;
}

.send-btn {
  background-color: #06c755;
  color: white;
}

.send-btn:hover:not(:disabled) {
  background-color: #05b04a;
}

.send-btn:disabled {
  background-color: #d1d5db;
  cursor: not-allowed;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
  .header {
    padding: 8px 12px;
    height: 56px;
  }

  .main-content {
    margin-top: 56px;
    height: calc(100vh - 56px);
  }

  .chat-messages {
    padding: 16px;
    gap: 16px;
  }

  .message-container {
    max-width: 85%;
  }

  .message-avatar img {
    width: 40px;
    height: 40px;
  }

  .message-input-area {
    padding: 12px;
  }

  #messageInput {
    font-size: 16px;
  }
}

/* スクロールバーのスタイリング */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* 未読バッジ */
.unread-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 9999px;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}

/* プレビュー共通 */
.file-preview {
  display: block;
  border-radius: 8px;
  margin-top: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  max-width: 100%;
}

.image-preview {
  max-width: 240px;
  max-height: 180px;
  object-fit: cover;
}

.pdf-preview {
  width: 260px;
  height: 180px;
  background: #fff;
  border: 1px solid #e5e5e7;
}

.video-preview { width: 260px; max-height: 200px; }
.audio-preview { width: 260px; }

.message-file .file-fallback a,
.message-file .file-generic {
  text-decoration: underline;
  font-size: 13px;
  display: inline-flex;
  margin-top: 6px;
  color: inherit;
}

.user-name {
  font-size: 10px;
  color: white;
}

.dropdown-user-info .user-name {
  color: black;
}

/* ヘッダーユーザーアイコン */
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.6);
  display: block;
}

/* ドロップダウン内の小アイコン */
.user-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #3498db;
  flex-shrink: 0;
}

/* ドロップダウンのユーザー情報行 */
.dropdown-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}
