/* LearnChat LMS - WhatsApp-inspired Design System */
/* Production CSS - no build step required */

:root {
  --brand-primary: #128C7E;
  --brand-secondary: #25D366;
  --brand-accent: #34B7F1;
  --wa-teal: #128C7E;
  --wa-green: #25D366;
  --wa-blue: #34B7F1;
  --wa-dark: #075E54;
  --wa-teal-dark: #0b141a;
  --wa-panel: #111b21;
  --wa-panel-header: #202c33;
  --wa-chat-bg: #0b141a;
  --wa-incoming: #202c33;
  --wa-outgoing: #005c4b;
  --wa-text: #e9edef;
  --wa-text-secondary: #8696a0;
  --wa-border: #2a3942;
  --wa-hover: #202c33;
  --wa-input: #2a3942;
  --wa-danger: #ea4335;
  --wa-warning: #f59e0b;
  --wa-success: #25D366;

  /* Light mode defaults for public pages */
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --text: #111b21;
  --text-muted: #667781;
  --border: #e9edef;
  --shadow: 0 1px 3px rgba(11,20,26,.08), 0 4px 12px rgba(11,20,26,.04);
  --shadow-lg: 0 8px 30px rgba(11,20,26,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --nav-height: 60px;
  --header-height: 60px;
  --bottom-nav-height: 64px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b141a;
  --bg-card: #111b21;
  --bg-elevated: #202c33;
  --text: #e9edef;
  --text-muted: #8696a0;
  --border: #2a3942;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.4);
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: none; opacity: 0.9; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }

/* ========== Utilities ========== */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.container-sm { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.container-lg { max-width: 1400px; margin: 0 auto; padding: 0 16px; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-primary { color: var(--brand-primary); }
.text-success { color: var(--wa-success); }
.text-danger { color: var(--wa-danger); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-8 { padding-top: 32px; padding-bottom: 32px; }
.py-12 { padding-top: 48px; padding-bottom: 48px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; min-height: 100dvh; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius); }
.rounded-full { border-radius: var(--radius-full); }
.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9375rem;
  transition: all var(--transition);
  border: 2px solid transparent;
  line-height: 1.25;
  white-space: nowrap;
  cursor: pointer;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--brand-primary);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary {
  background: var(--brand-secondary);
  color: #fff;
}
.btn-outline {
  background: transparent;
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}
.btn-outline:hover { background: var(--brand-primary); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-danger { background: var(--wa-danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-lg { padding: 14px 28px; font-size: 1.0625rem; }
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon.btn-sm { width: 32px; height: 32px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.15);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--wa-danger); margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: 18px; height: 18px; accent-color: var(--brand-primary); }

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ========== Avatar ========== */
.avatar {
  width: 48px; height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--brand-primary);
}
.avatar-sm { width: 36px; height: 36px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 96px; height: 96px; }
.avatar-xs { width: 28px; height: 28px; }

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-success { background: rgba(37, 211, 102, 0.15); color: #128C7E; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.badge-danger { background: rgba(234, 67, 53, 0.15); color: #c5221f; }
.badge-info { background: rgba(52, 183, 241, 0.15); color: #0284c7; }
.badge-primary { background: rgba(18, 140, 126, 0.15); color: var(--brand-primary); }
.badge-locked { background: rgba(134, 150, 160, 0.2); color: var(--text-muted); }

/* ========== Progress ========== */
.progress {
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--brand-secondary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.progress-lg { height: 8px; }
.progress-circle {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.625rem; font-weight: 700;
  background: conic-gradient(var(--brand-secondary) calc(var(--pct, 0) * 1%), var(--border) 0);
  position: relative;
}
.progress-circle::before {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--bg-card);
  border-radius: 50%;
}
.progress-circle span { position: relative; z-index: 1; color: var(--text); }

/* ========== Alerts / Flash ========== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.875rem;
}
.alert-success { background: rgba(37, 211, 102, 0.12); color: #0d7a4f; border: 1px solid rgba(37, 211, 102, 0.3); }
.alert-error { background: rgba(234, 67, 53, 0.1); color: #c5221f; border: 1px solid rgba(234, 67, 53, 0.25); }
.alert-info { background: rgba(52, 183, 241, 0.1); color: #0369a1; border: 1px solid rgba(52, 183, 241, 0.25); }
.alert-warning { background: rgba(245, 158, 11, 0.1); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.25); }

/* ========== Modal ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 20, 26, 0.7);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  backdrop-filter: blur(4px);
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { transform: translateY(0); }
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal {
    border-radius: var(--radius);
    transform: translateY(20px) scale(0.95);
  }
  .modal-overlay.open .modal { transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0;
  background: var(--bg-card);
  z-index: 1;
}
.modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  position: sticky; bottom: 0;
  background: var(--bg-card);
}

/* ========== WhatsApp Chat List (Course List) ========== */
.chat-app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--wa-chat-bg);
  color: var(--wa-text);
}

.chat-sidebar {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--wa-panel);
  border-right: 1px solid var(--wa-border);
}
@media (min-width: 768px) {
  .chat-sidebar { width: 400px; max-width: 40%; min-width: 320px; }
}

.chat-header {
  height: var(--header-height);
  background: var(--wa-panel-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}
.chat-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--wa-text);
}
.chat-header-actions { display: flex; gap: 4px; }
.chat-header-actions button,
.chat-header-actions a {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--wa-text-secondary);
  transition: background var(--transition);
}
.chat-header-actions button:hover,
.chat-header-actions a:hover { background: var(--wa-hover); color: var(--wa-text); }

