/* ==========================================================================
   Ame-FileManager Quest - ゲーミフィケーション特化スタイルシート
   ADHDフレンドリー: 視覚的報酬、ネオングラデーション、コードが主役の設計
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans JP', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;

  --bg-primary: #0a0d14;
  --bg-secondary: #121722;
  --bg-tertiary: #1b2230;
  --bg-card: rgba(18, 23, 34, 0.85);
  --border-color: #273142;
  --border-subtle: #1c2433;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #38bdf8;
  --accent-blue: #60a5fa;
  --accent-green: #34d399;
  --accent-purple: #c084fc;
  --accent-amber: #fbbf24;
  --accent-rose: #f43f5e;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --header-height: 68px;
  --sidebar-width: 320px;
  --chat-width: 440px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 15px;
  height: 100%;
  overflow: hidden;
}

/* スクロールバー */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: var(--radius-full); }

/* ヘッダー & RPG ステータスバー */
header.game-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 50;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.game-title-badge {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.4);
}

/* プレイヤープロファイル / ステータス */
.player-status-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--bg-tertiary);
  padding: 0.45rem 1.25rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.level-badge {
  font-size: 0.9rem;
  font-weight: 800;
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.exp-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 140px;
}
.exp-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.exp-track {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.exp-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

.streak-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f43f5e;
}

.badges-row {
  display: flex;
  gap: 0.35rem;
}
.badge-chip {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(192, 132, 252, 0.15);
  color: var(--accent-purple);
  border: 1px solid rgba(192, 132, 252, 0.3);
}

/* メインレイアウト */
.app-body {
  display: flex;
  height: calc(100vh - var(--header-height));
  width: 100%;
  position: relative;
}

/* 左列: クエストリスト */
aside.quest-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.quest-nav-list {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.quest-nav-card {
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}
.quest-nav-card:hover {
  border-color: var(--accent-cyan);
  transform: translateX(2px);
}
.quest-nav-card.active {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}
.quest-nav-card.cleared {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.08);
}

/* 中央列: エディタ ＆ コンソール（画面の主役！） */
main.workspace {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* クエスト目標バナー（上部） */
.quest-banner {
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}
.quest-stage-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}
.quest-title-text {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.quest-mission-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.quest-rewards-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

/* エディタ ＆ コンソール分割エリア */
.code-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-wrapper {
  flex: 6;
  display: flex;
  flex-direction: column;
  background: #06090e;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}
.editor-bar {
  padding: 0.5rem 1rem;
  background: #0f141d;
  border-bottom: 1px solid #1a2332;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.editor-filename {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-cyan);
  font-weight: 700;
}
.editor-actions {
  display: flex;
  gap: 0.5rem;
}

textarea.code-textarea {
  flex: 1;
  width: 100%;
  padding: 1.25rem;
  background: #06090e;
  color: #f1f5f9;
  font-family: var(--font-mono);
  font-size: 0.98rem;
  line-height: 1.6;
  border: none;
  resize: none;
  outline: none;
  tab-size: 4;
}

/* コンソール（下部） */
.terminal-wrapper {
  flex: 4;
  display: flex;
  flex-direction: column;
  background: #04060a;
  overflow: hidden;
}
.terminal-bar {
  padding: 0.45rem 1rem;
  background: #0a0e14;
  border-bottom: 1px solid #161e2a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.terminal-content {
  flex: 1;
  padding: 1rem 1.25rem;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.5;
  color: #e2e8f0;
  white-space: pre-wrap;
}

/* テスト判定ボックス */
.test-result-box {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  font-size: 0.9rem;
}
.test-result-box.pass {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
}
.test-result-box.fail {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid var(--accent-rose);
  color: var(--accent-rose);
}

/* ボタン群 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}
.btn:hover { background: var(--border-color); }
.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: none;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.4);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-run {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}
.btn-run:hover { transform: scale(1.02); }
.btn-ai {
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: #fff;
  border: none;
  font-weight: 700;
}
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.78rem; }

/* ヒント・解答ボックス */
.expand-box {
  display: none;
  padding: 0.85rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin: 0.75rem 1.5rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* クエストクリアモーダル */
.clear-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}
.clear-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.clear-modal-card {
  width: 90%;
  max-width: 480px;
  background: var(--bg-secondary);
  border: 2px solid var(--accent-green);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  text-align: center;
  box-shadow: 0 0 40px rgba(52, 211, 153, 0.4);
  transform: scale(0.95);
  transition: var(--transition);
}
.clear-modal-overlay.open .clear-modal-card {
  transform: scale(1);
}

/* AI ドロワー */
.ai-drawer {
  position: fixed;
  top: var(--header-height);
  right: -500px;
  width: var(--chat-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.ai-drawer.open { right: 0; }
.ai-drawer-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.chat-bubble {
  max-width: 90%;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.5;
}
.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
}
.chat-bubble.ai {
  align-self: flex-start;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}
.ai-input-area {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.ai-input-box {
  display: flex;
  gap: 0.5rem;
}
.ai-textarea {
  flex: 1;
  resize: none;
  height: 48px;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  outline: none;
}

.floating-ai-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  z-index: 55;
  border: none;
  transition: var(--transition);
}
.floating-ai-btn:hover {
  transform: translateY(-2px) scale(1.03);
}

/* 設定モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-content {
  width: 90%;
  max-width: 500px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}
.form-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
}
