/* ============================================
   モバイルメニュー
   ============================================ */

/* ==========================================
   オーバーレイ
   ========================================== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.overlay.active {
  display: block;
  opacity: 1;
}

[data-theme="dark"] .overlay {
  background: rgba(0, 0, 0, 0.7);
}

/* ==========================================
   モバイルメニュー本体
   ========================================== */
.mobile-menu {
  position: fixed;
  top: 0;
  left: -100%;
  width: 280px;
  height: 100vh;
  height: 100dvh;
  background: var(--color-bg-secondary);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: left 0.3s;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.mobile-menu.active {
  left: 0;
}

/* iOS Safari 対応 */
@supports (-webkit-touch-callout: none) {
  .mobile-menu {
    height: -webkit-fill-available;
  }
}

/* ==========================================
   モバイルメニューヘッダー
   ========================================== */
.mobile-menu-header {
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.mobile-menu-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  padding-left: 10px;
}

.mobile-menu-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--color-text-secondary);
  border: none;
  background: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
  margin-right: -4px;
}

.mobile-menu-close:hover {
  background: var(--color-bg-hover);
}

/* ==========================================
   モバイルメニューコンテンツ
   ========================================== */
.mobile-menu-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ==========================================
   新規作成ボタン（掲示板・ナレッジ・議事録用）
   ========================================== */
.mobile-new-action {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.mobile-new-action-btn {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  color: var(--color-text-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  transition: all 0.2s;
  text-align: left;
}

.mobile-new-action-btn:active {
  background: var(--color-bg-hover);
}

/* ==========================================
   チャット専用：新規チャットボタン
   ========================================== */
.mobile-new-chat {
  padding: 8px 16px 4px 16px;
  flex-shrink: 0;
}

.mobile-new-chat-btn {
  width: 100%;
  padding: 8px 12px;
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-fast);
  text-align: center;
}

.mobile-new-chat-btn:active {
  background: var(--color-bg-secondary);
}

/* ==========================================
   チャット専用：検索ボックス
   ========================================== */
.mobile-menu-search {
  padding: 12px 16px 8px 16px;
  flex-shrink: 0;
}

.mobile-menu-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
  background: var(--color-bg-input);
}

.mobile-menu-search input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mobile-menu-search input::placeholder {
  color: var(--color-text-muted);
}

/* ==========================================
   チャット専用：履歴一覧
   ========================================== */
.mobile-history {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 16px;
  min-height: 0;
}

.mobile-history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 履歴アイテム */
.chat-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
  margin-bottom: 2px;
}

/* ❌ 変更前 */
.chat-history-item:hover {
  background: rgba(59, 130, 246, 0.15);
  border-left-color: rgba(59, 130, 246, 0.3);
}

.chat-history-item.active {
  background: rgba(59, 130, 246, 0.15);
  border-left-color: var(--color-info);
}

.chat-history-item:hover {
  background: rgba(48, 48, 48, 0.1);
  border-left-color: rgba(48, 48, 48, 0.3);
}

.chat-history-item.active {
  background: rgba(48, 48, 48, 0.1);
  border-left-color: #303030;
}

[data-theme="dark"] .chat-history-item:hover {
  background: rgba(48, 48, 48, 0.6);
  border-left-color: rgba(48, 48, 48, 0.8);
}

[data-theme="dark"] .chat-history-item.active {
  background: rgba(48, 48, 48, 0.6);
  border-left-color: #303030;
}

.chat-history-content {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.chat-history-title {
  font-size: var(--font-size-sm);
  line-height: 1.3;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 3px;
}

.chat-history-date {
  font-size: var(--font-size-xs);
  line-height: 1.2;
  color: var(--color-text-muted);
}

/* ==========================================
   モバイルナビゲーション
   ========================================== */
.mobile-nav-section {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.mobile-nav-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  font-size: 15px;
  transition: background 0.2s;
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.mobile-nav-item:hover {
  background: var(--color-bg-hover);
}

.mobile-nav-item.active {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.mobile-nav-item:not(.active) {
  background: none !important;
}

.mobile-nav-item.hidden {
  display: none !important;
}

.mobile-nav-divider {
  height: 1px;
  background: var(--color-border);
  margin: 8px 0;
}

/* テーマ切り替えボタン */
.mobile-nav-item[data-theme-btn] {
  position: relative;
  padding-left: 40px;
}

.mobile-nav-item[data-theme-btn]::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.mobile-nav-item[data-theme-btn="dark"]::before {
  background: #1e293b;
  border: 2px solid #475569;
}

.mobile-nav-item[data-theme-btn="light"]::before {
  background: #ffffff;
  border: 2px solid var(--color-border);
}

.mobile-nav-item[data-theme-btn].active {
  font-weight: var(--font-weight-semibold);
}

.mobile-nav-item[data-theme-btn].active::after {
  content: '✓';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-primary);
}

/* ==========================================
   モバイルメニューフッター
   ========================================== */
.mobile-menu-footer {
  border-top: 1px solid var(--color-border);
  padding: 12px 16px;
  flex-shrink: 0;
  background: var(--color-bg-secondary);
  min-height: 60px;
  overflow-y: auto;
  max-height: 50vh;
}

.mobile-user-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.mobile-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-user-icon {
  font-size: 18px;
  color: var(--color-text-secondary);
}

.mobile-user-name {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
}

.mobile-user-arrow {
  font-size: 12px;
  color: var(--color-text-secondary);
  transition: transform 0.2s;
}

.mobile-user-button.active .mobile-user-arrow {
  transform: rotate(180deg);
}

.mobile-user-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.mobile-user-menu.active {
  max-height: 500px;
}

.mobile-nav-list {
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-nav-list .mobile-nav-item {
  padding: 12px 16px;
  font-size: var(--font-size-sm);
}

.mobile-nav-list .mobile-nav-item[data-theme-btn] {
  padding-left: 40px;
}

.mobile-nav-list .mobile-nav-item.danger {
  color: var(--color-error);
}

.mobile-nav-list .mobile-nav-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ==========================================
   PC版では非表示
   ========================================== */
@media (min-width: 768px) {

  .mobile-menu,
  .overlay {
    display: none;
  }

  .mobile-only {
    display: none;
  }
}