/* ==========================================================================
   GAMES.CSS — Flashcard, Match Game, Type Game, Progress Bar, Vocab List, Tab, Form
   ========================================================================== */

/* ========== FLASHCARD ========== */
#flashcardView { flex-grow: 1; display: flex; flex-direction: column; justify-content: center; padding-top: 10px; }
.card-counter { text-align: center; font-size: 1.1em; font-weight: bold; color: #718096; margin-bottom: 15px; letter-spacing: 1px; }
.flashcard-nav-container { display: flex; align-items: center; justify-content: center; gap: 30px; margin-bottom: 30px; }

.nav-btn { background: #fff; border: 2px solid #e2e8f0; border-radius: 50%; width: 50px; height: 50px; font-size: 1.4em; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #4a5568; transition: all 0.2s ease; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.nav-btn:hover { background: #f8fafc; border-color: #cbd5e0; transform: scale(1.05); color: #2b6cb0; }

.flashcard { perspective: 1000px; width: 350px; height: 220px; cursor: pointer; margin: 0 auto; }
.flashcard-inner { position: relative; width: 100%; height: 100%; text-align: center; transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1); transform-style: preserve-3d; border-radius: 16px; border: 1px solid #e2e8f0; background: #fff; box-shadow: 0 10px 20px rgba(0,0,0,0.08); }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 30px; border-radius: 16px; box-sizing: border-box; }
.flashcard-front { background: linear-gradient(135deg, #ebf4ff 0%, #ffffff 100%); color: #2b6cb0; }
.flashcard-back { background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%); color: #c53030; transform: rotateY(180deg); }

#fcFrontText { font-size: 2.2em; font-weight: 800; margin-bottom: 5px; }
#fcBackText { font-size: 1.6em; font-weight: bold; line-height: 1.4; }
.audio-icon { font-size: 0.85em; color: #718096; font-weight: normal; margin-top: 15px; display: inline-flex; align-items: center; gap: 6px; opacity: 0.9; background: rgba(255,255,255,0.7); padding: 6px 14px; border-radius: 20px; border: 1px solid #e2e8f0; }

.controls-row { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 25px; color: #4a5568; font-weight: 500; }
.start-game-btn { background: #3182ce; color: white; border: none; padding: 14px 24px; border-radius: 10px; font-weight: bold; cursor: pointer; transition: 0.2s; font-size: 1.05em; display: inline-block; width: 100%; max-width: 350px; margin: 0 auto; box-shadow: 0 4px 6px rgba(49, 130, 206, 0.2); }
.start-game-btn:hover { background: #2b6cb0; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(49, 130, 206, 0.3); }

/* Nút đánh giá Flashcard */
.flashcard-assess-group { display: flex; gap: 10px; justify-content: center; margin-top: 20px; width: 100%; }
.btn-assess { flex: 1; border: none; padding: 12px; border-radius: 8px; font-weight: bold; color: white; cursor: pointer; transition: 0.2s; font-size: 0.95em; }
.btn-assess:hover { filter: brightness(0.9); transform: translateY(-2px); }

/* Nút sao trong flashcard */
.fc-star-btn { position: absolute; top: 15px; right: 15px; background: transparent; border: none; font-size: 1.5em; cursor: pointer; color: #cbd5e1; transition: 0.2s; z-index: 5; }
.fc-star-btn:hover { transform: scale(1.2); }
.fc-star-btn.saved { color: #fbbf24; }

/* ========== MATCH GAME ========== */
#matchView { flex-grow: 1; display: none; flex-direction: column; position: relative; min-height: 350px; }
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; margin-bottom: 20px; max-height: 45vh; overflow-y: auto; padding-right: 5px; align-content: start; }
.match-grid::-webkit-scrollbar { width: 6px; }
.match-grid::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 4px; }

.match-card { padding: 10px; text-align: center; border-radius: 8px; font-weight: bold; cursor: pointer; display: flex; justify-content: center; align-items: center; min-height: 65px; border: 2px solid #e2e8f0; background: #f8fafc; font-size: 1em; transition: 0.15s; }
.match-card:hover { border-color: #cbd5e0; transform: translateY(-2px); }
.match-card:active { transform: scale(0.95); }
.match-card.kr { color: #2b6cb0; } .match-card.vn { color: #2f855a; }
.match-card.selected { border-color: #3182ce; background: #ebf8ff; box-shadow: inset 0 0 0 1px #3182ce; }
.match-card.error { border-color: #fc8181 !important; background: #fff5f5 !important; color: #c53030 !important; animation: shake 0.4s; }
.match-card.hidden { opacity: 0; pointer-events: none; visibility: hidden; }

.result-overlay { display: none; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255, 255, 255, 0.95); z-index: 100; flex-direction: column; justify-content: center; align-items: center; border-radius: 12px; }
.result-box { background: #fff; padding: 40px 30px; border-radius: 16px; text-align: center; border: 2px solid #48bb78; width: 85%; max-width: 320px; animation: popIn 0.3s; box-shadow: 0 10px 25px rgba(0,0,0,0.1); }

/* ========== MYPAGE GAME & SCROLL AREA ========== */
#matchArea { position: relative; min-height: 400px; display: flex; flex-direction: column; }
.match-grid-scroll { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; padding: 5px; max-height: 350px; align-content: start; }
.match-grid-scroll::-webkit-scrollbar { width: 6px; }
.match-grid-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.match-overlay-fixed { position: absolute; inset: 0; background: rgba(255,255,255,0.95); z-index: 10; display: none; flex-direction: column; justify-content: center; align-items: center; border-radius: 12px; }
body.dark-mode .match-overlay-fixed { background: rgba(31,41,55,0.95); }

/* ========== TYPE GAME ========== */
.type-game-container { text-align: center; padding: 20px 0; }
.type-word-display { font-size: 2.5em; font-weight: 800; margin-bottom: 20px; color: var(--text-main); }
.type-input { width: 100%; max-width: 300px; padding: 15px; font-size: 1.2em; border: 2px solid var(--border-color); border-radius: 8px; text-align: center; outline: none; background: var(--bg-body); color: var(--text-main); margin-bottom: 15px; transition: 0.2s; }
.type-input:focus { border-color: var(--text-main); }
.type-result { height: 24px; font-weight: bold; margin-bottom: 15px; }

/* ========== PROGRESS BAR & MEMORY STATS ========== */
.memory-stats-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 25px; margin-bottom: 30px; box-shadow: 0 2px 10px rgba(0,0,0,0.02); }
.memory-stats-title { font-size: 1.1em; font-weight: 800; color: #475569; margin-bottom: 20px; }
.progress-bar-container { display: flex; height: 16px; width: 100%; border-radius: 99px; overflow: hidden; background: #f1f5f9; margin-bottom: 25px; }
.progress-segment { height: 100%; transition: width 0.5s ease; }
.bg-moi { background-color: #cbd5e1; }
.bg-dang-hoc { background-color: #f472b6; }
.bg-dang-on { background-color: #60a5fa; }
.bg-thanh-thao { background-color: #34d399; }

.stats-legend { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.legend-item { display: flex; flex-direction: column; align-items: flex-start; }
.legend-dot-wrapper { display: flex; align-items: center; gap: 8px; font-weight: bold; font-size: 1.2em; color: #334155; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; }
.legend-label { font-size: 0.85em; color: #94a3b8; margin-top: 4px; font-weight: 500; }

/* ========== VOCAB LIST ========== */
.vocab-list-container { display: flex; flex-direction: column; gap: 12px; max-height: 400px; overflow-y: auto; padding-right: 5px; }
.vocab-list-container::-webkit-scrollbar { width: 6px; }
.vocab-list-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.vocab-item { display: flex; justify-content: space-between; align-items: center; padding: 15px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; transition: 0.2s; }
.vocab-item:hover { border-color: #cbd5e1; box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
.vocab-info { display: flex; flex-direction: column; gap: 4px; }
.vocab-word-text { font-size: 1.1em; font-weight: bold; color: #0f172a; }
.vocab-mean-text { font-size: 0.95em; color: #64748b; }
.vocab-actions { display: flex; gap: 5px; }
.status-badge { font-size: 0.75em; padding: 4px 8px; border-radius: 4px; font-weight: bold; color: white; }

/* ========== 2-COLUMN VOCAB GRID ========== */
.vocab-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-height: 400px; overflow-y: auto; padding-right: 5px; }
@media (max-width: 600px) { .vocab-grid-2col { grid-template-columns: 1fr; } }
.vocab-grid-2col::-webkit-scrollbar { width: 4px; }
.vocab-grid-2col::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.v-card-flat { position: relative; border: 1px solid var(--border-color); border-radius: 10px; padding: 15px 15px 15px 25px; background: var(--bg-card); display: flex; flex-direction: column; gap: 4px; transition: 0.2s; }
.v-card-flat:hover { border-color: #94a3b8; }
.v-dot { position: absolute; top: 18px; left: 10px; width: 8px; height: 8px; border-radius: 50%; }
.v-dot.bg-moi { background-color: #cbd5e1; }
.v-dot.bg-hoc { background-color: #f472b6; }
.v-dot.bg-on { background-color: #60a5fa; }
.v-dot.bg-thanh { background-color: #34d399; }

/* ========== TABS & FORM CONTROLS ========== */
.tabs-2x2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 25px; }
.tab-btn-flat { background: var(--bg-body); color: var(--text-sub); border: 1px solid var(--border-color); padding: 15px; border-radius: 12px; font-weight: 600; font-size: 0.95em; cursor: pointer; transition: 0.2s; text-align: center; }
.tab-btn-flat:hover { border-color: var(--text-main); color: var(--text-main); }
.tab-btn-flat.active { background: var(--text-main); color: var(--bg-card); border-color: var(--text-main); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.btn-flat-primary { background: #111827; color: #ffffff; border: none; padding: 12px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; width: 100%; font-size: 0.95em; }
.btn-flat-primary:hover { opacity: 0.8; }
.btn-flat-outline { background: transparent; color: #111827; border: 1px solid #e5e7eb; padding: 12px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; width: 100%; font-size: 0.95em; }
body.dark-mode .btn-flat-primary { background: #ffffff; color: #111827; }
body.dark-mode .btn-flat-outline { border-color: #374151; color: #f9fafb; }

.form-group { margin-bottom: 14px; }
.form-label { font-size: 0.85em; font-weight: 700; color: var(--text-sub); display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-control { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border-color); border-radius: 8px; background: var(--bg-body); color: var(--text-main); box-sizing: border-box; font-size: 1em; outline: none; transition: border-color 0.2s; }
.form-control:focus { border-color: var(--text-main); }

/* ========== LEADERBOARD ========== */
.lb-item { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-bottom: 1px solid var(--border-color); }
.lb-item:last-child { border-bottom: none; }
.lb-rank { font-size: 1.2em; font-weight: bold; width: 40px; }
.lb-name { font-weight: 600; flex: 1; }
.lb-stats { font-size: 0.9em; color: var(--text-sub); text-align: right; }

/* ========== CHART SCROLL ========== */
.chart-scroll-container { width: 100%; overflow-x: auto; overflow-y: hidden; border: 1px solid var(--border-color); border-radius: 12px; padding: 15px; background: var(--bg-card); }
.chart-scroll-container::-webkit-scrollbar { height: 6px; }
.chart-scroll-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.chart-inner { height: 300px; width: 100%; }

/* ========== ANIMATIONS ========== */
@keyframes shake { 0%, 100% { transform: translateX(0); } 25%, 75% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
