/* ==========================================================================
   HỘP QUÀ MAY MẮN & THẺ BÍ ẨN - PODIUM CLASSROOM TOOL (TCT.VN)
   Chuyên biệt cho Smart TV bục giảng, màn hình tương tác 4K/FullHD
   Thiết kế No-Scroll 100vh, hiệu ứng 3D CSS mở hộp, nắp hộp bật tung
   ========================================================================== */

:root {
  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  
  /* Light Theme */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  
  --primary: #ec4899;
  --primary-hover: #db2777;
  --primary-light: #fce7f3;
  --accent: #6366f1;
  --accent-light: #e0e7ff;
  --success: #10b981;
  --warning: #f59e0b;
  
  --topbar-height: 64px;
  --subbar-height: 48px;
  --box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --box-shadow-hover: 0 20px 35px -5px rgba(236, 72, 153, 0.25), 0 10px 15px -5px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  
  --primary-light: rgba(236, 72, 153, 0.15);
  --accent-light: rgba(99, 102, 241, 0.15);
  --box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden; /* Cố định 100vh không cuộn trên bục giảng */
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  user-select: none;
}

.podium-app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* --- TOPBAR --- */
.podium-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 1.25rem;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  background-color: var(--primary-light);
  border-radius: 9999px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.back-link:hover {
  filter: brightness(0.95);
  transform: translateX(-2px);
}

.lesson-info-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-main);
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.lesson-badge {
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.lesson-title-input {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1rem;
  outline: none;
  min-width: 260px;
  max-width: 380px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.custom-select {
  appearance: none;
  background-color: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.45rem 1.8rem 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-btn:hover {
  background-color: var(--bg-main);
  border-color: var(--text-muted);
}

.topbar-btn.accent {
  background: linear-gradient(135deg, #ec4899, #d946ef);
  color: #fff;
  border: none;
}
.topbar-btn.accent:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.topbar-btn.warning {
  color: #ea580c;
  background-color: #ffedd5;
  border-color: #fed7aa;
}
.topbar-btn.warning:hover {
  background-color: #fdba74;
}

.topbar-btn.icon-only {
  padding: 0.45rem 0.6rem;
  font-size: 1rem;
}

/* --- STAGE & SUBBAR --- */
.podium-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1.5rem;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
}

.stage-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--subbar-height);
  margin-bottom: 0.5rem;
  gap: 1rem;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-card);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #10b981;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.student-caller-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
  padding: 0.35rem 1rem;
  border-radius: 9999px;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.caller-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.caller-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #6366f1;
}

.caller-btn {
  background-color: #6366f1;
  color: #fff;
  border: none;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.caller-btn:hover {
  background-color: #4f46e5;
  transform: scale(1.05);
}

.scoreboard-quick-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ea580c;
  background-color: #ffedd5;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  text-decoration: none;
  transition: all 0.2s ease;
}
.scoreboard-quick-link:hover {
  background-color: #fdba74;
}

/* --- GIFT GRID (3D) --- */
.gift-grid {
  flex: 1;
  display: grid;
  gap: 1.25rem;
  align-items: stretch;
  perspective: 1000px;
  width: 100%;
  height: calc(100% - var(--subbar-height) - 1rem);
  padding: 0.5rem 0;
}

/* Layouts tùy số hộp */
.gift-grid[data-count="4"] {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 1fr;
}

