/* ==========================================================================
   KRU CHAYANAT EDTECH - DESIGN SYSTEM & STYLESHEET
   Modern Education Platform for High School Students
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Bai+Jamjuree:wght@300;400;500;600;700&family=Kanit:wght@300;400;500;600;700&display=swap');

:root {
  /* Primary Palette */
  --primary-50: #eefbff;
  --primary-100: #d8f5ff;
  --primary-200: #b9edff;
  --primary-300: #89e2ff;
  --primary-400: #4ecfef;
  --primary-500: #00b4d8;
  --primary-600: #0087b8;
  --primary-700: #0077b6;
  --primary-800: #03045e;
  --primary-900: #070a29;

  /* Secondary & Accent Palette */
  --accent-gold: #ffb703;
  --accent-gold-light: #fff3d1;
  --accent-purple: #8a2be2;
  --accent-purple-light: #f1e6ff;
  --accent-orange: #fb8500;
  --accent-green: #06d6a0;
  --accent-green-light: #e6f9f4;
  --accent-pink: #ff4d6d;

  /* State & Feedback Colors */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #3b82f6;

  /* Dark Theme / Ambient Neutrals (Default) */
  --bg-main: #0b132b;
  --bg-card: rgba(27, 38, 59, 0.75);
  --bg-card-hover: rgba(35, 50, 77, 0.9);
  --bg-glass: rgba(15, 23, 42, 0.75);
  --bg-glass-border: rgba(255, 255, 255, 0.12);
  --bg-glass-light: rgba(255, 255, 255, 0.05);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-dark: #0f172a;

  /* Layout & Spacing */
  --sidebar-width: 280px;
  --header-height: 72px;
  --mobile-nav-height: 64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Shadows & Glows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
  --glow-cyan: 0 0 25px rgba(0, 180, 216, 0.4);
  --glow-gold: 0 0 25px rgba(255, 183, 3, 0.4);
  --glow-purple: 0 0 25px rgba(138, 43, 226, 0.4);

  /* Font Families */
  --font-heading: 'Kanit', sans-serif;
  --font-body: 'Bai Jamjuree', sans-serif;

  /* Transitions */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-main: #f0f4f8;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-glass: rgba(255, 255, 255, 0.85);
  --bg-glass-border: rgba(0, 180, 216, 0.2);
  --bg-glass-light: rgba(0, 0, 0, 0.04);

  --text-main: #0f172a;
  --text-muted: #334155;
  --text-dim: #64748b;
  --text-dark: #0f172a;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 180, 216, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(138, 43, 226, 0.1) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Typography Customization */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-main);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.15rem; }

p {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

a {
  color: var(--primary-500);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-600);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(11, 19, 43, 0.3);
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 180, 216, 0.4);
  border-radius: 4px;
}

/* App Layout Grid Structure */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* Sidebar Navigation */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--bg-glass-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--bg-glass-border);
}

.brand-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary-500), var(--accent-purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
  box-shadow: var(--glow-cyan);
  font-family: var(--font-heading);
  font-weight: 700;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--primary-500), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--accent-gold);
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 0.75rem 0.75rem 0.25rem;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.nav-item:hover {
  color: var(--text-main);
  background: var(--bg-glass-light);
  transform: translateX(4px);
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-700));
  border-color: rgba(0, 180, 216, 0.4);
  box-shadow: 0 4px 12px rgba(0, 180, 216, 0.3);
}

.nav-item .nav-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent-pink);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--bg-glass-border);
  background: var(--bg-glass-light);
}

.user-profile-mini {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-dark);
  font-size: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 0.72rem;
  color: var(--primary-500);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
}

/* Header Navbar */
.app-header {
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--bg-glass-border);
  position: sticky;
  top: 0;
  z-index: 90;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

.global-search-trigger {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-glass-light);
  border: 1px solid var(--bg-glass-border);
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 0.88rem;
  cursor: pointer;
  width: 280px;
  transition: all var(--transition-fast);
}

.global-search-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary-400);
  color: var(--text-main);
  box-shadow: 0 0 12px rgba(0, 180, 216, 0.2);
}

.search-shortcut {
  margin-left: auto;
  background: rgba(0, 0, 0, 0.15);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle-btn {
  background: var(--bg-glass-light);
  border: 1px solid var(--bg-glass-border);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: var(--primary-500);
  color: #fff;
}

.role-switcher-group {
  display: flex;
  background: rgba(0, 0, 0, 0.15);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--bg-glass-border);
}

