/* CSS Variables for Global Theming */
:root {
  --primary-color: #4facfe;
  --secondary-color: #00f2fe;
  --bg-color: #f6f8fd;
  --text-main: #2d3748;
  --text-muted: #718096;
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Sarabun', sans-serif;
}

body {
  background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  padding-bottom: 80px; /* Space for bottom nav */
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

html {
  scroll-behavior: smooth;
}

/* Loader Overlay */
#loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s;
}

.loader-logo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(79, 172, 254, 0.5);
  border: 4px solid white;
  animation: pulseLogo 1.5s infinite ease-in-out;
  margin-bottom: 20px;
  object-fit: cover;
}

@keyframes pulseLogo {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(79, 172, 254, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 20px rgba(79, 172, 254, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(79, 172, 254, 0); }
}

/* Main Application Container */
.app-container {
  width: 100%;
  max-width: 1200px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* Header Styling */
header {
  margin-top: 20px;
  text-align: center;
  padding: 30px 20px;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 30px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 20px rgba(79, 172, 254, 0.4);
  margin-bottom: 10px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.8);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-icon {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
  box-shadow: 0 8px 15px rgba(79, 172, 254, 0.4);
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
}

header h2 {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
}

/* Sections Container (Index) */
.dashboard-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

/* Section Styling */
.section {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 24px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.section-header i {
  font-size: 24px;
  background: -webkit-linear-gradient(45deg, #ff0844, #ffb199);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.section-header.lessons i { background: -webkit-linear-gradient(45deg, #4facfe, #00f2fe); -webkit-background-clip: text; }
.section-header.practice i { background: -webkit-linear-gradient(45deg, #f093fb, #f5576c); -webkit-background-clip: text; }
.section-header.tools i { background: -webkit-linear-gradient(45deg, #43e97b, #38f9d7); -webkit-background-clip: text; }
.section-header.system i { background: -webkit-linear-gradient(45deg, #fa709a, #fee140); -webkit-background-clip: text; }
.section-header.social i { background: -webkit-linear-gradient(45deg, #ff0844, #ffb199); -webkit-background-clip: text; }

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

/* Individual Card */
.card {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 20px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.card:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 12px 25px rgba(0,0,0,0.1);
}

.card-icon {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  margin-bottom: 5px;
}

/* Icon Gradients */
.bg-blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.bg-green { background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%); color: #2d3748; }
.bg-orange { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); }
.bg-pink { background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%); }
.bg-purple { background: linear-gradient(135deg, #c471f5 0%, #fa71cd 100%); }
.bg-yellow { background: linear-gradient(135deg, #fccb90 0%, #d57eeb 100%); }

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

/* Units (Lessons Pages) */
.unit {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 24px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  transition: all 0.3s ease;
}

.unit[open] {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
}

summary {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: '\f07b';
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: var(--primary-color);
  font-size: 20px;
  transition: transform 0.3s ease;
}

details[open] summary::after {
  content: '\f07c';
  transform: scale(1.1);
}

details[open] .worksheet {
  animation: expand 0.4s ease forwards;
}

@keyframes expand {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Worksheet Styling */
.worksheet {
  background: rgba(255, 255, 255, 0.6);
  padding: 18px;
  border-radius: 16px;
  margin-bottom: 15px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 10px rgba(0,0,0,0.02);
  margin-top: 15px; /* Added for spacing from summary */
}

.worksheet:last-child {
  margin-bottom: 0;
}

.worksheet h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #2c3e50;
  display: flex;
  align-items: center;
  gap: 8px;
}

.worksheet h3::before {
  content: '\f15c';
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: #4facfe;
}

.worksheet ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.worksheet ul li a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-main);
  text-decoration: none;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  font-weight: 500;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.worksheet ul li a i {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.worksheet ul li a:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transform: translateX(4px);
  border-color: rgba(255,255,255,0.3);
  box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.worksheet ul li a:hover i {
  color: white !important;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 400px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 30px;
  display: flex;
  justify-content: space-around;
  padding: 10px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  border: 1px solid var(--glass-border);
  z-index: 1000;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 20px;
  transition: all 0.3s ease;
  font-size: 12px;
  gap: 4px;
}

.nav-item i {
  font-size: 20px;
}

.nav-item.active {
  color: var(--primary-color);
  background: rgba(79, 172, 254, 0.15);
}

/* Responsive */
@media (max-width: 600px) {
  header { padding: 12px; margin-top: 5px; flex-direction: row; justify-content: center; align-items: center; border-radius: 16px; gap: 10px; }
  .header-icon { width: 32px; height: 32px; font-size: 16px; border-radius: 10px; }
  header h1 { font-size: 16px; margin: 0; }
  .section-title { font-size: 16px; }
  .card-icon { width: 40px; height: 40px; font-size: 20px; }
  .card { padding: 15px 12px; }
  summary { font-size: 16px; }
  .worksheet h3 { font-size: 15px; }
  .worksheet ul li a { font-size: 14px; padding: 10px 14px; }
}
