/* ============== LearnHub Base Styles ============== */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #10b981;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }

.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.col { flex: 1; min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.15s ease; text-decoration: none; }
.btn:hover { border-color: var(--primary-light); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-warn { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.card { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 14px; }

.input, select.input, textarea.input, input[type=text].input, input[type=password].input, input[type=number].input, input[type=email].input, input[type=tel].input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 14px; outline: none;
}
.input:focus, .input:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
textarea.input { min-height: 200px; resize: vertical; line-height: 1.6; }
label.label { display: block; margin: 12px 0 6px; font-weight: 500; font-size: 13px; color: var(--text); }

.form-row { display: flex; flex-wrap: wrap; gap: 12px; }
.form-row > .form-cell { flex: 1; min-width: 220px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-expiring { background: #fef3c7; color: #92400e; }
.badge-expired { background: #fee2e2; color: #991b1b; }
.badge-disabled { background: #f3f4f6; color: #4b5563; }
.badge-unknown { background: #f3f4f6; color: #6b7280; }
.badge-draft { background: #f3f4f6; color: #4b5563; }
.badge-published { background: #dbeafe; color: #1e40af; }
.badge-offline { background: #fef3c7; color: #92400e; }

table.table { width: 100%; border-collapse: collapse; background: #fff; }
table.table th, table.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }
table.table th { background: #f9fafb; font-weight: 600; color: var(--text-muted); }
table.table tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #fafbff; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-card { padding: 16px; }
.stat-card .num { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-card .label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.stat-card.primary { background: linear-gradient(135deg, #ede9fe, #f5f3ff); }
.stat-card.success { background: linear-gradient(135deg, #dcfce7, #f0fdf4); }
.stat-card.warn { background: linear-gradient(135deg, #fef3c7, #fffbeb); }
.stat-card.danger { background: linear-gradient(135deg, #fee2e2, #fef2f2); }

.muted { color: var(--text-muted); }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.space-between { display: flex; justify-content: space-between; align-items: center; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 16px; }
.p-2 { padding: 12px; }

/* ============== Admin Layout ============== */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 220px; background: #1e293b; color: #cbd5e1; padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.admin-sidebar .logo { font-size: 18px; font-weight: 700; color: #fff; padding: 0 18px 18px; border-bottom: 1px solid #334155; margin-bottom: 12px; }
.admin-sidebar a { display: block; padding: 10px 18px; color: #cbd5e1; font-size: 14px; border-left: 3px solid transparent; }
.admin-sidebar a:hover { background: #334155; color: #fff; }
.admin-sidebar a.active { background: #334155; color: #fff; border-left-color: var(--primary-light); }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-header { background: #fff; padding: 12px 24px; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; }
.admin-content { padding: 24px; }

@media (max-width: 768px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: relative; display: flex; overflow-x: auto; padding: 8px 0; }
  .admin-sidebar .logo { display: none; }
  .admin-sidebar a { padding: 10px 14px; white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .admin-sidebar a.active { border-left: none; border-bottom-color: var(--primary-light); }
  .admin-content { padding: 14px; }
}

/* ============== Client Layout ============== */
.client-shell { min-height: 100vh; display: flex; flex-direction: column; }
.client-topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.client-topbar .brand { font-weight: 700; font-size: 16px; color: var(--text); }
.client-topbar .topnav { display: flex; gap: 12px; }
.client-topbar .topnav a { padding: 6px 12px; border-radius: 8px; color: var(--text-muted); }
.client-topbar .topnav a.active { background: var(--bg); color: var(--text); }
.client-main { flex: 1; }
.client-bottombar { display: none; }

@media (max-width: 768px) {
  .client-topbar .topnav { display: none; }
  .client-bottombar { display: flex; background: #fff; border-top: 1px solid var(--border); position: sticky; bottom: 0; z-index: 50; }
  .client-bottombar a { flex: 1; text-align: center; padding: 10px 0; font-size: 12px; color: var(--text-muted); }
  .client-bottombar a.active { color: var(--primary); }
}

.course-card { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform 0.15s; }
.course-card:hover { transform: translateY(-2px); }
.course-card .cover { aspect-ratio: 16/9; background: linear-gradient(135deg, #c7d2fe, #e0e7ff); display: flex; align-items: center; justify-content: center; color: #4f46e5; font-weight: 700; font-size: 18px; }
.course-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.course-card .body { padding: 12px; }
.course-card .title { font-weight: 600; font-size: 14px; margin-bottom: 6px; line-height: 1.4; }
.course-card .meta { color: var(--text-muted); font-size: 12px; }
.progress { height: 6px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress .bar { height: 100%; background: linear-gradient(90deg, #4f46e5, #818cf8); border-radius: 999px; }
.progress-text { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

.banner { aspect-ratio: 16/5; border-radius: var(--radius); overflow: hidden; background: linear-gradient(135deg, #6366f1, #8b5cf6); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; font-weight: 600; margin-bottom: 14px; }
.banner img { width: 100%; height: 100%; object-fit: cover; }

.notice-block { background: linear-gradient(90deg, #fef3c7, #fefce8); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; color: #92400e; }

.section-title { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 12px; }
.section-title h2 { font-size: 16px; margin: 0; font-weight: 600; }

/* learn page */
.learn-shell { display: flex; min-height: 100vh; }
.learn-sidebar { width: 280px; border-right: 1px solid var(--border); background: #fff; overflow-y: auto; max-height: 100vh; position: sticky; top: 0; }
.learn-sidebar .chapter { border-bottom: 1px solid var(--border); }
.learn-sidebar .chapter-title { padding: 12px 14px; font-weight: 600; background: #f9fafb; }
.learn-sidebar .content-link { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; color: var(--text); }
.learn-sidebar .content-link:hover { background: #f9fafb; }
.learn-sidebar .content-link.active { background: #ede9fe; color: var(--primary); font-weight: 600; }
.learn-sidebar .content-link .type { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg); color: var(--text-muted); }
.learn-sidebar .content-link.completed::after { content: '✓'; margin-left: auto; color: var(--success); }
.learn-main { flex: 1; padding: 20px 28px; min-width: 0; }
@media (max-width: 768px) {
  .learn-shell { flex-direction: column; }
  .learn-sidebar { width: 100%; position: relative; max-height: 240px; }
  .learn-main { padding: 14px; }
}

/* lesson body */
.lesson-content { max-width: 800px; margin: 0 auto; background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.lesson-content h1 { font-size: 22px; margin: 0 0 16px; }
.lesson-content video { width: 100%; border-radius: 8px; background: #000; }
.lesson-content .note-body, .lesson-content .imagetext-body { line-height: 1.7; font-size: 15px; }
.lesson-content .note-body img, .lesson-content .imagetext-body img { max-width: 100%; border-radius: 6px; }

/* login */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.auth-card { background: #fff; border-radius: 14px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,0.15); }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.auth-tabs a { flex: 1; text-align: center; padding: 12px 0; color: var(--text-muted); font-weight: 500; }
.auth-tabs a.active { color: var(--primary); border-bottom: 2px solid var(--primary); }

/* misc */
.chev { transition: transform 0.2s; }
.chev.open { transform: rotate(180deg); }
.course-card-list .course-card { display: flex; align-items: stretch; }
.course-card-list .cover { width: 140px; flex: 0 0 140px; aspect-ratio: auto; }
.course-card-list .body { flex: 1; }
@media (max-width: 600px) {
  .course-card-list .cover { width: 100px; flex: 0 0 100px; }
}
.text-ellipsis-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.text-ellipsis-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
