/* ════════════════════════════════════════════════
   COURSE HUB — Design System
   Aesthetic: Editorial / warm academic
   ════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&family=Nunito+Sans:opsz,wght@6..12,300;6..12,400;6..12,500;6..12,600;6..12,700&display=swap');

:root {
  --bg: #FAF7F2;
  --bg-warm: #F3EDE4;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FDFCFA;
  --bg-overlay: rgba(26, 22, 18, 0.55);
  --text: #1A1612;
  --text-secondary: #5C554C;
  --text-muted: #9E958A;
  --accent: #B8542E;
  --accent-hover: #9A4525;
  --accent-soft: #F6E8E1;
  --accent-glow: rgba(184, 84, 46, 0.08);
  --border: #E8E2D8;
  --border-light: #F0EBE3;
  --success: #3D7A52;
  --success-bg: #EAF4EE;
  --danger: #B83B2E;
  --danger-bg: #FAEDEB;
  --warning: #C4880C;
  --warning-bg: #FDF5E6;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.02);
  --radius: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-body: 'Nunito Sans', system-ui, sans-serif;
  --max-w: 1180px;
  --header-h: 64px;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

/* ── Layout ─────────────────────────────────── */

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
}

/* ── Header ─────────────────────────────────── */

.site-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(250, 247, 242, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 500;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: all 0.15s;
}

.nav-link:hover { color: var(--text); background: var(--bg-warm); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); }

/* ── Search ─────────────────────────────────── */

.search-box {
  position: relative;
  width: 100%;
  max-width: 460px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 42px;
  padding: 0 16px 0 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input::placeholder { color: var(--text-muted); }

/* ── Buttons ────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-muted); background: var(--bg-card-hover); }

.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover { color: var(--text); background: var(--border-light); }

.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success { background: var(--success-bg); color: var(--success); }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-xs { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-block { width: 100%; }

.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Tags / chips ───────────────────────────── */

.tag-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px 0;
}

.tag-chip {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.tag-chip:hover { border-color: var(--accent); color: var(--accent); }

.tag-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tag-count {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 3px;
}

/* ── Cards ──────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.2s var(--ease);
}

.card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
}

.card-body { padding: 24px; }

/* ── Course card ────────────────────────────── */

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 20px;
}

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

.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  position: relative;
}

.course-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 24px; right: 24px;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transform: scaleX(0);
  transition: transform 0.25s var(--ease);
}

.course-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.course-card:hover::after { transform: scaleX(1); }

.course-card-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 14px;
}

.course-card h3 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 8px;
  color: var(--text);
}

.course-card .desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.course-meta svg { width: 14px; height: 14px; opacity: 0.6; }

.meta-item { display: flex; align-items: center; gap: 5px; }

/* ── Course detail page ─────────────────────── */

.course-hero {
  padding: 48px 0 36px;
  border-bottom: 1px solid var(--border);
}

.course-hero .breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.course-hero .breadcrumb a { color: var(--text-secondary); }
.course-hero .breadcrumb a:hover { color: var(--accent); }

.course-hero h1 {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.course-hero .hero-desc {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 640px;
}

.course-hero .hero-meta {
  margin-top: 20px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.hero-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.hero-stat svg { width: 16px; height: 16px; }

/* ── File list ──────────────────────────────── */

.file-section { padding: 32px 0 60px; }

.file-section h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  transition: all 0.15s;
}

.file-row:hover {
  border-color: var(--border);
  background: var(--bg-card-hover);
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.file-icon.pdf { background: #FAEDEB; color: #B83B2E; }
.file-icon.doc { background: #E6F0FA; color: #2E6AB8; }
.file-icon.xls { background: #EAF4EE; color: #3D7A52; }
.file-icon.zip { background: #F3ECF8; color: #7B3DB8; }
.file-icon.img { background: #FDF5E6; color: #C4880C; }
.file-icon.default { background: var(--bg-warm); color: var(--text-secondary); }

.file-info { min-width: 0; }

.file-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-date {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.file-download {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.file-download:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.file-download svg { width: 16px; height: 16px; }

/* ── Admin layout ───────────────────────────── */

.admin-header {
  background: var(--text);
  color: #fff;
}

.admin-header .header-inner { border-bottom: none; }
.admin-header .logo { color: #fff; }
.admin-header .logo-icon { background: var(--accent); }
.admin-header .nav-link { color: rgba(255,255,255,0.6); }
.admin-header .nav-link:hover { color: #fff; background: rgba(255,255,255,0.08); }
.admin-header .nav-link.active { color: #fff; background: rgba(255,255,255,0.12); }

.admin-body { padding: 32px 0 60px; }

.admin-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
}

.admin-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── Admin table ────────────────────────────── */

.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-table th {
  text-align: left;
  padding: 12px 18px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-warm);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 14px 18px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table tr:hover td { background: var(--bg-card-hover); }

/* ── Modal / Dialog ─────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.25s var(--ease-spring);
}

.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 24px 28px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg-warm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.modal-close:hover { background: var(--border); color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body { padding: 20px 28px 28px; }

/* ── Forms ──────────────────────────────────── */

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-card);
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ── File upload zone ───────────────────────── */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone svg { width: 36px; height: 36px; color: var(--text-muted); margin: 0 auto 10px; }
.upload-zone p { font-size: 14px; color: var(--text-secondary); }
.upload-zone .upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.upload-progress {
  margin-top: 16px;
}

.progress-bar-wrap {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

.upload-file-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upload-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 13px;
}

.upload-file-item .file-name { font-weight: 500; }
.upload-file-item .file-size { color: var(--text-muted); font-size: 12px; }

/* ── Login gate ─────────────────────────────── */

.login-gate {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 6px;
}

.login-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-card .form-group { text-align: left; }

.login-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-bg);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

/* ── Toast notifications ────────────────────── */

.toast-container {
  position: fixed;
  top: calc(var(--header-h) + 16px);
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s var(--ease-spring);
  max-width: 360px;
}

.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.info { background: var(--text); color: #fff; }

.toast.out { animation: toastOut 0.2s var(--ease) forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ── Empty state ────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state svg { width: 48px; height: 48px; color: var(--text-muted); margin: 0 auto 16px; opacity: 0.5; }
.empty-state h3 { font-family: var(--font-display); font-size: 20px; margin-bottom: 6px; }
.empty-state p { font-size: 14px; color: var(--text-muted); max-width: 320px; margin: 0 auto; }

/* ── Confirm dialog ─────────────────────────── */

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Responsive ─────────────────────────────── */

@media (max-width: 640px) {
  .course-hero h1 { font-size: 28px; }
  .course-card { padding: 20px; }
  .file-row { grid-template-columns: auto 1fr auto; gap: 10px; }
  .file-date { display: none; }
  .header-nav .nav-link span { display: none; }
  .modal { margin: 12px; max-width: none; }
}

/* ── Stagger animation ──────────────────────── */

.stagger-in {
  opacity: 0;
  transform: translateY(12px);
  animation: staggerFadeIn 0.4s var(--ease) forwards;
}

@keyframes staggerFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Skeleton loading ───────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--bg-warm) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
