/* ============================================================
   デザインシステム & グローバルスタイル
   ============================================================ */

:root {
  /* Light Theme (Default) */
  --primary: #00c896;
  --primary-dark: #00a87e;
  --primary-light: #e0faf3;
  --accent: #ff6b35;
  --accent-light: #fff0ea;
  --bg: #f5f7f9;
  --bg-card: #ffffff;
  --bg-card2: #f0f2f5;
  --border: #e1e4e8;
  --text-primary: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8c959f;
  --danger: #cf222e;
  --warning: #9a6700;
  --info: #0969da;
  --success: #1a7f37;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
  --nav-h: 60px;
  --sidebar-w: 240px;
  --transition: 0.25s ease;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-card2: #1e2530;
  --border: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --danger: #f85149;
  --warning: #f0883e;
  --info: #58a6ff;
  --success: #3fb950;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --primary-light: rgba(0,200,150,0.15);
}

body {
  transition: background var(--transition), color var(--transition);
}
.sidebar, .topbar, .card, .stat-card, .btn, .form-input, .modal, .toast {
  transition: background var(--transition), color var(--transition), border var(--transition), box-shadow var(--transition);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Noto Sans JP', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ---- ローディング ---- */
.loading-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg); z-index: 9999;
  gap: 16px;
  transition: opacity 0.4s ease;
}
.loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-logo { font-size: 64px; animation: bounce 1.2s infinite; }
.loading-title { font-size: 1.4rem; font-weight: 700; color: var(--primary); letter-spacing: 0.05em; }
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* ---- レイアウト ---- */
#app { min-height: 100vh; }

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- サイドバー ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo { font-size: 28px; }
.sidebar-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.sidebar-subtitle { font-size: 0.7rem; color: var(--text-secondary); }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section-label {
  font-size: 0.65rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.1em; padding: 8px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-card2); color: var(--text-primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item.active .nav-icon { color: var(--primary); }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card2);
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; flex-shrink: 0;
}
.user-name { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 0.65rem; color: var(--text-secondary); }

