/* =============================================
   LMS スタイルシート（レスポンシブ対応）
   ============================================= */

/* リセット & 基本設定 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--gray-900);
  background-color: var(--gray-50);
}

a {
  text-decoration: none;
  color: var(--primary-color);
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-hover);
}

/* =============================================
   ログイン画面
   ============================================= */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-color) 0%, #1e40af 100%);
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 450px;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h1 {
  color: white;
  font-size: 1.8rem;
  margin-bottom: 15px;
}

.language-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: white;
}

.language-switcher a {
  color: rgba(255, 255, 255, 0.8);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.9rem;
}

.language-switcher a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.language-switcher a.active {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  font-weight: 600;
}

.login-box {
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-box h2 {
  margin-bottom: 20px;
  color: var(--gray-800);
  font-size: 1.5rem;
}

.form-description {
  color: var(--gray-600);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* =============================================
   ナビゲーションバー
   ============================================= */

.navbar {
  background-color: white;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.nav-brand {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary-color);
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-link {
  color: var(--gray-600);
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--primary-color);
  background-color: var(--gray-50);
}

.nav-link.active {
  color: var(--primary-color);
  background-color: var(--gray-100);
}

.nav-user {
  color: var(--gray-700);
  font-weight: 500;
}

/* ナビゲーションバー内の言語切り替え */
.navbar .language-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.navbar .language-switcher a {
  color: var(--gray-600);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.navbar .language-switcher a:hover {
  background-color: var(--gray-100);
  color: var(--primary-color);
}

.navbar .language-switcher a.active {
  background-color: var(--primary-color);
  color: white;
}

.navbar .language-switcher span {
  color: var(--gray-400);
}

/* =============================================
   コンテナ & レイアウト
   ============================================= */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 20px;
}

.content-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 30px;
  margin-top: 20px;
}

/* =============================================
   フォーム
   ============================================= */

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.95rem;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control.text-center {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  font-weight: 600;
}

.form-text {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--gray-500);
}

.form-footer {
  margin-top: 20px;
  text-align: center;
}