.role-btn {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.role-btn.active {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.xp-streak-pill {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: rgba(255, 183, 3, 0.15);
  border: 1px solid rgba(255, 183, 3, 0.4);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
}

.pill-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.pill-xp { color: var(--accent-gold); }
.pill-streak { color: var(--accent-orange); }

/* Main Content Container */
.content-body {
  flex: 1;
  padding: 2rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* Page Views */
.page-view {
  display: none;
  animation: fadeIn var(--transition-normal) forwards;
}

.page-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 180, 216, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  transform: translateY(-2px);
  box-shadow: var(--glow-cyan);
}

.btn-secondary {
  background: var(--bg-glass-light);
  color: var(--text-main);
  border: 1px solid var(--bg-glass-border);
}

.btn-secondary:hover {
  background: rgba(0, 180, 216, 0.1);
  border-color: var(--primary-400);
  color: var(--primary-500);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
  color: var(--text-dark);
  box-shadow: var(--glow-gold);
}

.btn-accent:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

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

.btn-outline:hover {
  background: rgba(0, 180, 216, 0.15);
}

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

.btn-lg {
  padding: 0.9rem 2rem;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

/* Card Component */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-hover:hover {
  transform: translateY(-6px);
  background: var(--bg-card-hover);
  border-color: rgba(0, 180, 216, 0.35);
  box-shadow: var(--shadow-md);
}

/* Glassmorphism Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.2) 0%, rgba(138, 43, 226, 0.25) 100%), var(--bg-card);
  border: 1px solid rgba(0, 180, 216, 0.3);
  border-radius: var(--radius-xl);
  padding: 3.5rem 2.5rem;
  position: relative;
  overflow: hidden;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.hero-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(0, 180, 216, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  max-width: 650px;
  z-index: 2;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 180, 216, 0.15);
  border: 1px solid rgba(0, 180, 216, 0.35);
  color: var(--primary-500);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.hero-title {
  font-size: 2.75rem;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.hero-title span {
  background: linear-gradient(90deg, #00b4d8, #8a2be2, #ffb703);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-illustration {
  position: relative;
  width: 380px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-element {
  position: absolute;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-md);
  animation: float 4s ease-in-out infinite;
}

.float-1 { top: 10%; right: 5%; animation-delay: 0s; }
.float-2 { bottom: 15%; left: 0%; animation-delay: 1.5s; }
.float-3 { top: 45%; right: 40%; animation-delay: 0.8s; }

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-12px) rotate(2deg); }
}

/* Dashboard Specific Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.75rem;
  margin-bottom: 2rem;
}

.welcome-card {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.15), var(--bg-card));
  border: 1px solid rgba(0, 180, 216, 0.25);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.progress-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
}

.stat-card {
  background: var(--bg-glass-light);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: rgba(0, 180, 216, 0.2); color: var(--primary-500); }
.stat-icon.green { background: rgba(16, 185, 129, 0.2); color: var(--color-success); }
.stat-icon.gold { background: rgba(255, 183, 3, 0.2); color: var(--accent-gold); }
.stat-icon.purple { background: rgba(138, 43, 226, 0.2); color: var(--accent-purple); }

.stat-val {
  font-size: 1.35rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text-main);
}

.stat-lbl {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Circular & Linear Progress Bars */
.progress-circle-wrap {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--bg-glass-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1rem;
}

.circular-progress {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: conic-gradient(var(--primary-400) calc(var(--progress) * 1%), rgba(0, 0, 0, 0.1) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.circular-progress::before {
  content: '';
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-card);
}

.circular-value {
  position: relative;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
  font-family: var(--font-heading);
}

.progress-bar-container {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-300));
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Course Card Grid */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

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

.course-thumb {
  height: 170px;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  margin-bottom: 1.25rem;
}

.course-grade-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  color: var(--primary-300);
  border: 1px solid rgba(0, 180, 216, 0.3);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.course-title {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.course-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.course-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--bg-glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Lesson Viewer Layout */
.lesson-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.75rem;
  align-items: start;
}

.lesson-outline-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: sticky;
  top: calc(var(--header-height) + 1.5rem);
  max-height: calc(100vh - var(--header-height) - 3rem);
  overflow-y: auto;
}

.outline-title {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--bg-glass-border);
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.chapter-item:hover {
  background: var(--bg-glass-light);
  color: var(--text-main);
}

.chapter-item.active {
  background: rgba(0, 180, 216, 0.18);
  color: var(--text-main);
  border: 1px solid rgba(0, 180, 216, 0.4);
  font-weight: 600;
}

.chapter-status-icon {
  font-size: 1.1rem;
}

.status-completed { color: var(--color-success); }
.status-current { color: var(--accent-gold); }
.status-pending { color: var(--text-dim); }

.lesson-content-area {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.section-box {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.objective-card {
  background: linear-gradient(135deg, rgba(6, 214, 160, 0.1), var(--bg-card));
  border: 1px solid rgba(6, 214, 160, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.info-box {
  background: rgba(0, 180, 216, 0.08);
  border-left: 4px solid var(--primary-400);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
}

/* Accordion */
.accordion-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.accordion-item {
  background: var(--bg-glass-light);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.accordion-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
}

.accordion-content {
  padding: 0 1.25rem;
  max-height: 0;
  overflow: hidden;
  transition: all var(--transition-normal);
  color: var(--text-muted);
}

.accordion-item.open .accordion-content {
  padding: 1rem 1.25rem;
  max-height: 500px;
  border-top: 1px solid var(--bg-glass-border);
}

/* Flip Cards */
.flip-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.flip-card {
  background-color: transparent;
  height: 180px;
  perspective: 1000px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner,
.flip-card:hover .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bg-glass-border);
}

.flip-card-front {
  background: var(--bg-card);
  color: var(--text-main);
}

.flip-card-back {
  background: linear-gradient(135deg, var(--primary-700), var(--accent-purple));
  color: #fff;
  transform: rotateY(180deg);
}

/* Interactive Diagram */
.interactive-diagram {
  background: var(--bg-glass-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

.diagram-node {
  background: var(--bg-card);
  border: 1.5px solid var(--primary-500);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 130px;
}

.diagram-node:hover, .diagram-node.active {
  background: var(--primary-600);
  color: #fff;
  transform: scale(1.08);
}

.diagram-arrow {
  color: var(--primary-400);
  font-size: 1.5rem;
  font-weight: 700;
}

/* Video Player */
.video-player-wrap {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  position: relative;
  aspect-ratio: 16/9;
  box-shadow: var(--shadow-lg);
}

.video-player-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Quiz Interface */
.quiz-container {
  max-width: 800px;
  margin: 0 auto;
}

.quiz-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  background: var(--bg-glass);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-glass-border);
}

.quiz-timer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--accent-gold);
  font-size: 1.1rem;
}

.quiz-question-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.quiz-question-title {
  font-size: 1.35rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.quiz-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.quiz-option-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-glass-light);
  border: 1.5px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
}

.quiz-option-btn:hover {
  background: rgba(0, 180, 216, 0.12);
  border-color: var(--primary-400);
}

.quiz-option-btn.selected {
  background: rgba(0, 180, 216, 0.25);
  border-color: var(--primary-400);
  font-weight: 600;
}

.quiz-option-prefix {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.fill-blank-input {
  width: 100%;
  padding: 0.9rem 1.25rem;
  background: var(--bg-glass-light);
  border: 1.5px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 1rem;
  margin-top: 1rem;
}

/* Badges Showcase */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}

.badge-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all var(--transition-normal);
}

.badge-card.unlocked {
  border-color: rgba(255, 183, 3, 0.5);
  box-shadow: 0 0 20px rgba(255, 183, 3, 0.2);
}

.badge-card.locked {
  opacity: 0.5;
  filter: grayscale(0.8);
}

.badge-icon {
  font-size: 3.5rem;
  margin-bottom: 0.75rem;
  transition: transform var(--transition-bounce);
}

.badge-card:hover .badge-icon {
  transform: scale(1.2) rotate(6deg);
}

.badge-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

/* Reflection Section */
.reflection-box {
  background: linear-gradient(135deg, rgba(138, 43, 226, 0.12), var(--bg-card));
  border: 1px solid rgba(138, 43, 226, 0.3);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-top: 2rem;
}

.reflection-textarea {
  width: 100%;
  min-height: 120px;
  background: var(--bg-glass-light);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  resize: vertical;
  margin-bottom: 1rem;
}

/* Modal Overlay & Certificate Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(6, 11, 24, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  padding: 1.5rem;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-main);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: scale(0.92);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--bg-glass-border);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Certificate Paper Frame */
.certificate-frame {
  background: #ffffff;
  color: #0f172a;
  padding: 2.5rem;
  border: 8px double var(--primary-600);
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  position: relative;
}

.certificate-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  color: var(--primary-800);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.certificate-subtitle {
  font-size: 1rem;
  color: #475569;
  margin-bottom: 1.5rem;
}

.certificate-name {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--accent-purple);
  border-bottom: 2px solid var(--accent-gold);
  display: inline-block;
  padding: 0 1.5rem 0.25rem;
  margin: 1rem 0;
}

