/* =============================================================================
   kCHN - Nền tảng Học tiếng Trung & Quản trị Thông minh
   Design Language: Hiện đại, Trang nhã, Đậm nét văn hóa Hán ngữ
   ============================================================================= */

:root {
  --primary: #c2410c;         /* Đỏ cam Chu Sa truyền thống */
  --primary-hover: #9a3412;
  --primary-light: #ffedd5;
  --primary-dark: #7c2d12;
  
  --chinese-red: #dc2626;     /* Đỏ son may mắn */
  --chinese-gold: #d97706;    /* Vàng hoàng gia */
  --chinese-jade: #059669;    /* Ngọc bích thanh nhã */
  --chinese-blue: #2563eb;    /* Lam thanh vân */

  --secondary: #475569;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0284c7;
  --info-light: #e0f2fe;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

/* =============================================================================
   Header & Navbar (Public / Marketing & Học tập)
   ============================================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  height: 60px;
}

.nav-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary);
  flex-shrink: 0;
  text-decoration: none !important;
}

.brand-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--chinese-red), var(--primary));
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
  flex-shrink: 0;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: nowrap;
}

.nav-menu li {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 38px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  border-radius: 8px;
  transition: all 0.15s ease;
  white-space: nowrap !important;
  text-decoration: none !important;
  box-sizing: border-box;
}

.nav-link i {
  font-size: 0.95rem;
  opacity: 0.85;
}

.nav-link:hover {
  color: var(--primary);
  background: rgba(194, 65, 12, 0.08);
}

.nav-link.active {
  color: var(--primary);
  background: #ffedd5;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(194, 65, 12, 0.25);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  white-space: nowrap !important;
  box-sizing: border-box;
  border: 1px solid var(--border-color);
  background: #fff;
  color: #334155 !important;
  text-decoration: none !important;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.nav-btn-admin {
  border-color: #fecaca;
  color: #b91c1c !important;
  background: #fef2f2;
}

.nav-btn-admin:hover {
  background: #fee2e2;
  border-color: #f87171;
  color: #991b1b !important;
}

.nav-btn-icon {
  width: 38px;
  padding: 0;
}

/* =============================================================================
   Buttons & Badges
   ============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--chinese-red));
  color: #fff !important;
  box-shadow: 0 4px 10px rgba(194, 65, 12, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #b91c1c);
  box-shadow: 0 6px 14px rgba(194, 65, 12, 0.35);
}

.btn-secondary {
  background: #fff;
  color: #334155 !important;
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff !important;
  box-shadow: 0 4px 10px rgba(217, 119, 6, 0.3);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 13px 26px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-red { background: #fee2e2; color: #dc2626; }
.badge-gold { background: #fef3c7; color: #b45309; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }

/* =============================================================================
   Hero Banner & Section Styles
   ============================================================================= */
.hero-section {
  background: radial-gradient(circle at 80% 20%, #ffedd5 0%, #fff7ed 40%, #f8fafc 100%);
  padding: 70px 20px;
  border-bottom: 1px solid var(--border-color);
}

.hero-content {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 40px;
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.2;
  color: #0f172a;
  margin-bottom: 18px;
}

.hero-title span {
  color: var(--primary);
  background: linear-gradient(135deg, var(--chinese-red), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.1rem;
  line-height: 1.6;
  color: #475569;
  margin-bottom: 30px;
}

.hero-stats {
  display: flex;
  gap: 30px;
  margin-top: 35px;
  padding-top: 25px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.stat-item h4 {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--chinese-red);
}

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

/* Speaker button for Chinese speech pronunciation */
.btn-speak {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}
.btn-speak:hover {
  background: var(--primary-light);
  transform: scale(1.15);
}

/* =============================================================================
   Card Grid & Cards
   ============================================================================= */
.section-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 60px 20px;
  width: 100%;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 35px;
}

.section-title {
  font-size: 1.9rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

/* =============================================================================
   3D Flashcard Module (Học từ vựng thông minh)
   ============================================================================= */
.flashcard-stage {
  perspective: 1200px;
  max-width: 600px;
  margin: 0 auto 30px;
}

.flashcard {
  width: 100%;
  min-height: 340px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.flashcard.is-flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  box-sizing: border-box;
  background: #ffffff;
  border: 2px solid #fed7aa;
}

.flashcard-front {
  background: linear-gradient(135deg, #ffffff 0%, #fff7ed 100%);
}

.flashcard-back {
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
  transform: rotateY(180deg);
  border-color: #bbf7d0;
}

.hanzi-big {
  font-size: 5rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 12px;
  line-height: 1;
}

.pinyin-text {
  font-size: 1.6rem;
  font-weight: 600;
  color: #ea580c;
  margin-bottom: 15px;
}

.meaning-text {
  font-size: 1.8rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 10px;
}

/* =============================================================================
   Wayground / Quizizz Style Gamified Quiz Arena
   ============================================================================= */
.quiz-arena {
  max-width: 860px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.quiz-arena-header {
  background: #0f172a;
  color: #fff;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quiz-timer-bar-wrap {
  width: 100%;
  height: 8px;
  background: #334155;
  overflow: hidden;
}

.quiz-timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
  transition: width 1s linear;
}

.streak-badge {
  background: linear-gradient(135deg, #ea580c, #dc2626);
  color: #fff;
  padding: 6px 14px;
  border-radius: 9999px;
  font-weight: 800;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 8px rgba(234, 88, 12, 0.4);
}

.quiz-question-box {
  padding: 40px 30px;
  text-align: center;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
}

.quiz-question-text {
  font-size: 1.7rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 12px;
}

.quiz-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 30px;
}

.quiz-option-card {
  padding: 24px 20px;
  border-radius: var(--radius-md);
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 14px;
  user-select: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.quiz-option-card:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.quiz-option-card:active {
  transform: translateY(1px);
}

/* 4 Gamified Wayground Colors */
.opt-red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.opt-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.opt-yellow { background: linear-gradient(135deg, #f59e0b, #d97706); }
.opt-green { background: linear-gradient(135deg, #10b981, #059669); }

.quiz-option-card.correct {
  animation: pulse-correct 0.5s;
  box-shadow: 0 0 0 4px #22c55e;
}
.quiz-option-card.wrong {
  animation: shake-wrong 0.4s;
  opacity: 0.6;
}

@keyframes pulse-correct {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

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

/* =============================================================================
   Admin Portal Layout & Sidebar
   ============================================================================= */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.admin-sidebar-header {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-sidebar-nav {
  padding: 16px 10px;
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.admin-nav-section-title {
  padding: 12px 14px 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.admin-nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  margin-bottom: 3px;
}

.admin-nav-item a:hover, .admin-nav-item a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.admin-nav-item a.active {
  background: var(--primary);
  color: #fff;
}

.admin-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  background: var(--bg-main);
  padding: 30px;
  min-height: 100vh;
}

/* Data Tables */
.table-wrap {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

.data-table tr:hover td {
  background: #f8fafc;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 28px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.92rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.15);
}

/* Responsive */
@media (max-width: 900px) {
  .hero-content {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .hero-stats {
    justify-content: center;
  }
  .admin-sidebar {
    display: none;
  }
  .admin-main {
    margin-left: 0;
  }
  .quiz-options-grid {
    grid-template-columns: 1fr;
  }
}
