/* ===========================
   Japanese Language School CSS
   =========================== */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a2b4a;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ---- Navbar ---- */
.navbar {
  background: #1a2b4a;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.navbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-box {
  width: 36px; height: 36px;
  background: #dc2626;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}
.logo-text {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}
.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-user { color: #94a3b8; font-size: 14px; }
.nav-back { color: #94a3b8; font-size: 13px; }
.nav-back:hover { color: #fff; }
.nav-logout {
  color: #fff;
  background: rgba(255,255,255,0.1);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
}
.nav-logout:hover { background: #dc2626; }

/* ---- Page wrapper ---- */
.app-body { min-height: 100vh; }
.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 24px; font-weight: 700; }
.page-header p { color: #6b7280; margin-top: 4px; }

/* ---- Course Grid (student dashboard) ---- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}
.course-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform .2s, box-shadow .2s;
}
.course-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.course-thumb img {
  width: 100%; height: 180px; object-fit: cover; display: block;
}
.thumb-placeholder {
  width: 100%; height: 180px;
  background: linear-gradient(135deg, #1a2b4a 0%, #dc2626 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 28px; font-weight: 700; letter-spacing: 2px;
}
.course-body { padding: 20px; }
.course-body h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.course-body h3 a:hover { color: #dc2626; }
.course-desc { font-size: 13px; color: #6b7280; margin-bottom: 12px; }
.course-meta { font-size: 12px; color: #9ca3af; margin-bottom: 16px; }
.btn-view {
  display: block;
  background: #1a2b4a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: background .2s;
}
.btn-view:hover { background: #dc2626; }

/* ---- Course viewer layout ---- */
.course-layout {
  display: flex;
  min-height: calc(100vh - 60px);
}
.lesson-sidebar {
  width: 300px;
  min-width: 260px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
}
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #1a2b4a;
  color: #fff;
}
.sidebar-header h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.sidebar-header span { font-size: 12px; opacity: 0.7; }
.lesson-list { list-style: none; }
.lesson-list li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  transition: background .15s;
}
.lesson-list li a:hover { background: #f9fafb; }
.lesson-list li.active a { background: #eff6ff; color: #1a2b4a; font-weight: 600; border-left: 3px solid #dc2626; }
.l-num {
  width: 24px; height: 24px;
  background: #e5e7eb;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.lesson-list li.active .l-num { background: #dc2626; color: #fff; }
.l-title { flex: 1; }
.l-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600;
}
.l-badge.vid { background: #dbeafe; color: #1d4ed8; }
.l-badge.pdf { background: #dcfce7; color: #166534; }

.lesson-main {
  flex: 1;
  padding: 32px;
  max-width: 900px;
}
.lesson-header { margin-bottom: 24px; }
.lesson-header h2 { font-size: 22px; font-weight: 700; }
.lesson-desc { color: #6b7280; margin-top: 8px; font-size: 14px; }
.video-wrap {
  position: relative;
  padding-bottom: 56.25%;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}
.video-wrap iframe,
.video-wrap video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}
.pdf-section {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}
.pdf-section h4 { margin-bottom: 12px; }
.btn-pdf {
  display: inline-block;
  background: #16a34a;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.btn-pdf:hover { background: #15803d; }
.lesson-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
}
.btn-nav {
  background: #e5e7eb;
  color: #1a2b4a;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.btn-nav.primary { background: #1a2b4a; color: #fff; }
.btn-nav:hover { opacity: 0.85; }

/* ---- Admin layout ---- */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 60px);
}
.admin-sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 20px 0;
}
.admin-sidebar ul { list-style: none; }
.admin-sidebar li a {
  display: block;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
  transition: all .15s;
}
.admin-sidebar li a:hover { background: #f9fafb; color: #1a2b4a; }
.admin-sidebar li.active a {
  background: #eff6ff;
  color: #1a2b4a;
  font-weight: 700;
  border-left: 3px solid #dc2626;
}
.admin-main {
  flex: 1;
  padding: 32px;
  overflow-x: auto;
}
.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.admin-page-header h2 { font-size: 22px; font-weight: 700; }
.admin-section { background: #fff; border-radius: 12px; padding: 24px; margin-bottom: 24px; }
.admin-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}

/* ---- Stats ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  border-top: 4px solid #e5e7eb;
}
.stat-card.blue { border-color: #3b82f6; }
.stat-card.green { border-color: #16a34a; }
.stat-card.red { border-color: #dc2626; }
.stat-card.gray { border-color: #9ca3af; }
.stat-num { font-size: 36px; font-weight: 800; color: #1a2b4a; }
.stat-label { font-size: 13px; color: #6b7280; margin-top: 4px; }

/* ---- Tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.data-table tr:hover td { background: #f9fafb; }
.action-cell { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn-primary {
  background: #1a2b4a;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover { background: #dc2626; }
.btn-sm {
  background: #f3f4f6;
  color: #374151;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-sm:hover { background: #e5e7eb; }
.btn-sm.danger { background: #fef2f2; color: #dc2626; }
.btn-sm.danger:hover { background: #dc2626; color: #fff; }
.btn-sm.success { background: #f0fdf4; color: #16a34a; }
.btn-sm.success:hover { background: #16a34a; color: #fff; }

/* ---- Badges / Status ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #dbeafe;
  color: #1d4ed8;
  margin: 1px;
}
.badge.green { background: #dcfce7; color: #166534; }
.status-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.status-badge.active { background: #dcfce7; color: #166534; }
.status-badge.inactive { background: #fee2e2; color: #dc2626; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label, .field-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .2s;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: #1a2b4a;
}
.form-group small { color: #9ca3af; font-size: 12px; margin-top: 4px; display: block; }
.checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; cursor: pointer; padding: 6px 0;
}
.check-item input { width: 16px; height: 16px; cursor: pointer; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: #9ca3af;
  line-height: 1;
}
.modal-close:hover { color: #374151; }

/* ---- Flash messages ---- */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.flash.error {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: #374151; margin-bottom: 8px; }

/* ---- Admin courses grid ---- */
.course-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.admin-course-card {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}
.admin-thumb { width: 100%; height: 140px; object-fit: cover; display: block; }
.admin-thumb-placeholder {
  width: 100%; height: 140px;
  background: linear-gradient(135deg, #1a2b4a, #dc2626);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; letter-spacing: 2px;
}
.admin-course-body { padding: 16px; }
.admin-course-body h4 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.course-stats { font-size: 12px; color: #9ca3af; display: flex; gap: 12px; margin-bottom: 12px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- Course pills selector ---- */
.course-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 6px 16px;
  border-radius: 20px;
  background: #f3f4f6;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  border: 2px solid transparent;
}
.pill.active { background: #1a2b4a; color: #fff; }
.pill:hover { border-color: #1a2b4a; }

/* ---- Utilities ---- */
.text-muted { color: #9ca3af; font-size: 13px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .lesson-sidebar { display: none; }
  .lesson-main { padding: 16px; }
  .admin-sidebar { display: none; }
  .admin-main { padding: 16px; }
  .course-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .action-cell { flex-direction: column; }
}
