/* DC12 Vocabulary App — Taste-skill inspired minimal UI */

@import url('https://fonts.googleapis.com/css?family=Be+Vietnam+Pro:300,400,500,600,700&subset=vietnamese&display=swap');

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: rgba(148, 163, 184, 0.2);
  --text: #1e293b;
  --text-secondary: #64748b;
  --accent: #0a85a0;
  --accent-hover: #0a6f86;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 1.25rem;
  --radius-sm: 0.75rem;
  --shadow: 0 4px 24px rgba(0,0,0,0.04), 0 1px 4px rgba(0,0,0,0.03);
  --card-bg: #ffffff;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: rgba(148, 163, 184, 0.15);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --accent: #22d3ee;
  --accent-hover: #06b6d4;
  --success: #4ade80;
  --danger: #f87171;
  --shadow: 0 4px 24px rgba(0,0,0,0.2), 0 1px 4px rgba(0,0,0,0.1);
  --card-bg: #1e293b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Be Vietnam Pro', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}

/* Layout */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header .user-badge {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  letter-spacing: -0.01em;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.75rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 0.25rem;
}

.tab-btn {
  flex: 1;
  padding: 0.625rem 1rem;
  border: none;
  background: transparent;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--accent);
  color: white;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input, textarea, select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
  outline: none;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 133, 160, 0.1);
}

textarea { resize: vertical; min-height: 80px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { opacity: 0.9; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm { padding: 0.4rem 0.875rem; font-size: 0.8125rem; }

/* Tables */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  padding: 0.75rem 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #e0f2fe; color: #0c4a6e; }
[data-theme="dark"] .alert-success { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .alert-error { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .alert-info { background: #0c4a6e; color: #bae6fd; }

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card .card-title {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 1.75rem;
}

/* Word cards (user view) */
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

.word-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  transition: box-shadow 0.15s;
}

.word-card:hover {
  box-shadow: var(--shadow);
}

.word-card .english {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.word-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speaker-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
  line-height: 1;
}
.speaker-btn:hover { opacity: 1; }

.speaker-btn-sm {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 2px;
  opacity: 0.6;
  transition: opacity 0.15s;
  vertical-align: middle;
  line-height: 1;
}
.speaker-btn-sm:hover { opacity: 1; }

/* ===== FLASHCARD ===== */
#flashcardContainer {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

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

.fc-progress {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.fc-tip {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  opacity: 0.75;
}

.fc-card-wrapper {
  perspective: 800px;
  margin-bottom: 1.5rem;
  cursor: pointer;
}

.fc-card {
  position: relative;
  width: 100%;
  min-height: 280px;
}

.fc-card.flipped .fc-card-inner {
  transform: rotateY(180deg);
}

.fc-card-inner {
  position: relative;
  width: 100%;
  min-height: 280px;
  transition: transform 0.4s ease;
  transform-style: preserve-3d;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
}

.fc-front, .fc-back {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 280px;
  backface-visibility: hidden;
  border-radius: 16px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.fc-front {
  z-index: 2;
}

.fc-back {
  transform: rotateY(180deg);
}

.fc-word {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.fc-phonetic {
  font-size: 0.95rem;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.25rem;
}

.fc-speaker {
  font-size: 1.25rem;
  opacity: 0.5;
  margin-top: 0.25rem;
}
.fc-speaker:hover { opacity: 1; }

.fc-meaning {
  font-size: 1.125rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 1rem;
}

.fc-example {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
}

.fc-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}
.fc-actions .btn { min-width: 130px; }

/* ===== WORD CARDS ===== */
.word-card .phonetic {
  font-size: 0.875rem;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  margin: 0.25rem 0 0.35rem;
}

.word-card .meaning {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.word-card .example {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-style: italic;
  border-left: 2px solid var(--border);
  padding-left: 0.75rem;
}

/* Test mode */
.test-item {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.test-item .question {
  font-weight: 500;
}

.test-item input {
  width: 100%;
}

.test-item .status {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
}
.test-item .status.correct { color: var(--success); }
.test-item .status.wrong { color: var(--danger); }

/* Score banner */
.score-banner {
  text-align: center;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.score-banner .score {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
}
.score-banner .label {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

/* Hidden */
.hidden { display: none !important; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 90%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}

/* Misc */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }

/* Test mode toggle */
.mode-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.25rem;
  margin-bottom: 1.5rem;
  width: fit-content;
}

.mode-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  background: transparent;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}
.mode-btn.active {
  background: var(--accent);
  color: white;
}
/* Flashcard Controls */
.fc-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.fc-toggle-group {
  display: flex;
  gap: 0;
}
.fc-toggle-group .fc-toggle {
  border-radius: 0;
}
.fc-toggle-group .fc-toggle:first-child {
  border-radius: 0.375rem 0 0 0.375rem;
}
.fc-toggle-group .fc-toggle:last-child {
  border-radius: 0 0.375rem 0.375rem 0;
}
.fc-toggle-group .fc-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.fc-review-badge {
  background: #f59e0b;
  color: #fff;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  font-weight: 600;
  margin-left: auto;
}

/* Flashcard Header */
.fc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.fc-progress {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.fc-tip {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* Flashcard Type Area */
.fc-type-area {
  text-align: center;
  padding: 2rem 1rem;
  max-width: 400px;
  margin: 0 auto;
}
.fc-type-question {
  margin-bottom: 1rem;
  font-size: 1.1rem;
  line-height: 1.6;
}

/* Stats Modal dark mode support */
[data-theme="dark"] .modal {
  border: 1px solid var(--border);
}
[data-theme="dark"] .modal-overlay {
  background: rgba(0,0,0,0.6);
}

/* Guide Box */
.guide-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.guide-summary {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.guide-summary::-webkit-details-marker { display: none; }
.guide-summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 0.5rem;
  transition: transform 0.2s;
  font-size: 0.7rem;
}
details[open] .guide-summary::before {
  transform: rotate(90deg);
}
.guide-content {
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.guide-mode {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
}
.guide-icon {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  text-align: center;
}
.guide-footer {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}