.form-horizontal {
  max-width: 100%;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-label {
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
  display: block;
}

/* =============================================
   ボタン
   ============================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  color: white;
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
  color: white;
}

.btn-outline {
  background-color: transparent;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-outline:hover {
  background-color: var(--gray-100);
  color: var(--gray-800);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.1rem;
}

/* =============================================
   アラート
   ============================================= */

.alert {
  padding: 16px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-weight: 500;
}

.alert-error {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* =============================================
   カード
   ============================================= */

.card {
  background-color: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
}

.card h2 {
  margin-bottom: 20px;
  color: var(--gray-800);
  font-size: 1.3rem;
}

/* =============================================
   レッスン一覧
   ============================================= */

.lessons-list {
  background-color: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  height: fit-content;
}

.lessons-list h2 {
  margin-bottom: 20px;
  color: var(--gray-800);
  font-size: 1.3rem;
}

.lesson-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lesson-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  transition: all 0.2s;
  cursor: pointer;
}

.lesson-item:hover {
  border-color: var(--primary-color);
  background-color: var(--gray-50);
}

.lesson-item.active {
  border-color: var(--primary-color);
  background-color: #eff6ff;
}

.lesson-number {
  width: 40px;
  height: 40px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.lesson-title {
  color: var(--gray-800);
  font-weight: 600;
}

/* =============================================
   レッスンコンテンツ
   ============================================= */

.lesson-content {
  background-color: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.lesson-content h2 {
  margin-bottom: 20px;
  color: var(--gray-800);
}

.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  background-color: black;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 30px;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.video-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  text-align: center;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

/* =============================================
   受講記録フォーム
   ============================================= */

.attendance-form {
  border-top: 2px solid var(--gray-200);
  padding-top: 30px;
}

.attendance-form h3 {
  margin-bottom: 20px;
  color: var(--gray-800);
}

.user-checkboxes {
  margin-bottom: 20px;
  max-height: 400px;
  overflow-y: auto;
  padding: 15px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.checkbox-label:hover {
  background-color: var(--gray-50);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.attendance-date {
  margin-left: auto;
  color: var(--success-color);
  font-size: 0.85rem;
  font-weight: 600;
}

/* =============================================
   テーブル
   ============================================= */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead {
  background-color: var(--gray-100);
}

.table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-300);
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-200);
}

.table tbody tr:hover {
  background-color: var(--gray-50);
}

/* =============================================
   バッジ
   ============================================= */

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-primary {
  background-color: #dbeafe;
  color: var(--primary-color);
}

.badge-secondary {
  background-color: var(--gray-200);
  color: var(--gray-700);
}

/* =============================================
   CSV出力
   ============================================= */

.export-info {
  text-align: center;
  padding: 40px 20px;
}

.export-info h2 {
  margin-bottom: 15px;
  color: var(--gray-800);
}

.export-info p {
  color: var(--gray-600);
  margin-bottom: 30px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.stat-item {
  background-color: var(--gray-50);
  padding: 20px;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
}

.stat-label {
  display: block;
  color: var(--gray-600);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.stat-value {
  display: block;
  color: var(--primary-color);
  font-size: 2rem;
  font-weight: 700;
}

.export-actions {
  margin-top: 30px;
}

/* =============================================
   ユーティリティ
   ============================================= */

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--gray-500);
}

.text-error {
  color: var(--danger-color);
}

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

@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .lessons-list {
    order: 2;
  }

  .lesson-content {
    order: 1;
  }
}

@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    padding: 15px;
    gap: 15px;
  }

  .nav-menu {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .nav-brand {
    font-size: 1.1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .login-box {
    padding: 30px 20px;
  }

  .card {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 20px 15px;
  }

  .lesson-item {
    padding: 12px;
  }

  .lesson-number {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .btn {
    padding: 12px 16px;
    font-size: 0.95rem;
  }
}

/* =============================================
   ダークモード
   ============================================= */

body.dark-mode {
  background-color: #1f2937;
  color: #f9fafb;
}

body.dark-mode .card {
  background-color: #374151;
  border-color: #4b5563;
}

body.dark-mode .navbar {
  background-color: #111827;
  border-bottom-color: #374151;
}

body.dark-mode .nav-link {
  color: #d1d5db;
}

body.dark-mode .nav-link:hover,
body.dark-mode .nav-link.active {
  color: #60a5fa;
  background-color: #1f2937;
}

body.dark-mode .table {
  background-color: #374151;
  color: #f9fafb;
}

body.dark-mode .table thead {
  background-color: #1f2937;
}

body.dark-mode .table tbody tr {
  border-bottom-color: #4b5563;
}

body.dark-mode .table tbody tr:hover {
  background-color: #1f2937;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
  background-color: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

body.dark-mode .form-control:focus {
  border-color: #60a5fa;
}

body.dark-mode .btn-outline {
  border-color: #4b5563;
  color: #d1d5db;
}

body.dark-mode .btn-outline:hover {
  background-color: #374151;
  border-color: #60a5fa;
}

body.dark-mode .alert-error {
  background-color: #7f1d1d;
  border-color: #991b1b;
  color: #fecaca;
}

body.dark-mode .alert-success {
  background-color: #065f46;
  border-color: #047857;
  color: #a7f3d0;
}

body.dark-mode .lesson-item {
  background-color: #374151;
  border-color: #4b5563;
}

body.dark-mode .lesson-item:hover {
  background-color: #1f2937;
  border-color: #60a5fa;
}

/* ダークモードトグルボタン */
.dark-mode-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  transition: all 0.3s;
  z-index: 100;
}

.dark-mode-toggle:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

body.dark-mode .dark-mode-toggle {
  background: #f59e0b;
}

/* =============================================
   パンくずリスト
   ============================================= */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0;
  font-size: 0.9rem;
  color: var(--gray-600);
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-separator {
  color: var(--gray-400);
}

body.dark-mode .breadcrumb {
  color: #9ca3af;
}

/* =============================================
   フィルター機能
   ============================================= */

.filter-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 250px;
}

.filter-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.filter-btn:hover {
  background: var(--gray-50);
}

.filter-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

body.dark-mode .filter-btn {
  background: #374151;
  border-color: #4b5563;
  color: #d1d5db;
}

body.dark-mode .filter-btn.active {
  background: #60a5fa;
  border-color: #60a5fa;
}

/* =============================================
   チェックボックス改善
   ============================================= */

.checkbox-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.checkbox-item:hover {
  background: var(--gray-50);
  border-color: var(--primary-color);
}

.checkbox-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 0.75rem;
  cursor: pointer;
}

.checkbox-item label {
  flex: 1;
  cursor: pointer;
  margin: 0;
}

body.dark-mode .checkbox-item {
  border-color: #4b5563;
}

body.dark-mode .checkbox-item:hover {
  background: #1f2937;
}

/* =============================================
   プリセットボタン
   ============================================= */

.preset-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.preset-btn {
  padding: 0.4rem 0.8rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.preset-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

body.dark-mode .preset-btn {
  background: #374151;
  border-color: #4b5563;
  color: #d1d5db;
}

/* =============================================
   ツールチップ
   ============================================= */

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 0.75rem;
  background: #1f2937;
  color: white;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
}

.tooltip:hover::after {
  opacity: 1;
}

/* =============================================
   印刷用CSS
   ============================================= */

@media print {
  body {
    background: white;
    color: black;
  }

  .navbar,
  .nav-menu,
  .btn,
  .filter-controls,
  .dark-mode-toggle,
  .breadcrumb {
    display: none !important;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .table {
    font-size: 0.85rem;
  }

  .table th,
  .table td {
    padding: 0.5rem;
  }

  a[href]:after {
    content: none;
  }
}

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

@media (max-width: 1024px) {
  .filter-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 100%;
  }
}

@media (max-width: 768px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .preset-buttons {
    justify-content: stretch;
  }

  .preset-btn {
    flex: 1;
  }

  .dark-mode-toggle {
    bottom: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .filter-buttons {
    width: 100%;
  }

  .filter-btn {
    flex: 1;
    text-align: center;
  }
}