.chat-search {
  padding: 8px 12px;
  background: var(--wa-panel);
}
.chat-search-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--wa-input);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}
.chat-search-inner svg { color: var(--wa-text-secondary); flex-shrink: 0; }
.chat-search-inner input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--wa-text);
  font-size: 0.9375rem;
}
.chat-search-inner input::placeholder { color: var(--wa-text-secondary); }

.chat-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-list::-webkit-scrollbar { width: 6px; }
.chat-list::-webkit-scrollbar-thumb { background: var(--wa-border); border-radius: 3px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid transparent;
  position: relative;
  text-decoration: none;
  color: inherit;
}
.chat-item:hover { background: var(--wa-hover); }
.chat-item.active { background: var(--wa-hover); }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}
.chat-item-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--wa-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item-time {
  font-size: 0.75rem;
  color: var(--wa-text-secondary);
  flex-shrink: 0;
  margin-left: 8px;
}
.chat-item-time.unread { color: var(--brand-secondary); }
.chat-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.chat-item-preview {
  font-size: 0.8125rem;
  color: var(--wa-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.chat-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.chat-unread {
  background: var(--brand-secondary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* ========== Chat / Learning View ========== */
.chat-main {
  flex: 1;
  display: none;
  flex-direction: column;
  background: var(--wa-chat-bg);
  position: relative;
}
.chat-main.open { display: flex; }
@media (min-width: 768px) {
  .chat-main { display: flex; }
  .chat-main.empty-state { display: flex; }
}

.chat-main-header {
  height: var(--header-height);
  background: var(--wa-panel-header);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  flex-shrink: 0;
  z-index: 10;
}
.chat-back {
  display: flex;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  color: var(--wa-text);
  border-radius: 50%;
}
@media (min-width: 768px) {
  .chat-back { display: none; }
}
.chat-main-info { flex: 1; min-width: 0; }
.chat-main-info h2 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--wa-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-main-info p {
  font-size: 0.75rem;
  color: var(--wa-text-secondary);
}

/* Chat wallpaper */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 24px;
  background-color: #0b141a;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(18,140,126,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(37,211,102,0.02) 0%, transparent 40%);
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Message bubbles */
.msg {
  max-width: 85%;
  position: relative;
  animation: msgIn 0.25s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (min-width: 640px) {
  .msg { max-width: 65%; }
}
.msg-incoming {
  align-self: flex-start;
}
.msg-outgoing {
  align-self: flex-end;
}
.msg-bubble {
  padding: 8px 12px 6px;
  border-radius: 8px;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,.15);
}
.msg-incoming .msg-bubble {
  background: var(--wa-incoming);
  border-top-left-radius: 0;
  color: var(--wa-text);
}
.msg-outgoing .msg-bubble {
  background: var(--wa-outgoing);
  border-top-right-radius: 0;
  color: var(--wa-text);
}
.msg-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-secondary);
  margin-bottom: 2px;
}
.msg-text {
  font-size: 0.9rem;
  line-height: 1.45;
}
.msg-text p { margin-bottom: 0.5em; }
.msg-text p:last-child { margin-bottom: 0; }
.msg-text a { color: var(--brand-accent); text-decoration: underline; }
.msg-text code {
  background: rgba(0,0,0,.25);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}
.msg-text pre {
  background: rgba(0,0,0,.3);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 0.8125rem;
}
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  font-size: 0.6875rem;
  color: var(--wa-text-secondary);
}
.msg-image img {
  border-radius: 8px;
  max-width: 100%;
  cursor: pointer;
}
.msg-image .msg-bubble { padding: 4px; }
.msg-image .msg-caption {
  padding: 4px 8px;
  font-size: 0.8125rem;
}

/* Voice note player */
.voice-note {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 4px 0;
}
.voice-play {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--brand-secondary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition);
}
.voice-play:hover { transform: scale(1.05); }
.voice-play.playing { background: var(--brand-primary); }
.voice-wave {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.voice-wave span {
  width: 3px;
  background: var(--wa-text-secondary);
  border-radius: 2px;
  transition: height 0.1s, background 0.2s;
}
.voice-wave span.active { background: var(--brand-secondary); }
.voice-info { font-size: 0.75rem; color: var(--wa-text-secondary); }
.voice-speed {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--brand-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(37, 211, 102, 0.15);
  cursor: pointer;
  user-select: none;
}

/* Video block */
.msg-video video,
.msg-video iframe {
  width: 100%;
  border-radius: 8px;
  max-height: 280px;
  background: #000;
}
.msg-video .msg-bubble { padding: 4px; }

/* PDF / Download block */
.msg-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  min-width: 200px;
}
.msg-file-icon {
  width: 44px; height: 44px;
  border-radius: 8px;
  background: rgba(234, 67, 53, 0.15);
  color: #ea4335;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name { font-size: 0.875rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-size { font-size: 0.75rem; color: var(--wa-text-secondary); }

/* Callout */
.callout {
  border-left: 3px solid var(--brand-accent);
  padding: 10px 14px;
  background: rgba(52, 183, 241, 0.08);
  border-radius: 0 8px 8px 0;
  font-size: 0.875rem;
  margin: 4px 0;
}
.callout.warning { border-color: var(--wa-warning); background: rgba(245, 158, 11, 0.08); }
.callout.success { border-color: var(--brand-secondary); background: rgba(37, 211, 102, 0.08); }
.callout.tip { border-color: #a855f7; background: rgba(168, 85, 247, 0.08); }

/* Date separator */
.msg-date {
  align-self: center;
  background: var(--wa-panel-header);
  color: var(--wa-text-secondary);
  font-size: 0.75rem;
  padding: 5px 12px;
  border-radius: 8px;
  margin: 12px 0;
  box-shadow: 0 1px 1px rgba(0,0,0,.1);
}

/* Lesson complete bar */
.lesson-actions {
  background: var(--wa-panel-header);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-top: 1px solid var(--wa-border);
  flex-wrap: wrap;
}
.lesson-tools {
  display: flex;
  gap: 4px;
  margin-right: auto;
}
.lesson-tools button {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--wa-text-secondary);
}
.lesson-tools button:hover,
.lesson-tools button.active { background: var(--wa-hover); color: var(--brand-secondary); }

/* Empty state */
.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--wa-text-secondary);
}
.empty-chat-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--wa-panel-header);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  font-size: 2rem;
}
.empty-chat h3 { color: var(--wa-text); margin-bottom: 8px; }

