/* ===== VARIABLES ===== */
:root {
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-transition: all 0.3s ease;
  --edit-border: #ccc;
  --edit-bg: #f9f9f9;
  --edit-toolbar-bg: #eee;
  --edit-button-hover: #e0e0e0;
}

/* Light mode variables */
.light {
  --bg-primary: #ffffff;
  --bg-secondary: #f0f0f2; /* Đậm hơn một chút */
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0f2;
  --text-primary: #000000;
  --text-secondary: #666668; /* Đậm hơn để dễ đọc */
  --border-color: #d5d5d7; /* Đậm hơn */
  --nav-bg: rgba(255, 255, 255, 0.9); /* Đậm hơn */
  --hero-gradient: linear-gradient(180deg, #e5e5e7 0%, #ffffff 100%); /* Tăng tương phản */
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); /* Đậm hơn */
  --section-bg: linear-gradient(145deg, #e8e8ea, #ffffff); /* Tăng tương phản */
  --option-bg: rgba(0, 0, 0, 0.08); /* Đậm hơn */
  --option-hover: rgba(0, 0, 0, 0.15); /* Đậm hơn */
  --note-bg: rgba(0, 0, 0, 0.08); /* Đậm hơn */
  --table-header: rgba(0, 0, 0, 0.15); /* Đậm hơn */
  --table-row-even: rgba(0, 0, 0, 0.05); /* Đậm hơn */
  --footer-bg: #e5e5e7; /* Đậm hơn */
}

/* Dark mode variables */
.dark {
  --bg-primary: #000000;
  --bg-secondary: #1a1a1a;
  --bg-card: linear-gradient(145deg, #1a1a1a, #222);
  --bg-card-hover: linear-gradient(145deg, #222, #2a2a2a);
  --text-primary: #ffffff;
  --text-secondary: #86868b;
  --border-color: #333333;
  --nav-bg: rgba(0, 0, 0, 0.8);
  --hero-gradient: linear-gradient(180deg, #000000 0%, #1a1a1a 100%);
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --section-bg: linear-gradient(145deg, #1a1a1a, #222);
  --option-bg: rgba(255, 255, 255, 0.05);
  --option-hover: rgba(255, 255, 255, 0.1);
  --note-bg: rgba(255, 255, 255, 0.05);
  --table-header: rgba(255, 255, 255, 0.1);
  --table-row-even: rgba(255, 255, 255, 0.03);
  --footer-bg: #1a1a1a;
  --edit-border: #444;
  --edit-bg: #2a2a2a;
  --edit-toolbar-bg: #333;
  --edit-button-hover: #444;
}

/* ===== RESET & BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== NAVIGATION ===== */
.nav {
  background-color: var(--nav-bg);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
}

.nav-container {
  max-width: 980px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
}

.nav-logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-logo-img {
  height: 30px;
  width: auto;
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  color: var(--apple-blue);
  text-decoration: none;
  font-size: 17px;
  transition: var(--apple-transition);
}

.back-link:hover {
  color: var(--text-primary);
}

.back-link::before {
  content: "←";
  margin-right: 6px;
  transition: var(--apple-transition);
}

.back-link:hover::before {
  margin-right: 10px;
}

/* ===== HERO SECTION ===== */
.hero {
  height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 0 20px;
  background: var(--hero-gradient);
  position: relative;
  overflow: hidden;
}

.hero-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.4;
  z-index: -1;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  width: 100%;
  text-align: center;
}

.hero h1 {
  font-size: clamp(40px, 8vw, 80px);
  font-weight: 600;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-align: center;
}

.hero p {
  font-size: clamp(19px, 4vw, 28px);
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 30px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* ===== CTA BUTTONS ===== */
.cta-container {
  display: flex;
  gap: 20px;
  margin-bottom: 40px;
}

.cta-button {
  background-color: var(--apple-blue);
  color: white;
  border: none;
  border-radius: 980px;
  padding: 12px 22px;
  font-size: 17px;
  font-weight: 400;
  cursor: pointer;
  transition: var(--apple-transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cta-button:hover {
  background-color: var(--apple-blue-hover);
  transform: scale(1.02);
}

/* ===== CONTENT SECTIONS ===== */
.content {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 20px;
}

.section {
  margin-bottom: 80px;
}

.section-title {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 30px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.section-content {
  background: var(--section-bg);
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(0, 0, 0, 0.05); /* Thêm viền mỏng */
}

.section-content p {
  margin-bottom: 20px;
  font-size: 17px;
  color: var(--text-primary);
}

.section-content ul,
.section-content ol {
  margin-bottom: 20px;
  padding-left: 20px;
}

.section-content li {
  margin-bottom: 10px;
  font-size: 17px;
  color: var(--text-primary);
}

/* ===== EXAMPLES & NOTES ===== */
.example {
  background-color: var(--note-bg);
  border-radius: 12px;
  padding: 25px;
  margin: 30px 0;
}

.example-title {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 15px;
  color: var(--text-primary);
}

.question {
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.options {
  margin-bottom: 20px;
}

.option {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 15px;
  background-color: var(--option-bg);
  border-radius: 10px;
  transition: var(--apple-transition);
  border: 1px solid rgba(0, 0, 0, 0.08); /* Thêm viền */
}

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

.option-marker {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--apple-blue);
  margin-right: 15px;
  flex-shrink: 0;
}

.option-text {
  font-size: 17px;
  color: var(--text-primary);
}

.answer {
  font-size: 17px;
  color: var(--apple-blue);
  font-weight: 500;
}

/* ===== TABLES ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  margin: 30px 0;
  border-radius: 12px;
  overflow: hidden;
}

.table th {
  background-color: var(--table-header);
  padding: 15px;
  text-align: left;
  font-weight: 500;
  color: var(--text-primary);
}

.table td {
  padding: 15px;
  border-top: 1px solid var(--border-color);
  color: var(--text-primary);
}

.table tr:nth-child(even) {
  background-color: var(--table-row-even);
}

.bloom-table {
  width: 100%;
  border-collapse: collapse;
  margin: 30px 0;
  border-radius: 12px;
  overflow: hidden;
}

.bloom-table th {
  background-color: var(--apple-blue);
  padding: 15px;
  text-align: left;
  font-weight: 500;
  color: white;
}

.bloom-table td {
  padding: 15px;
  border-top: 1px solid var(--border-color);
  color: var(--text-primary);
}

.bloom-table tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.03);
}

.bloom-table tr:nth-child(even) {
  background-color: var(--table-row-even);
}

/* ===== VARIANTS ===== */
.variant {
  background: var(--section-bg);
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 20px;
  transition: var(--apple-transition);
  box-shadow: var(--card-shadow);
}

.variant:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.variant-title {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 15px;
  color: var(--text-primary);
}

.note {
  background-color: var(--note-bg);
  border-left: 4px solid var(--apple-blue);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin: 30px 0;
  border-radius: 0 12px 12px 0;
}

.note-title {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--text-primary);
}

/* ===== VIDEO SECTION ===== */
.video-section {
  margin: 80px 0;
  text-align: center;
}

.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  overflow: hidden;
  border-radius: 18px;
  box-shadow: var(--card-shadow);
  margin: 30px 0;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.section-intro {
  text-align: center;
  margin-bottom: 40px;
}

.section-intro p {
  font-size: 19px;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ===== LISTS ===== */
.feature-list {
  list-style: none;
  margin-bottom: 20px;
}

.feature-item {
  position: relative;
  padding-left: 25px;
  margin-bottom: 12px;
  font-size: 17px;
  color: var(--text-primary);
}

.feature-item::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--apple-blue);
  font-size: 18px;
}

.nested-list {
  list-style: none;
  margin-top: 10px;
  margin-left: 20px;
}

.nested-item {
  position: relative;
  padding-left: 20px;
  margin-bottom: 8px;
  font-size: 16px;
  color: var(--text-primary);
}

.nested-item::before {
  content: "○";
  position: absolute;
  left: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ===== FOOTER ===== */
.footer {
  background-color: var(--footer-bg);
  padding: 30px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  border-top: 1px solid var(--border-color);
}

/* ===== GAME GRID (for index page) ===== */
.game-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 30px;
}

.game-card {
  background: var(--bg-card);
  border-radius: 18px;
  overflow: hidden;
  transition: var(--apple-transition);
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
  text-decoration: none; /* Bỏ gạch chân */
}

/* Thêm style cho thẻ a trong game-grid */
.game-grid a {
  text-decoration: none; /* Bỏ gạch chân */
  color: inherit; /* Giữ màu mặc định */
}

.game-card-content {
  padding: 25px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.game-title {
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.game-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ===== RESPONSIVE STYLES ===== */
@media (max-width: 768px) {
  .hero {
    height: auto;
    padding: 100px 20px;
  }

  .content {
    padding: 40px 20px;
  }

  .section {
    margin-bottom: 60px;
  }

  .table,
  .bloom-table {
    display: block;
    overflow-x: auto;
  }

  .cta-container {
    flex-direction: column;
    width: 100%;
    max-width: 300px;
  }

  .game-grid {
    padding: 40px 20px;
    gap: 20px;
  }
}

/* ===== EDIT MODE ===== */
.edit-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  animation: pulse 2s infinite;
  height: auto; /* Đảm bảo chiều cao tự động theo nội dung */
  width: auto; /* Đảm bảo chiều rộng tự động theo nội dung */
}

/* Thay đổi vị trí mới cho nút Chỉnh sửa */
@media (min-width: 769px) {
  .edit-button {
    position: fixed;
    top: 60px; /* Vị trí gần phần đầu trang */
    right: calc(50% - 420px); /* Căn theo độ rộng nội dung */
    max-height: 40px; /* Giới hạn chiều cao tối đa */
  }
}

.edit-button:hover {
  background-color: #0056b3;
  transform: scale(1.05);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
  }
}

.edit-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1001;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease;
}

.fade-in {
  animation: fadeIn 0.3s forwards;
}

.fade-out {
  animation: fadeOut 0.3s forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.edit-container {
  background-color: white;
  border-radius: 8px;
  width: 80%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.4s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.dark .edit-container {
  background-color: #1a1a1a;
  color: white;
}

.edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--edit-border);
}

.dark .edit-header {
  border-bottom: 1px solid #333;
}

.edit-title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.edit-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #333;
  transition: all 0.2s ease;
}

.edit-close:hover {
  transform: scale(1.2);
  color: #ff0000;
}

.dark .edit-close {
  color: #ddd;
}

.dark .edit-close:hover {
  color: #ff6b6b;
}

/* WYSIWYG Editor Styles */
.edit-toolbar {
  display: flex;
  padding: 10px;
  background-color: var(--edit-toolbar-bg);
  border-bottom: 1px solid var(--edit-border);
  flex-wrap: wrap;
  gap: 5px;
}

/* Thêm style cho HTML editor */
.html-editor {
  flex-grow: 1;
  min-height: 300px;
  padding: 15px;
  border: none;
  overflow-y: auto;
  background-color: var(--edit-bg);
  color: var(--text-primary);
  font-family: monospace;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  white-space: pre-wrap;
}

.html-editor:focus {
  outline: none;
}

/* Nút nhúng YouTube và toggle HTML */
.toolbar-btn[id="embedYoutubeBtn"],
.toolbar-btn[id="toggleHtmlBtn"] {
  background-color: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 5px 10px;
  margin-right: 5px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.dark .toolbar-btn[id="embedYoutubeBtn"],
.dark .toolbar-btn[id="toggleHtmlBtn"] {
  background-color: #333;
  border-color: #555;
  color: #fff;
}

.toolbar-btn[id="embedYoutubeBtn"]:hover,
.toolbar-btn[id="toggleHtmlBtn"]:hover {
  background-color: #e0e0e0;
}

.dark .toolbar-btn[id="embedYoutubeBtn"]:hover,
.dark .toolbar-btn[id="toggleHtmlBtn"]:hover {
  background-color: #444;
}

/* Mở rộng thiết kế toolbar */
.edit-toolbar {
  display: flex;
  padding: 10px;
  background-color: var(--edit-toolbar-bg);
  border-bottom: 1px solid var(--edit-border);
  flex-wrap: wrap;
  gap: 5px;
}

/* Active state cho nút toggle HTML */
.toolbar-btn.active {
  background-color: var(--apple-blue);
  color: white;
}

/* Tăng độ tương phản cho chế độ light mode */
.light .edit-toolbar {
  background-color: #e8e8e8;
}

.light .toolbar-btn {
  border: 1px solid #ccc;
  background-color: #f5f5f5;
}

.light .toolbar-btn:hover {
  background-color: #ddd;
}

.light .html-editor {
  background-color: #f8f8f8;
  border: 1px solid #ddd;
}

.toolbar-btn {
  padding: 5px 10px;
  background: none;
  border: 1px solid var(--edit-border);
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.toolbar-btn:hover {
  background-color: var(--edit-button-hover);
}

.edit-content {
  flex-grow: 1;
  min-height: 300px;
  padding: 15px;
  border: none;
  overflow-y: auto;
  background-color: var(--edit-bg);
  color: var(--text-primary);
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
}

.edit-content:focus {
  outline: none;
}

.edit-content h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 15px 0;
}

.edit-content h3 {
  font-size: 20px;
  font-weight: 500;
  margin: 12px 0;
}

.edit-content p {
  margin-bottom: 15px;
}

.edit-content ul,
.edit-content ol {
  margin-left: 20px;
  margin-bottom: 15px;
}

.edit-content li {
  margin-bottom: 5px;
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 20px;
  border-top: 1px solid var(--edit-border);
}

.edit-save,
.edit-cancel {
  padding: 8px 16px;
  margin-left: 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.edit-save {
  background-color: #28a745;
  color: white;
}

.edit-save:hover {
  background-color: #218838;
  transform: translateY(-2px);
}

.edit-cancel {
  background-color: #6c757d;
  color: white;
}

.edit-cancel:hover {
  background-color: #5a6268;
  transform: translateY(-2px);
}

.save-success {
  animation: saveSuccess 0.7s ease;
}

@keyframes saveSuccess {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
    background-color: #5cb85c;
  }
  100% {
    transform: scale(1);
  }
}

.table-container {
  overflow-x: auto;
  margin-bottom: 30px;
}

/* Remove footer styles or set to display: none */
footer {
  display: none !important;
}

/* Add animations */
.nav-container {
  transition: all 0.3s ease;
}

.nav-container:hover {
  transform: translateY(-3px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.cta-button {
  transition: all 0.2s ease-in-out;
}

.cta-button:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.2);
}

.section-content {
  transition: all 0.3s ease;
}

.section-content:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* New animations for existing elements */
.section-title {
  position: relative;
  transition: all 0.3s ease;
}

.section-title:after {
  content: "";
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -5px;
  left: 0;
  background-color: var(--apple-blue);
  transition: width 0.3s ease;
}

.section-title:hover:after {
  width: 100%;
}

.game-card {
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.hero h1 {
  animation: fadeInDown 1.2s ease-out;
}

.hero p {
  animation: fadeInUp 1.2s ease-out;
}

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

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

.section-content {
  transition: all 0.4s ease;
}

.section-content:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.back-link {
  transition: all 0.3s ease;
}

.back-link:hover {
  transform: translateX(-5px);
}

.back-link::before {
  transition: all 0.3s ease;
}

/* Make sure footer stays hidden */
footer {
  display: none !important;
}