.gift-grid[data-count="6"] {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.gift-grid[data-count="8"] {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

/* 3D GIFT CARD */
.gift-card {
  position: relative;
  background: var(--bg-card);
  border-radius: 20px;
  border: 2px solid var(--border-color);
  box-shadow: var(--box-shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
  overflow: hidden;
}

.gift-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--primary);
  box-shadow: var(--box-shadow-hover);
}

.gift-card:active {
  transform: translateY(-2px) scale(0.99);
}

/* Card Number Tag */
.gift-number-badge {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(236, 72, 153, 0.3);
}

/* 3D Box Illustration Visual */
.gift-box-visual {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  transition: transform 0.4s ease;
}

.gift-box-icon {
  font-size: 5rem;
  filter: drop-shadow(0 10px 15px rgba(0,0,0,0.15));
  transition: all 0.3s ease;
}

.gift-card:hover .gift-box-icon {
  transform: scale(1.12) rotate(5deg);
}

.gift-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.gift-sublabel {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.gift-hint-action {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background-color: var(--primary-light);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  opacity: 0.9;
  transition: opacity 0.2s;
}

/* Trạng thái Hộp Đã Mở */
.gift-card.is-opened {
  background: var(--bg-main);
  border: 2px dashed var(--border-color);
  opacity: 0.75;
}

.gift-card.is-opened:hover {
  transform: translateY(-4px);
  opacity: 1;
}

.gift-card.is-opened .gift-number-badge {
  background: #64748b;
  box-shadow: none;
}

.gift-card.is-opened .gift-box-icon {
  filter: grayscale(0.5);
  transform: scale(0.95);
}

.gift-card.is-opened .gift-hint-action {
  background-color: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

/* --- REVEAL MODAL (THẺ BẬT MỞ 3D) --- */
.reveal-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-modal.show {
  opacity: 1;
  visibility: visible;
}

.reveal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
}

.reveal-card {
  position: relative;
  background: var(--bg-card);
  width: 90%;
  max-width: 820px;
  border-radius: 28px;
  border: 3px solid var(--primary);
  box-shadow: 0 25px 60px -15px rgba(236, 72, 153, 0.5);
  padding: 2.25rem 2.5rem;
  transform: scale(0.8) translateY(30px);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.reveal-modal.show .reveal-card {
  transform: scale(1) translateY(0);
}

.reveal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.reveal-box-tag {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  padding: 0.4rem 1.25rem;
  border-radius: 9999px;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
}

.reveal-close-btn {
  background: transparent;
  border: none;
  font-size: 2.2rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  transition: transform 0.2s, color 0.2s;
}

.reveal-close-btn:hover {
  color: var(--primary);
  transform: rotate(90deg);
}

.reveal-body {
  text-align: center;
  padding: 1rem 0 2rem;
}

.reveal-symbol {
  font-size: 5rem;
  margin-bottom: 0.75rem;
  animation: bouncePop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bouncePop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); }
}

.reveal-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.reveal-content {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--text-main);
  padding: 0 1rem;
}

.reveal-answer-box {
  margin-top: 1.5rem;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(14, 165, 233, 0.1));
  border: 2px dashed #10b981;
  border-radius: 16px;
  padding: 1.25rem;
  animation: fadeIn 0.3s ease;
}

.reveal-answer-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: #059669;
  margin-bottom: 0.35rem;
}

.reveal-answer-text {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
}

/* Footer & Direct Awarding */
.reveal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.reveal-footer-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn.outline {
  background: transparent;
  border: 2px solid var(--border-color);
  color: var(--text-main);
}
.action-btn.outline:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.reveal-award-zone {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.award-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.award-group-buttons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.award-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  border: none;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.award-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

.award-btn:active {
  transform: scale(0.95);
}

/* --- EDIT MODAL --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  background: var(--bg-card);
  width: 90%;
  max-width: 750px;
  max-height: 85vh;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--box-shadow);
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.question-list-editor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.question-edit-item {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
}

.question-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.question-edit-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary);
}

.question-edit-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.edit-field {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
}

.edit-field:focus {
  border-color: var(--primary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-main);
}

.modal-footer-right {
  display: flex;
  gap: 0.6rem;
}

.modal-btn {
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
}

.modal-btn.primary {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: #fff;
  border: none;
}

.modal-btn.secondary {
  background: #f1f5f9;
  color: #334155;
}

/* CANVAS CONFETTI */
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}

/* RESPONSIVE TRÊN MÀN HÌNH NHỎ NẾU CẦN */
@media (max-width: 900px) {
  .lesson-title-input {
    min-width: 150px;
  }
  .reveal-content {
    font-size: 1.4rem;
  }
  .gift-grid[data-count="4"],
  .gift-grid[data-count="6"],
  .gift-grid[data-count="8"] {
    grid-template-columns: repeat(2, 1fr);
  }
}