/* FAB */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  right: 16px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--brand-secondary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
  z-index: 50;
  transition: transform var(--transition), box-shadow var(--transition);
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5); }
.fab:active { transform: scale(0.95); }

/* ========== Bottom Navigation ========== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--wa-panel-header);
  border-top: 1px solid var(--wa-border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--wa-text-secondary);
  font-size: 0.625rem;
  font-weight: 500;
  transition: color var(--transition);
  text-decoration: none;
}
.bottom-nav a.active { color: var(--brand-secondary); }
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  background: var(--wa-danger);
  color: #fff;
  font-size: 0.625rem;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* Student pages with bottom nav need padding */
.has-bottom-nav { padding-bottom: calc(var(--bottom-nav-height) + 16px); }

/* ========== Public / Landing ========== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
  display: flex;
  align-items: center;
}
[data-theme="dark"] .navbar {
  background: rgba(11, 20, 26, 0.9);
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}
.navbar-brand-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.1rem;
}
.navbar-nav {
  display: none;
  align-items: center;
  gap: 8px;
}
@media (min-width: 768px) {
  .navbar-nav { display: flex; }
}
.navbar-nav a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: all var(--transition);
}
.navbar-nav a:hover { color: var(--text); background: var(--border); }

.hero {
  padding: 60px 0 80px;
  background: linear-gradient(160deg, rgba(18,140,126,0.08) 0%, transparent 50%, rgba(37,211,102,0.05) 100%);
  overflow: hidden;
  position: relative;
}
.hero-grid {
  display: grid;
  gap: 40px;
  align-items: center;
}
@media (min-width: 900px) {
  .hero-grid { grid-template-columns: 1fr 1fr; }
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.hero h1 span { color: var(--brand-primary); }
.hero p {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-bottom: 28px;
  max-width: 480px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-mockup {
  background: var(--wa-panel);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--wa-border);
  max-width: 360px;
  margin: 0 auto;
}
.hero-mockup-header {
  background: var(--wa-panel-header);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--wa-text);
}
.hero-mockup-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 280px;
  background: var(--wa-chat-bg);
}
.hero-mockup .bubble {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8125rem;
  max-width: 80%;
  color: var(--wa-text);
}
.hero-mockup .bubble.in { background: var(--wa-incoming); align-self: flex-start; border-top-left-radius: 0; }
.hero-mockup .bubble.out { background: var(--wa-outgoing); align-self: flex-end; border-top-right-radius: 0; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (min-width: 768px) {
  .stats-row { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
  text-align: center;
  padding: 24px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand-primary);
  line-height: 1.2;
}
.stat-card .stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Course cards (public) */
.course-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 640px) {
  .course-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .course-grid { grid-template-columns: repeat(3, 1fr); }
}
.course-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.course-card-img {
  aspect-ratio: 16/9;
  object-fit: cover;
  width: 100%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
}
.course-card-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.course-card-cat {
  font-size: 0.75rem;
  color: var(--brand-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.course-card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
}
.course-card-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.course-price {
  font-weight: 700;
  color: var(--brand-primary);
  font-size: 1rem;
}
.course-price.free { color: var(--brand-secondary); }

/* Section */
.section { padding: 64px 0; }
.section-header {
  text-align: center;
  margin-bottom: 40px;
}
.section-header h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.section-header p { color: var(--text-muted); max-width: 520px; margin: 0 auto; }

/* FAQ */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--bg-card);
}
.faq-q {
  width: 100%;
  padding: 16px 20px;
  text-align: left;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  background: none;
  cursor: pointer;
}
.faq-a {
  padding: 0 20px 16px;
  color: var(--text-muted);
  font-size: 0.9375rem;
  display: none;
}
.faq-item.open .faq-a { display: block; }
.faq-item.open .faq-q svg { transform: rotate(180deg); }