.certificate-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: var(--shadow-md);
  min-width: 280px;
  animation: slideInRight var(--transition-bounce) forwards;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-success { border-left: 4px solid var(--color-success); }
.toast-error { border-left: 4px solid var(--color-error); }
.toast-warning { border-left: 4px solid var(--color-warning); }
.toast-info { border-left: 4px solid var(--primary-400); }

/* Mobile Navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-height);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--bg-glass-border);
  z-index: 95;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
}

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

.app-footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--bg-glass-border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Admin Sub-Navigation Filter Tabs */
.admin-tab-nav {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-glass-light);
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-glass-border);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.admin-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.admin-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--bg-glass-border);
}

.admin-tab-btn.active {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.admin-tab-btn.tab-grade.active {
  background: var(--accent-purple);
  color: #ffffff;
}

.admin-tab-btn.tab-classroom.active {
  background: var(--accent-gold);
  color: #0f172a;
}

.admin-tab-btn.tab-student.active {
  background: var(--accent-green);
  color: #0f172a;
}

.admin-tab-btn.tab-teacher.active,
.admin-tab-btn.tab-settings.active {
  background: var(--primary-500);
  color: #ffffff;
}

.admin-tab-btn.tab-all.active {
  background: var(--primary-700);
  color: #ffffff;
}

.admin-sec-card {
  display: none;
}

.admin-sec-card.active {
  display: block;
}

/* Print Styles */
@media print {
  body * {
    visibility: hidden;
  }
  #certificate-modal, #certificate-modal * {
    visibility: visible;
  }
  #certificate-modal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: #fff;
  }
  .modal-header, .no-print {
    display: none !important;
  }
}