/* ---- メインコンテンツ ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ---- トップバー ---- */
.topbar {
  height: var(--nav-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  gap: 16px;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; flex: 1; }
.hamburger {
  display: none; background: none; border: none;
  color: var(--text-primary); font-size: 1.4rem; padding: 4px;
}

.page-body { padding: 24px; flex: 1; }

/* ---- カード ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 1rem; font-weight: 700; }
.card-subtitle { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 600;
  border: none; transition: all var(--transition);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,200,150,0.3); }
.btn-secondary { background: var(--bg-card2); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ---- フォーム ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 0.9rem;
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,200,150,0.15);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-select option { background: var(--bg-card); }

/* ---- バッジ ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-danger { background: rgba(248,81,73,0.15); color: var(--danger); }
.badge-warning { background: rgba(240,136,62,0.15); color: var(--warning); }
.badge-info { background: rgba(88,166,255,0.15); color: var(--info); }
.badge-success { background: rgba(63,185,80,0.15); color: var(--success); }

/* ---- ページヘッダー ---- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-desc { font-size: 0.85rem; color: var(--text-secondary); margin-top: 4px; }

/* ---- グリッド ---- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- スタッツカード ---- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 500; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text-primary); }
.stat-icon { font-size: 1.6rem; }
.stat-row { display: flex; align-items: center; justify-content: space-between; }

/* ---- テーブル ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { padding: 10px 14px; text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: 0.05em; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-primary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card2); }

/* ---- モーダル ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
  box-shadow: var(--shadow);
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 1.4rem; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text-primary); background: var(--bg-card2); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ---- トースト ---- */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9000;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  min-width: 240px;
  animation: slideIn 0.3s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- ログイン画面 ---- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, rgba(0,200,150,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(255,107,53,0.08) 0%, transparent 50%),
              var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; font-size: 48px; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { text-align: center; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 28px; }

/* ---- ダッシュボード ---- */
.dashboard-welcome {
  background: linear-gradient(135deg, var(--primary) 0%, #00a0c8 100%);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  position: relative; overflow: hidden;
}
.dashboard-welcome::after {
  content: '🎾';
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  font-size: 64px; opacity: 0.2;
}
.welcome-greeting { font-size: 0.85rem; opacity: 0.85; }
.welcome-name { font-size: 1.5rem; font-weight: 700; margin: 4px 0; }
.welcome-date { font-size: 0.8rem; opacity: 0.75; }

/* ---- 動画ルーム ---- */
.room-list { display: flex; flex-direction: column; gap: 10px; }
.room-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.room-item:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.room-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #00a0c8);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.room-name { font-size: 0.95rem; font-weight: 600; }
.room-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

/* ---- 動画リスト ---- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
}
.video-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.video-thumb {
  width: 100%; aspect-ratio: 16/9;
  background: var(--bg-card2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; position: relative; overflow: hidden;
}
.video-thumb video { width: 100%; height: 100%; object-fit: cover; }
.play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.4);
  opacity: 0; transition: opacity var(--transition);
}
.video-card:hover .play-overlay { opacity: 1; }
.play-btn-big {
  width: 52px; height: 52px;
  background: rgba(0,200,150,0.9);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.video-info { padding: 12px 14px; }
.video-title { font-size: 0.875rem; font-weight: 600; margin-bottom: 4px; }
.video-meta { font-size: 0.72rem; color: var(--text-secondary); }

/* ---- プログレスバー（容量） ---- */
.storage-bar {
  width: 100%; height: 10px;
  background: var(--bg-card2);
  border-radius: 5px; overflow: hidden;
  margin: 8px 0;
}
.storage-fill {
  height: 100%; border-radius: 5px;
  background: var(--primary);
  transition: width 0.5s ease;
}
.storage-fill.warning { background: var(--warning); }
.storage-fill.danger { background: var(--danger); }

/* ---- グラフコンテナ ---- */
.chart-wrap { position: relative; height: 280px; }

/* ---- 振り返りカード ---- */
.reflection-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  transition: all var(--transition);
}
.reflection-card:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }
.reflection-date { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 8px; }
.reflection-content { font-size: 0.875rem; line-height: 1.7; white-space: pre-wrap; }
.reflection-comment {
  margin-top: 12px; padding: 10px 14px;
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem; color: var(--text-primary);
}
.reflection-comment-label { font-size: 0.7rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }

/* ---- 空状態 ---- */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-primary); }
.empty-desc { font-size: 0.85rem; }

/* ---- タブ ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 8px 16px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 0.875rem; font-weight: 500;
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--text-primary); }

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

/* ---- ユーティリティ ---- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 0.8rem; }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---- レスポンシブ ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99; display: none;
  }
  .sidebar-backdrop.show { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
  .login-card { padding: 28px 20px; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 480px) {
  .video-grid { grid-template-columns: 1fr; }
}

/* ---- テニスボールエフェクト ---- */
@keyframes tennis-fly {
  0% { left: -60px; transform: rotate(0deg) scale(0.6); opacity: 1; }
  50% { transform: rotate(540deg) scale(1.2); }
  100% { left: 105vw; transform: rotate(1080deg) scale(0.8); opacity: 0; }
}
.tennis-ball-effect {
  position: fixed; pointer-events: none; z-index: 10000;
  width: 44px; height: 44px;
  background: #d4f800; /* テニスボールの蛍光イエロー */
  border-radius: 50%;
  box-shadow: inset -4px -4px 10px rgba(0,0,0,0.2), 0 4px 15px rgba(0,0,0,0.2);
  will-change: left, transform;
  animation: tennis-fly 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
/* ボールの白いライン */
.tennis-ball-effect::before, .tennis-ball-effect::after {
  content: ''; position: absolute;
  width: 100%; height: 100%;
  border: 2px solid #fff;
  border-radius: 50%;
}
.tennis-ball-effect::before { left: -70%; }
.tennis-ball-effect::after { right: -70%; }
