/* ===== SVG Icon System ===== */
.icon {
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
  vertical-align: -0.2em;
  flex-shrink: 0;
}
.nav-icon .icon {
  width: 22px;
  height: 22px;
  display: block;
}
.empty-icon .icon {
  width: 56px;
  height: 56px;
  display: block;
  margin: 0 auto;
  opacity: 0.45;
}
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 40px; height: 40px; }
.header-title-row { display: flex; align-items: center; gap: 8px; }

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* FIN AI Brand Colors */
  --primary:       #B51217;
  --primary-dark:  #8E1015;
  --primary-light: #D71920;
  --soft-red:      #FCE8E8;
  --charcoal:      #1F2937;

  /* Gradient */
  --gradient-fin: linear-gradient(135deg, #8E1015 0%, #B51217 45%, #D71920 100%);

  /* Neutrals */
  --text:       #1F2937;
  --text-muted: #6B7280;
  --bg:         #F3F4F6;
  --white:      #FFFFFF;
  --border:     #E5E7EB;

  /* Status */
  --danger:  #B51217;
  --warning: #D97706;
  --success: #059669;

  /* Radius — ขอบมน Premium */
  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  /* Shadow */
  --shadow:    0 2px 16px rgba(0, 0, 0, 0.08);
  --shadow-red: 0 4px 16px rgba(181, 18, 23, 0.25);
}

body {
  font-family: 'LINE Seed Sans TH', 'Prompt', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 88px;
}

/* ===== Loading Screen ===== */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 16px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--soft-red);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-screen p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== Header ===== */
.header {
  background: var(--gradient-fin);
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-red);
}

.header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

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

.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  object-fit: cover;
}

.header-name {
  font-size: 13px;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== User Profile Card ===== */
.profile-card {
  background: var(--white);
  margin: 16px;
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
}

.profile-info h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 4px;
}

.profile-info p {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Badge ===== */
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
}

.badge-student { background: var(--soft-red); color: var(--primary); }
.badge-admin   { background: #FEF3C7; color: #92400E; }
.badge-teacher { background: #DBEAFE; color: #1E40AF; }
.badge-staff   { background: #F3E8FF; color: #6B21A8; }

/* ===== Section ===== */
.section {
  padding: 0 16px;
  margin-bottom: 24px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== Course Card ===== */
.course-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.course-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.course-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-red);
}

.course-thumbnail {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--gradient-fin);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 40px;
}

.course-body {
  padding: 16px;
}

.course-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 6px;
  line-height: 1.4;
}

.course-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.course-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.course-price.paid::before {
  content: '฿';
  font-size: 13px;
  font-weight: 600;
}

.course-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-xl);
  background: var(--soft-red);
  color: var(--primary);
}

/* ===== Button ===== */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
  letter-spacing: 0.3px;
}

.btn:active {
  opacity: 0.85;
  transform: scale(0.99);
}

.btn-primary {
  background: var(--gradient-fin);
  color: var(--white);
  box-shadow: var(--shadow-red);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-danger {
  background: var(--primary);
  color: var(--white);
}

.btn-ghost {
  background: var(--soft-red);
  color: var(--primary);
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  gap: 4px;
  transition: color 0.15s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 22px;
  line-height: 1;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 52px;
  margin-bottom: 14px;
  opacity: 0.6;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
}

/* ===== Toast ===== */
#toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--charcoal);
  color: white;
  padding: 10px 22px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
  white-space: nowrap;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Info Row (ใช้ใน detail page) ===== */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); }
.info-value { font-weight: 600; color: var(--charcoal); }

/* ===== Divider ===== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ===== Utility ===== */
.hidden        { display: none !important; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mt-24         { margin-top: 24px; }
.text-center   { text-align: center; }
.text-muted    { color: var(--text-muted); font-size: 13px; }
.text-primary  { color: var(--primary); }
.text-bold     { font-weight: 700; }
.w-full        { width: 100%; }
