/* ==========================================================================
   CRAFT DESIGN SYSTEM - MODERN EDITORIAL LMS
   Palette: Deep Slate / Obsidian with Warm Amber & Emerald Accents
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Surface & Canvas */
  --bg-canvas: #090d16;
  --bg-canvas-rgb: 9, 13, 22;
  --bg-surface: #101624;
  --bg-card: #151d30;
  --bg-card-hover: #1b253d;
  --bg-card-active: #202c48;
  --bg-elevated: #1e2942;
  
  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(245, 158, 11, 0.3);
  --border-emerald: rgba(16, 185, 129, 0.3);
  
  /* Brand Accents */
  --amber-primary: #f59e0b;
  --amber-hover: #d97706;
  --amber-light: #fbbf24;
  --amber-glow: rgba(245, 158, 11, 0.16);
  --amber-border: rgba(245, 158, 11, 0.3);

  --emerald-primary: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.15);
  --emerald-hover: #059669;

  --indigo-primary: #6366f1;
  --rose-primary: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.15);

  /* Typography */
  --text-white: #ffffff;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dark: #0f172a;

  /* Font Families */
  --font-sans: 'Plus Jakarta Sans', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacings */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
  --shadow-elevated: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
  --shadow-amber: 0 0 25px rgba(245, 158, 11, 0.22);
}

/* Base Reset & Norms */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-canvas);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Links */
a {
  color: inherit;
  text-decoration: none;
  transition: color 0.18s ease;
}

/* Layout Container */
.container {
  width: 100%;
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.container-wide {
  width: 100%;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* Top Demo Bar (1-Click Role Switcher) */
.demo-bar {
  background: #060910;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  z-index: 100;
}

.demo-bar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.demo-bar-badge {
  background: var(--amber-glow);
  color: var(--amber-light);
  border: 1px solid var(--amber-border);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.demo-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.demo-pill {
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.demo-pill:hover, .demo-pill.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-white);
  border-color: rgba(255, 255, 255, 0.25);
}

.demo-pill.active {
  border-color: var(--amber-primary);
  color: var(--amber-light);
  background: var(--amber-glow);
}

/* Navigation Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(9, 13, 22, 0.88);
  border-bottom: 1px solid var(--border-subtle);
  transition: border-color 0.2s ease;
}

.site-nav {
  height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text-white);
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #090d16;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.brand-name span {
  color: var(--amber-primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav-link {
  font-size: 0.925rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.18s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-white);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--amber-primary);
  color: #090d16;
  border-color: var(--amber-primary);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.25);
}

.btn-primary:hover {
  background: var(--amber-light);
  border-color: var(--amber-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
  color: #090d16;
}

.btn-emerald {
  background: var(--emerald-primary);
  color: #090d16;
  border-color: var(--emerald-primary);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.25);
}

.btn-emerald:hover {
  background: #34d399;
  border-color: #34d399;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
  color: #090d16;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text-white);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.38rem 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  font-size: 1.05rem;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-lg);
}

.btn-full {
  width: 100%;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.badge-amber {
  background: var(--amber-glow);
  color: var(--amber-light);
  border: 1px solid var(--amber-border);
}

.badge-emerald {
  background: var(--emerald-glow);
  color: #34d399;
  border: 1px solid var(--border-emerald);
}

.badge-subtle {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-rose {
  background: var(--rose-glow);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

/* Cards */
.craft-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-card);
}

.craft-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-3px);
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.55);
}

/* Hero Section */
.hero-editorial {
  position: relative;
  padding: 5.5rem 0 4.5rem;
  overflow: hidden;
  background-image: 
    radial-gradient(ellipse 60% 50% at 50% -10%, rgba(245, 158, 11, 0.12), transparent 75%),
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.035) 1px, transparent 0);
  background-size: 100% 100%, 28px 28px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.95rem;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  color: var(--amber-light);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.hero-title {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-white);
  max-width: 900px;
  margin-bottom: 1.5rem;
}

.hero-title em {
  font-style: normal;
  color: var(--amber-primary);
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-description {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 680px;
  margin-bottom: 2.25rem;
  font-weight: 400;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 3.5rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  max-width: 820px;
}

.stat-item-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-white);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.stat-item-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Course Grid */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 2rem;
}

.course-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.course-card-thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

.course-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.course-card:hover .course-card-thumb {
  transform: scale(1.04);
}

.course-card-level-badge {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 2;
}

.course-card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.course-card-cat {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--amber-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.course-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.35;
  margin-bottom: 0.75rem;
  transition: color 0.18s ease;
}

.course-card:hover .course-card-title {
  color: var(--amber-light);
}

.course-card-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 1.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.course-card-instructor {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.course-card-avatar {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.course-card-footer {
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.course-price-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.course-price-current {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-white);
}

.course-price-free {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--emerald-primary);
}

.course-price-old {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: line-through;
}

/* Category Filter Tabs */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.filter-pill {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.filter-pill:hover, .filter-pill.active {
  background: rgba(245, 158, 11, 0.1);
  color: var(--amber-light);
  border-color: var(--amber-border);
}

/* Search Input */
.search-input-wrap {
  position: relative;
  min-width: 280px;
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 1rem 0.55rem 2.25rem;
  color: var(--text-white);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  border-color: var(--amber-primary);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.45rem;
}

.form-control {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.7rem 1rem;
  color: var(--text-white);
  font-size: 0.925rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--amber-primary);
  background: rgba(0, 0, 0, 0.35);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Alert Boxes */
.alert {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid var(--border-emerald);
  color: #34d399;
}

.alert-error {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

/* Footer */
.site-footer {
  margin-top: auto;
  background: #060910;
  border-top: 1px solid var(--border-subtle);
  padding: 3.5rem 0 2rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-top {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-brand p {
  margin-top: 1rem;
  max-width: 320px;
  line-height: 1.6;
}

.footer-heading {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-white);
  margin-bottom: 1rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
}

/* User Menu Dropdown */
.user-menu {
  position: relative;
}

.user-avatar-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.75rem 0.35rem 0.4rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-white);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.user-avatar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-medium);
}

.user-avatar-img {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  z-index: 100;
}

.dropdown-menu.show {
  display: flex;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-white);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.35rem 0;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
  .footer-top {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
  .nav-links {
    display: none;
  }
}

@media (max-width: 640px) {
  .footer-top {
    grid-template-columns: 1fr;
  }
  .courses-grid {
    grid-template-columns: 1fr;
  }
  .demo-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}
