/**
 * HocTiengDuc.de — Gamification Style System
 * Premium, dark-mode glassmorphic aesthetics.
 */

:root {
  --htd-gami-accent: #d97706; /* Amber-600 */
  --htd-gami-accent-light: #f59e0b; /* Amber-500 */
  --htd-gami-accent-glow: rgba(217, 119, 6, 0.2);
  --htd-gami-bg: rgba(30, 41, 59, 0.75); /* Slate 800 glass */
  --htd-gami-bg-solid: #1e293b;
  --htd-gami-card-bg: rgba(15, 23, 42, 0.6);
  --htd-gami-border: rgba(255, 255, 255, 0.1);
  --htd-gami-text: #f8fafc;
  --htd-gami-text-muted: #94a3b8;
}

[data-theme="light"] {
  --htd-gami-bg: rgba(255, 255, 255, 0.8);
  --htd-gami-bg-solid: #ffffff;
  --htd-gami-card-bg: rgba(241, 245, 249, 0.8);
  --htd-gami-border: rgba(0, 0, 0, 0.08);
  --htd-gami-text: #0f172a;
  --htd-gami-text-muted: #64748b;
}

/* ── Floating Action Button (FAB) ───────────────────────────── */
.htd-gami-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.htd-gami-fab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--htd-gami-bg-solid);
  border: 1px solid var(--htd-gami-accent);
  color: var(--htd-gami-text);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 24px var(--htd-gami-accent-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.htd-gami-fab:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 6px 32px var(--htd-gami-accent-glow);
}

.htd-gami-fab-icon {
  font-size: 1.25rem;
}

.htd-gami-fab-text {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--htd-gami-accent);
}

/* ── Glassmorphic Panel ────────────────────────────────────── */
.htd-gami-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 340px;
  max-width: calc(100vw - 48px);
  background: var(--htd-gami-bg);
  border: 1px solid var(--htd-gami-border);
  border-radius: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transform: scale(0.9) translateY(10px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

.htd-gami-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible;
}

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

.htd-gami-panel-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--htd-gami-text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.htd-gami-panel-close {
  background: none;
  border: none;
  color: var(--htd-gami-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  transition: all 0.2s;
}

.htd-gami-panel-close:hover {
  background: var(--htd-gami-border);
  color: var(--htd-gami-text);
}

.htd-gami-panel-body {
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Custom scrollbar for panel body */
.htd-gami-panel-body::-webkit-scrollbar {
  width: 4px;
}
.htd-gami-panel-body::-webkit-scrollbar-thumb {
  background: var(--htd-gami-border);
  border-radius: 4px;
}

/* Metric Card */
.htd-gami-metric-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--htd-gami-card-bg);
  border: 1px solid var(--htd-gami-border);
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color 0.2s;
}

.htd-gami-metric-card:hover {
  border-color: var(--htd-gami-accent-glow);
}

.htd-metric-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.htd-metric-content {
  flex: 1;
}

.htd-metric-label {
  font-size: 0.75rem;
  color: var(--htd-gami-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.htd-metric-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--htd-gami-text);
}

/* XP Progress Bar */
.htd-progress-wrapper {
  margin-top: 8px;
}

.htd-prog-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--htd-gami-border);
  border-radius: 99px;
  overflow: hidden;
}

.htd-prog-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--htd-gami-accent), var(--htd-gami-accent-light));
  border-radius: 99px;
  transition: width 0.4s ease-out;
}

.htd-prog-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--htd-gami-text-muted);
  margin-top: 4px;
}

/* Sections */
.htd-gami-section h4 {
  margin: 0 0 10px 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--htd-gami-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.htd-badges-list {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 8px;
}

.htd-badge-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--htd-gami-card-bg);
  border: 1px solid var(--htd-gami-border);
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.2s;
}

.htd-badge-item.locked {
  opacity: 0.45;
  filter: grayscale(1);
}

.htd-badge-item.unlocked {
  border-color: rgba(217, 119, 6, 0.25);
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.05), transparent);
}

.htd-badge-item-icon {
  font-size: 1.25rem;
}

.htd-badge-item-meta {
  flex: 1;
}

.htd-badge-item-title {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--htd-gami-text);
}

.htd-badge-item-desc {
  display: block;
  font-size: 0.6875rem;
  color: var(--htd-gami-text-muted);
}

/* Stats Recaps */
.htd-gami-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.htd-stat-box {
  background: var(--htd-gami-card-bg);
  border: 1px solid var(--htd-gami-border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.htd-stat-box-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--htd-gami-accent);
}

.htd-stat-box-label {
  font-size: 0.6875rem;
  color: var(--htd-gami-text-muted);
  margin-top: 2px;
}


/* ── Toasts ─────────────────────────────────────────────────── */
.htd-toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.htd-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--htd-gami-border);
  padding: 12px 18px;
  border-radius: 10px;
  color: #fff;
  font-size: 0.875rem;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: htdToastIn 0.35s cubic-bezier(0, 0, 0.2, 1);
  max-width: 320px;
}

.htd-toast-success {
  border-color: rgba(217, 119, 6, 0.4);
  border-left: 4px solid var(--htd-gami-accent);
}

.htd-toast-msg {
  flex: 1;
  font-weight: 500;
}

.htd-toast.fade-out {
  animation: htdToastOut 0.4s ease-out forwards;
}

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

@keyframes htdToastOut {
  to { transform: translateX(50px); opacity: 0; }
}


/* ── Modals ─────────────────────────────────────────────────── */
.htd-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.htd-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.htd-modal-card {
  position: relative;
  z-index: 2;
  background: var(--htd-gami-bg);
  border: 1px solid var(--htd-gami-accent);
  border-radius: 18px;
  padding: 28px;
  width: 360px;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: 0 20px 64px rgba(217, 119, 6, 0.15);
  animation: htdModalIn 0.3s cubic-bezier(0, 0, 0.2, 1);
}

.htd-badge-big-icon {
  font-size: 3.5rem;
  line-height: 1;
  display: block;
  margin-bottom: 14px;
}

.htd-modal-card h2 {
  font-size: 1.4rem;
  margin: 0 0 6px 0;
  color: var(--htd-gami-accent);
  font-weight: 800;
}

.htd-modal-card h3 {
  font-size: 1.125rem;
  margin: 0 0 10px 0;
  color: var(--htd-gami-text);
  font-weight: 700;
}

.htd-modal-card p {
  font-size: 0.85rem;
  color: var(--htd-gami-text-muted);
  margin: 0 0 20px 0;
}

.htd-modal-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}

.htd-btn-amber {
  background: var(--htd-gami-accent);
  color: #fff;
}

.htd-btn-amber:hover {
  background: var(--htd-gami-accent-light);
  transform: translateY(-2px);
}

@keyframes htdModalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ── "Hoàn Thành Bài" CTA Button Styling ──────────────────────── */
.htd-complete-lesson-cta {
  display: flex;
  justify-content: center;
  margin-top: 32px;
}

.htd-complete-lesson-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--htd-gami-accent), var(--htd-gami-accent-light));
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 14px 28px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 32px var(--htd-gami-accent-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.htd-complete-lesson-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 40px rgba(217, 119, 6, 0.35);
}

.htd-complete-lesson-btn:active {
  transform: translateY(-1px);
}
