/* =============================================================
   common.css — 共通スタイル
   全ページ共通のリセット・変数・ヘッダー・ナビゲーション・
   ステータスバッジ・ローディングスピナーを定義する。

   読み込み順: common.css → ページ固有CSS
   ============================================================= */

/* -------------------------------------------------------
   1. リセット
------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* -------------------------------------------------------
   2. CSS変数（デザイントークン）
------------------------------------------------------- */
:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --card2: #1f2235;
  --border: #2a2d3e;
  --accent: #7c3aed;
  --accent-light: #9d5cf8;
  --accent-glow: rgba(124, 58, 237, 0.2);
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --text-dim: #5a6278;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --blue: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
}

/* dev-mode: /dev/ アクセス時に背景を黒に変更 */
body.dev-mode {
  --bg: #000000;
  --card: #111111;
  --card2: #181818;
  --border: #222222;
}
body.dev-mode .header {
  background: linear-gradient(135deg, #0a0a0a 0%, #0d0818 100%);
}
body.dev-mode .nav-menu {
  background: var(--card);
}

/* -------------------------------------------------------
   3. body基本スタイル
------------------------------------------------------- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'Hiragino Sans', 'Meiryo', sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* -------------------------------------------------------
   4. スクロールラッパー（iOS対応）
------------------------------------------------------- */
#scroll-wrapper {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
}

/* -------------------------------------------------------
   5. ヘッダー
------------------------------------------------------- */
.header {
  background: linear-gradient(135deg, #1a1d27 0%, #1e1630 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

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

.header-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px var(--accent-glow);
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* -------------------------------------------------------
   6. ハンバーガーボタン
------------------------------------------------------- */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 200;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* -------------------------------------------------------
   7. ナビメニュー
------------------------------------------------------- */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* -------------------------------------------------------
   8. ナビゲーションリンク
------------------------------------------------------- */
.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text);
  background: var(--card2);
}

.nav-link.active {
  color: var(--accent-light);
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.3);
}

/* -------------------------------------------------------
   9. モバイル: ハンバーガー + 縦スクロールメニュー
------------------------------------------------------- */
@media (max-width: 768px) {
  .hamburger { display: flex; }

  .nav-menu {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--card);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 12px 0;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    z-index: 150;
  }
  .nav-menu.open { display: flex; }

  .nav-menu .nav-link {
    padding: 14px 24px;
    font-size: 15px;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .nav-menu .nav-link:last-of-type { border-bottom: none; }

  .nav-menu .status-badge {
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
  }

  .header-title { font-size: 15px; }
  .header-icon { width: 30px; height: 30px; font-size: 15px; }
}

/* -------------------------------------------------------
   7. ステータスバッジ / ステータスドット
------------------------------------------------------- */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}

.status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
  animation: none;
}

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

/* -------------------------------------------------------
   8. ローディングスピナー
------------------------------------------------------- */
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
