/* ============================================================
   MATERIAL DESIGN 3 — Android-style design system
   ============================================================ */

:root {
  /* ---- Color roles (M3) ---- */
  --md-primary: #4F46E5;
  --md-on-primary: #FFFFFF;
  --md-primary-container: #E4E1FF;
  --md-on-primary-container: #150477;

  --md-secondary: #5C5A72;
  --md-secondary-container: #E1DFF9;

  --md-surface: #FFFBFF;
  --md-surface-dim: #DED8E1;
  --md-surface-container-low: #F7F2FA;
  --md-surface-container: #F1ECF4;
  --md-surface-container-high: #EBE6EE;
  --md-on-surface: #1C1B1F;
  --md-on-surface-variant: #49454E;

  --md-background: #FBFAFF;
  --md-outline: #79747E;
  --md-outline-variant: #C9C5D0;

  --md-error: #BA1A1A;
  --md-error-container: #FFDAD6;
  --md-success: #146C2E;
  --md-success-container: #C4EED0;

  /* ---- Elevation (Material shadow tokens) ---- */
  --el-1: 0 1px 2px rgba(0,0,0,0.30), 0 1px 3px 1px rgba(0,0,0,0.15);
  --el-2: 0 1px 2px rgba(0,0,0,0.30), 0 2px 6px 2px rgba(0,0,0,0.15);
  --el-3: 0 1px 3px rgba(0,0,0,0.30), 0 4px 8px 3px rgba(0,0,0,0.15);

  /* ---- Shape scale ---- */
  --shape-xs: 8px;
  --shape-sm: 12px;
  --shape-md: 16px;
  --shape-lg: 20px;
  --shape-full: 100px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: 'Roboto', 'Segoe UI', sans-serif;
  background: var(--md-background);
  color: var(--md-on-surface);
}

body { padding-bottom: 84px; }

a { color: inherit; }

/* ============================================================
   TOP APP BAR
   ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--md-surface);
  padding: 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--el-1);
}
.app-header h1 {
  font-size: 22px; font-weight: 400; letter-spacing: 0;
  flex: 1;
}
.app-header .icon-btn {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--md-on-surface-variant);
  text-decoration: none; position: relative; overflow: hidden;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--md-outline-variant);
}

/* ============================================================
   BOTTOM NAVIGATION BAR (Material 3 style, pill indicator)
   ============================================================ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--md-surface-container);
  display: flex;
  z-index: 200;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 3px rgba(0,0,0,0.08);
}
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-decoration: none;
  color: var(--md-on-surface-variant);
  font-size: 12px; font-weight: 500;
  letter-spacing: .2px;
  padding: 4px 0;
}
.bottom-nav .nav-icon-wrap {
  width: 56px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--shape-full);
  transition: background .2s ease;
}
.bottom-nav a.active .nav-icon-wrap {
  background: var(--md-secondary-container);
}
.bottom-nav a.active { color: var(--md-on-surface); font-weight: 700; }
.bottom-nav .material-symbols-outlined { font-size: 22px; }
.bottom-nav a:not(.active) .material-symbols-outlined { font-variation-settings: 'FILL' 0; }
.bottom-nav a.active .material-symbols-outlined { font-variation-settings: 'FILL' 1; color: var(--md-primary); }

/* ============================================================
   BUTTONS (Material filled / outlined)
   ============================================================ */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; border-radius: var(--shape-full);
  background: var(--md-primary); color: var(--md-on-primary);
  border: none; font-size: 14px; font-weight: 600; letter-spacing: .3px;
  text-decoration: none; position: relative; overflow: hidden;
  box-shadow: var(--el-1);
}
.btn:active { box-shadow: none; }
.btn-outlined {
  background: transparent; color: var(--md-primary);
  border: 1px solid var(--md-outline); box-shadow: none;
}
.btn-danger { background: var(--md-error); color: #fff; }
.btn-text {
  background: transparent; color: var(--md-primary); box-shadow: none;
  width: auto; padding: 10px 16px;
}

/* ---- Ripple effect (applied via JS to .btn, .card-tap, nav items) ---- */
.ripple-wrap { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transform: scale(0);
  animation: ripple-anim .55s ease-out;
  pointer-events: none;
}
.ripple-dark { background: rgba(0,0,0,0.12); }
@keyframes ripple-anim {
  to { transform: scale(3); opacity: 0; }
}

/* ============================================================
   FORM FIELDS (Material outlined text field)
   ============================================================ */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--md-on-surface-variant); margin-bottom: 6px;
  letter-spacing: .2px;
}
input, select {
  width: 100%; padding: 14px 16px; border-radius: var(--shape-xs);
  border: 1px solid var(--md-outline-variant); margin-bottom: 4px;
  font-size: 15px; background: var(--md-surface); color: var(--md-on-surface);
  transition: border-color .15s ease;
}
input:focus, select:focus {
  outline: none; border: 2px solid var(--md-primary); padding: 13px 15px;
}
input:disabled { background: var(--md-surface-container); color: var(--md-on-surface-variant); }

.auth-wrap { max-width: 420px; margin: 0 auto; padding: 32px 24px; }
.auth-title { font-size: 26px; font-weight: 400; margin-bottom: 6px; }
.auth-sub { font-size: 14px; color: var(--md-on-surface-variant); margin-bottom: 28px; }