/* Responsive & Auto-Fitting Device Rules */
html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

.modal-card {
  max-width: min(92vw, 760px) !important;
  max-height: 90vh !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  margin: 1rem auto !important;
  padding: clamp(1rem, 3vw, 2rem) !important;
}

@media (max-width: 1024px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; width: 100%; max-width: 100vw; }
  .mobile-menu-toggle { display: block; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .lesson-layout { grid-template-columns: 1fr; }
  .hero-banner { flex-direction: column; text-align: center; padding: 2.5rem 1.5rem; }
}

@media (max-width: 768px) {
  .mobile-bottom-nav { display: flex; }
  .content-body { padding: 0.75rem; padding-bottom: calc(var(--mobile-nav-height) + 2rem); }
  .progress-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 0.85rem; margin-bottom: 1rem; }
  
  /* App Header Mobile Scaling Fix */
  .app-header {
    padding: 0 0.5rem !important;
    height: auto !important;
    min-height: 54px !important;
    gap: 0.35rem !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .header-left {
    gap: 0.35rem !important;
    flex: 1;
    min-width: 0;
  }

  .global-search-trigger {
    width: auto !important;
    max-width: 130px !important;
    padding: 0.35rem 0.6rem !important;
    font-size: 0.78rem !important;
  }

  .global-search-trigger .search-shortcut {
    display: none !important;
  }

  .header-right {
    gap: 0.25rem !important;
    flex-shrink: 0;
  }

  #theme-text {
    display: none !important;
  }

  .theme-toggle-btn {
    padding: 0.35rem 0.45rem !important;
  }

  .role-btn {
    padding: 0.25rem 0.45rem !important;
    font-size: 0.7rem !important;
  }

  .xp-streak-pill {
    padding: 0.2rem 0.4rem !important;
    font-size: 0.7rem !important;
  }

  .pill-item {
    gap: 0.2rem !important;
  }

  /* Flex wrap headers & toolbars */
  .admin-sec-card > div:first-child,
  .card-header,
  .filter-bar,
  .action-bar {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }
}

@media (max-width: 640px) {
  /* Convert multi-column modal forms into 1 column for clean mobile fit */
  form div[style*="grid-template-columns"],
  .modal-card div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* Make filter dropdowns and action buttons full width on small phones */
  #admin-student-classroom-filter,
  #student-work-course-filter,
  .fill-blank-input,
  .btn-sm {
    max-width: 100% !important;
  }

  .admin-tab-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.78rem;
  }

  table {
    font-size: 0.78rem !important;
  }
  
  th, td {
    padding: 0.45rem 0.35rem !important;
  }
}

@media (max-width: 480px) {
  .progress-summary-grid { grid-template-columns: 1fr; }
  .course-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 0.85rem !important; }
  
  .global-search-trigger span:nth-child(2) {
    display: none;
  }
}