/* Footer */
.footer {
  background: var(--wa-panel);
  color: var(--wa-text-secondary);
  padding: 48px 0 24px;
}
.footer a { color: var(--wa-text-secondary); }
.footer a:hover { color: var(--wa-text); }
.footer-grid {
  display: grid;
  gap: 32px;
  margin-bottom: 32px;
}
@media (min-width: 768px) {
  .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
}
.footer h4 { color: var(--wa-text); margin-bottom: 12px; font-size: 0.9375rem; }
.footer ul li { margin-bottom: 8px; font-size: 0.875rem; }
.footer-bottom {
  border-top: 1px solid var(--wa-border);
  padding-top: 20px;
  text-align: center;
  font-size: 0.8125rem;
}

/* ========== Admin Layout ========== */
.admin-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}
.admin-sidebar {
  width: 260px;
  background: var(--wa-panel);
  color: var(--wa-text);
  display: none;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
}
.admin-sidebar.open { display: flex; }
@media (min-width: 1024px) {
  .admin-sidebar { display: flex; }
}
.admin-sidebar-brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.125rem;
  border-bottom: 1px solid var(--wa-border);
}
.admin-nav { padding: 12px 8px; flex: 1; }
.admin-nav-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--wa-text-secondary);
  padding: 12px 12px 6px;
  font-weight: 600;
}
.admin-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--wa-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  margin-bottom: 2px;
}
.admin-nav a:hover { background: var(--wa-hover); color: var(--wa-text); }
.admin-nav a.active {
  background: rgba(18, 140, 126, 0.2);
  color: var(--brand-secondary);
}
.admin-nav a svg { width: 20px; height: 20px; flex-shrink: 0; }
.admin-main {
  flex: 1;
  margin-left: 0;
  min-width: 0;
}
@media (min-width: 1024px) {
  .admin-main { margin-left: 260px; }
}
.admin-topbar {
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
}
.admin-content { padding: 24px 20px; }
.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (min-width: 768px) {
  .admin-stats { grid-template-columns: repeat(4, 1fr); }
}
.admin-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.admin-stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 4px; }
.admin-stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); }
.admin-stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  font-size: 1.25rem;
}