.error-msg {
  background: var(--md-error-container); color: #410E0B;
  padding: 12px 14px; border-radius: var(--shape-sm);
  font-size: 13px; margin-bottom: 16px;
}
.success-msg {
  background: var(--md-success-container); color: #002106;
  padding: 12px 14px; border-radius: var(--shape-sm);
  font-size: 13px; margin-bottom: 16px;
}

/* ============================================================
   SECTION TITLES
   ============================================================ */
.section-title {
  font-size: 16px; font-weight: 700; letter-spacing: .1px;
  margin: 20px 16px 12px; color: var(--md-on-surface);
}

/* ============================================================
   COURSE CARDS (Material elevated card)
   ============================================================ */
.course-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 4px 16px 16px;
}
.course-card {
  background: var(--md-surface-container-low);
  border-radius: var(--shape-md);
  overflow: hidden;
  box-shadow: var(--el-1);
  text-decoration: none;
  color: var(--md-on-surface);
  position: relative;
  transition: box-shadow .15s ease;
}
.course-card:active { box-shadow: none; }
.course-card img { width: 100%; height: 96px; object-fit: cover; display: block; background: var(--md-surface-dim); }
.course-card .body { padding: 12px; }
.course-card .title {
  font-size: 13px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.course-card .price { font-size: 13px; color: var(--md-primary); font-weight: 700; margin-top: 8px; }
.progress-bar { height: 6px; background: var(--md-surface-dim); border-radius: var(--shape-full); margin-top: 10px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--md-primary); border-radius: var(--shape-full); }

/* Order / list rows */
.list-card {
  background: var(--md-surface-container-low);
  border-radius: var(--shape-md);
  padding: 14px;
  margin-bottom: 12px;
  display: flex; gap: 12px; align-items: center;
  box-shadow: var(--el-1);
}

/* ============================================================
   MODULE / CHAPTER ACCORDION (Material Expansion Panel)
   ============================================================ */
.module {
  background: var(--md-surface-container-low);
  margin: 10px 16px;
  border-radius: var(--shape-md);
  overflow: hidden;
  box-shadow: var(--el-1);
}
.module-header {
  padding: 16px; font-weight: 600; font-size: 14.5px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
}
.module-header .chevron { transition: transform .25s ease; color: var(--md-on-surface-variant); }
.module.open .module-header .chevron { transform: rotate(180deg); }
.chapter-list {
  display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease;
}
.chapter-list > div { overflow: hidden; }
.module.open .chapter-list { grid-template-rows: 1fr; }
.chapter-list-inner { border-top: 1px solid var(--md-outline-variant); }
.chapter-item {
  padding: 13px 16px 13px 26px;
  display: flex; justify-content: space-between; align-items: center;
  text-decoration: none; color: var(--md-on-surface);
  border-bottom: 1px solid var(--md-outline-variant);
  font-size: 13.5px;
}
.chapter-item:last-child { border-bottom: none; }
.chapter-item .material-symbols-outlined { font-size: 18px; color: var(--md-on-surface-variant); }

/* ============================================================
   TOP TABS (Material 3 Tabs w/ colored indicator)
   ============================================================ */
.top-tabs {
  position: sticky; top: 0; z-index: 90;
  display: flex;
  background: var(--md-surface);
  box-shadow: var(--el-1);
}
.top-tabs button {
  flex: 1; border: none; background: transparent;
  padding: 16px 0 13px; font-size: 13.5px; font-weight: 600;
  color: var(--md-on-surface-variant); border-bottom: 3px solid transparent;
  position: relative; overflow: hidden;
}
.top-tabs button.active { color: var(--md-primary); border-bottom-color: var(--md-primary); }
.tab-panel { display: none; padding: 16px; animation: fade-in .2s ease; }
.tab-panel.active { display: block; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Lecture list item */
.lecture-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--md-surface-container-low);
  padding: 12px; border-radius: var(--shape-sm); margin-bottom: 10px;
  text-decoration: none; color: var(--md-on-surface);
  box-shadow: var(--el-1);
}
.lecture-item .thumb {
  width: 64px; height: 46px; border-radius: var(--shape-xs);
  object-fit: cover; background: var(--md-surface-dim);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lecture-item .meta { flex: 1; min-width: 0; }
.lecture-item .meta .name { font-size: 13.5px; font-weight: 600; }
.lecture-item .meta .dur { font-size: 11.5px; color: var(--md-on-surface-variant); margin-top: 2px; }
.lecture-item .play-icon {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--md-primary-container); color: var(--md-primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* Chip (status badges) */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--shape-full);
  font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
}
.chip-success { background: var(--md-success-container); color: var(--md-success); }
.chip-pending { background: #FFF3CD; color: #7A5B00; }
.chip-error { background: var(--md-error-container); color: var(--md-error); }
.chip-muted { background: var(--md-surface-container-high); color: var(--md-on-surface-variant); }

/* FAB */
.fab {
  position: fixed; right: 20px; bottom: 92px; z-index: 150;
  width: 56px; height: 56px; border-radius: var(--shape-md);
  background: var(--md-primary-container); color: var(--md-on-primary-container);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--el-3); border: none;
}

/* Empty state */
.empty-state { text-align: center; padding: 64px 24px; color: var(--md-on-surface-variant); }
.empty-state .material-symbols-outlined { font-size: 48px; opacity: .5; margin-bottom: 12px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }
