/* =============================================
   AI Navigator - スタイルシート v2
   3パネルレイアウト（サイドバー + 3カラムグリッド）
   ============================================= */

:root {
  --bg-primary: #0d1117;
  --bg-surface: #161b22;
  --bg-card: #1a1b2e;
  --bg-card-hover: #21223a;
  --bg-sidebar: #0d1117;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-subtle: rgba(59, 130, 246, 0.12);
  --pick-must: #ef4444;
  --pick-must-bg: rgba(239, 68, 68, 0.12);
  --pick-check: #f59e0b;
  --pick-check-bg: rgba(245, 158, 11, 0.12);
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --border: rgba(255,255,255,0.08);
  --border-accent: rgba(59, 130, 246, 0.4);
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 58px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; list-style: none; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* =============================================
   ヘッダー: ロゴ | タブ | 検索
   ============================================= */

#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}

/* ロゴ */
#logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
}

#logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

#logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

/* タブナビゲーション */
#tabbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 16px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* 検索 */
#search-wrapper {
  position: relative;
  flex-shrink: 0;
}

#search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

#search-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px 8px 36px;
  color: var(--text-primary);
  font-size: 13px;
  width: 220px;
  transition: width 0.2s, border-color 0.2s;
  outline: none;
}

#search-input:focus {
  width: 280px;
  border-color: var(--border-accent);
}

#search-input::placeholder { color: var(--text-muted); }

/* モバイルトグル（デスクトップでは非表示） */
#sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

/* =============================================
   アプリレイアウト
   ============================================= */

#app-layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* =============================================
   サイドバー
   ============================================= */

#sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: none;
  z-index: 100;
}

#sidebar::-webkit-scrollbar { display: none; }

.sidebar-section {
  padding: 8px 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* サイドバーフィルターアイテム */
.sidebar-item {
  display: block;
  padding: 8px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
  border-left: 3px solid transparent;
  user-select: none;
}

.sidebar-item:hover {
  color: var(--text-primary);
  background: var(--accent-subtle);
}

.sidebar-item.active {
  color: var(--accent-hover);
  background: var(--accent-subtle);
  border-left-color: var(--accent);
}

/* =============================================
   メインコンテンツ
   ============================================= */

#main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  padding-bottom: 80px;
}

/* 統計バー */
#stats-bar {
  padding: 10px 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

/* =============================================
   日付グループ + カードグリッド
   ============================================= */

.date-group {
  padding: 0 16px;
  margin-top: 20px;
}

.date-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
}

.date-label { color: var(--text-secondary); }

.date-count {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* 3カラムグリッド */
.article-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* =============================================
   記事カード
   ============================================= */

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  display: block;
  color: inherit;
}

.article-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.pick-badge {
  flex-shrink: 0;
  font-size: 13px;
  margin-top: 2px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text-primary);
  flex: 1;
}

/* メタ情報行（バッジ類） */
.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* バッジ統一スタイル（塗りつぶし） */
.card-badge {
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius-sm);
  padding: 2px 9px;
  white-space: nowrap;
}

.card-badge.badge-source {
  background: #2d6a4f; /* ソース系は緑系 */
}

.card-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* PICK スタイル */
.article-card.pick-must {
  border-left: 3px solid var(--pick-must);
  background: linear-gradient(135deg, var(--pick-must-bg) 0%, var(--bg-card) 60%);
}

.article-card.pick-check {
  border-left: 3px solid var(--pick-check);
  background: linear-gradient(135deg, var(--pick-check-bg) 0%, var(--bg-card) 60%);
}

/* RANKING タブ */
.rank-score {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-primary);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: auto;
}

.tier-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.tier-1 { background: var(--pick-must-bg); color: var(--pick-must); }
.tier-2 { background: var(--pick-check-bg); color: var(--pick-check); }
.tier-3 { background: var(--bg-primary); color: var(--text-muted); }

/* =============================================
   もっと見る
   ============================================= */

#load-more-wrapper {
  text-align: center;
  padding: 28px 20px;
}

#load-more-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  padding: 10px 32px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

#load-more-btn:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* =============================================
   空状態・ローディング
   ============================================= */

#empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

#empty-state .empty-icon { font-size: 40px; margin-bottom: 16px; }

/* =============================================
   レスポンシブ
   ============================================= */

/* タブレット: 2カラム */
@media (max-width: 1100px) {
  .article-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* モバイル: 2段ヘッダー・サイドバー非表示・1カラム */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 0px;
    --header-h: 96px; /* 2段分の高さ */
  }

  /* ヘッダーを2段構成に */
  #header {
    flex-wrap: wrap;
    padding: 0 12px;
    height: auto;
    min-height: var(--header-h);
    gap: 0;
  }

  /* 1段目: ロゴ + フィルターボタン + 検索 */
  #logo {
    flex: 1;
    height: 48px;
    align-items: center;
  }

  #search-wrapper {
    height: 48px;
    display: flex;
    align-items: center;
  }

  #search-input {
    width: 130px;
    font-size: 13px;
  }

  #search-input:focus { width: 160px; }

  #sidebar-toggle {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 10px;
    margin: 0 4px;
  }

  /* 2段目: タブバーを全幅で下段に */
  #tabbar {
    width: 100%;
    height: 48px;
    border-top: 1px solid var(--border);
    justify-content: space-around;
    gap: 0;
    padding: 0 4px;
  }

  .tab-btn {
    flex: 1;
    padding: 0 8px;
    font-size: 13px;
    height: 100%;
    border-bottom: none;
    border-radius: var(--radius-sm);
  }

  .tab-btn.active {
    color: var(--accent-hover);
    background: var(--accent-subtle);
    border-bottom: none;
  }

  /* サイドバー: ドロップダウン型 */
  #sidebar {
    top: var(--header-h);
    left: 0; right: 0;
    bottom: auto;
    width: 100%;
    height: auto;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: none;
    overflow-y: auto;
    z-index: 150;
  }

  #sidebar.open { display: block; }

  #sidebar .sidebar-section {
    display: flex;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 4px;
  }

  .sidebar-divider { display: none; }

  .sidebar-item {
    border-left: none;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 4px 12px;
    font-size: 12px;
    display: inline-block;
  }

  .sidebar-item.active {
    background: var(--accent-subtle);
    border-color: var(--border-accent);
    color: var(--accent-hover);
  }

  /* メイン */
  #main { margin-left: 0; }

  .article-cards-grid { grid-template-columns: 1fr; }

  .date-group { padding: 0 12px; }
}
