/* Hệ thống Tokens Thiết kế (CSS :root Variables) */
:root {
  /* Colors - Semantic & Premium */
  --color-primary: #4F46E5; /* Indigo */
  --color-primary-hover: #4338CA;
  
  --color-success: #10B981; /* Xanh - Đạt, Hoàn thành */
  --color-warning: #F59E0B; /* Vàng - Cần ôn tập, Đang làm */
  --color-danger: #EF4444;  /* Đỏ - Trễ hạn, Cần chú ý */
  
  --color-surface: #FFFFFF;
  --color-background: #F3F4F6;
  --color-text-main: #111827;
  --color-text-muted: #6B7280;
  --color-border: #E5E7EB;

  /* Typography */
  --font-family: 'Inter', sans-serif;
  
  /* Layout & Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  
  --sidebar-width: 260px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--color-background);
  color: var(--color-text-main);
  line-height: 1.5;
}

/* Typography Utilities */
h1, h2, h3 {
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
}

.text-muted {
  color: var(--color-text-muted);
}

.text-center {
  text-align: center;
}

/* Visibility Utilities */
.hidden {
  display: none !important;
}

/* Margin Utilities */
.mt-md {
  margin-top: var(--spacing-md);
}

/* Layout Container */
.layout-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-nav {
  flex: 1;
  padding: var(--spacing-md) 0;
}

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav a {
  display: block;
  padding: var(--spacing-sm) var(--spacing-lg);
  color: var(--color-text-main);
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.2s;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
  background-color: var(--color-background);
  color: var(--color-primary);
  border-right: 4px solid var(--color-primary);
}

.sidebar-footer {
  padding: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
}

.user-profile {
  display: flex;
  flex-direction: column;
}

#user-name {
  font-weight: 600;
}

/* --- Header & Navigation Responsive --- */
.tab-link {
  text-decoration: none;
  color: var(--color-text-main);
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s ease;
  font-weight: 500;
}

.tab-link:hover {
  background: var(--color-background);
}

.tab-link.active {
  color: var(--color-primary);
  background: rgba(79, 70, 229, 0.1);
}

.mobile-menu-link {
  text-decoration: none;
  color: var(--color-text-main);
  padding: 12px;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
}

.mobile-menu-link.active {
  color: var(--color-primary);
  background: rgba(79, 70, 229, 0.1);
}

#app-header {
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
  padding: var(--spacing-sm) var(--spacing-lg);
  background: transparent;
  z-index: 100;
  pointer-events: none;
  box-shadow: none;
}

#mobile-menu-btn {
  position: absolute;
  top: 32px; 
  left: 20px;
  z-index: 101;
  pointer-events: auto;
}

#top-nav {
  display: none !important;
}

#desktop-user-header {
  display: none !important;
}

.main-content {
  padding: var(--spacing-lg) !important;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.view-section {
  display: none; /* Hide by default */
}

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

/* UI Components */
.card {
  background-color: var(--color-surface);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-lg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-md);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
  font-size: 0.95rem;
}

.btn:active {
  transform: scale(0.96);
}

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

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

.btn-large {
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: 1.1rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px var(--spacing-sm);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success {
  background-color: #D1FAE5;
  color: #065F46;
}

.badge-warning {
  background-color: #FEF3C7;
  color: #92400E;
}

.badge-danger {
  background-color: #FEE2E2;
  color: #991B1B;
}

/* Health Bar */
.health-bar-container {
  width: 100%;
  height: 12px;
  background-color: var(--color-border);
  border-radius: 9999px;
  overflow: hidden;
  margin: var(--spacing-sm) 0;
}

.health-bar-fill {
  height: 100%;
  background-color: var(--color-success);
  transition: width 0.5s ease-out;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Responsive Rules for Mobile */
@media (max-width: 992px) {
  .layout-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  
  .sidebar-nav ul {
    display: flex;
    overflow-x: auto;
  }
  
  .sidebar-nav a {
    white-space: nowrap;
    border-right: none;
    border-bottom: 4px solid transparent;
  }
  
  .sidebar-nav a:hover, .sidebar-nav a.active {
    border-right: none;
    border-bottom: 4px solid var(--color-primary);
  }
}

/* =========================================
   ANIMATIONS & MICRO-INTERACTIONS
   ========================================= */

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-5px); }
}

@keyframes bounceIn {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}

.anim-fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

.anim-shake {
  animation: shake 0.4s ease-in-out;
}

.anim-bounce {
  animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.custom-alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.2s ease;
}

.mcq-option:hover, .match-pair-option:hover {
  background: var(--color-background) !important;
  border-color: var(--color-primary) !important;
}

.option-tile {
  background-color: var(--color-surface);
  color: var(--color-text-main);
  font-size: 1.1rem;
  font-weight: 500;
  padding: var(--spacing-md);
  border-radius: var(--border-radius-md);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  border: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  text-align: center;
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.2s;
  width: 100%;
}

.option-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
  border-color: var(--color-primary);
}

.option-tile:active {
  transform: scale(0.98);
}

.anagram-tile {
  background-color: var(--color-surface);
  color: var(--color-warning);
  font-size: 1.5rem;
  font-weight: 600;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-md);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.anagram-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}
.anagram-tile:active {
  transform: scale(0.95);
}

/* Toggle Switch */
.slider {
  background-color: #ccc;
}
.switch input:checked + .slider {
  background-color: var(--color-success);
}
.switch input:focus + .slider {
  box-shadow: 0 0 1px var(--color-success);
}
.switch input:checked + .slider:before {
  transform: translateX(22px);
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