/* Tables */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
table.data-table th {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tr:hover td { background: rgba(18, 140, 126, 0.04); }

/* ========== Auth pages ========== */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, rgba(18,140,126,0.1) 0%, var(--bg) 40%, rgba(37,211,102,0.06) 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 32px 28px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  margin-bottom: 12px;
}
.auth-logo h1 { font-size: 1.5rem; font-weight: 800; }
.auth-logo p { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }

/* ========== Quiz ========== */
.quiz-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px;
}
.quiz-question {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.quiz-question h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.4;
}
.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.quiz-option:hover { border-color: var(--brand-primary); background: rgba(18,140,126,0.04); }
.quiz-option.selected {
  border-color: var(--brand-primary);
  background: rgba(18,140,126,0.1);
}
.quiz-option.correct {
  border-color: var(--brand-secondary);
  background: rgba(37,211,102,0.1);
}
.quiz-option.wrong {
  border-color: var(--wa-danger);
  background: rgba(234,67,53,0.08);
}
.quiz-option input { accent-color: var(--brand-primary); }

/* ========== Notes panel ========== */
.notes-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 380px;
  background: var(--wa-panel);
  color: var(--wa-text);
  z-index: 300;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.3);
}
.notes-panel.open { transform: translateX(0); }
.notes-panel-header {
  padding: 16px;
  background: var(--wa-panel-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notes-panel textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--wa-text);
  padding: 16px;
  resize: none;
  outline: none;
  font-size: 0.9375rem;
  line-height: 1.6;
}
.notes-panel-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--wa-border);
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--wa-text-secondary);
}

/* ========== Lesson builder blocks ========== */
.block-list { display: flex; flex-direction: column; gap: 12px; }
.block-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  position: relative;
}
.block-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.block-type-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-primary);
  background: rgba(18,140,126,0.1);
  padding: 2px 8px;
  border-radius: 4px;
}
.block-actions { display: flex; gap: 4px; }
.block-actions button {
  width: 28px; height: 28px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.block-actions button:hover { background: var(--border); color: var(--text); }

/* Drag handle */
.drag-handle { cursor: grab; color: var(--text-muted); padding: 4px; }
.drag-handle:active { cursor: grabbing; }

/* ========== Skeleton loading ========== */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-elevated) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.2s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--wa-panel-header);
  color: var(--wa-text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  animation: toastIn 0.3s ease;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 10px;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ========== Locked lesson ========== */
.lesson-locked {
  opacity: 0.55;
  pointer-events: none;
}
.lesson-locked .chat-item-name::after {
  content: ' 🔒';
}

/* ========== Certificate preview ========== */
.cert-preview {
  border: 2px solid var(--brand-primary);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  background: #fff;
  color: #1a1a2e;
}

/* ========== Misc ========== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}
.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.page-subtitle { color: var(--text-muted); margin-bottom: 24px; font-size: 0.9375rem; }

/* Mobile menu overlay */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
  display: none;
}
.sidebar-overlay.open { display: block; }

/* PWA safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
}

/* Print */
@media print {
  .bottom-nav, .fab, .admin-sidebar, .chat-header-actions, .no-print { display: none !important; }
}

/* Smooth theme transition */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color 0.3s ease, color 0.2s ease, border-color 0.2s ease !important;
}
