/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--green);
  color: #131f24;
  box-shadow: 0 4px 0 var(--green-dark);
}
.btn-primary:hover { background: var(--green-light); }
.btn-primary:active { box-shadow: 0 2px 0 var(--green-dark); transform: translateY(2px); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 2px solid var(--border-light);
}
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text-primary); }

.btn-full { width: 100%; }

.btn-sm { padding: 10px 16px; font-size: 0.875rem; }
.btn-lg { padding: 16px 32px; font-size: 1.125rem; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
}

.card-elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

/* ===== Bottom Navigation ===== */
#nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.6875rem;
  font-weight: 600;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  background: none;
  border: none;
}

.nav-tab:hover { color: var(--text-secondary); }
.nav-tab.active { color: var(--green); }

.nav-tab svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 700;
}

.badge-xp {
  background: rgba(88, 204, 2, 0.15);
  color: var(--green);
}

.badge-streak {
  background: rgba(255, 150, 0, 0.15);
  color: var(--orange);
}

.badge-level {
  background: rgba(73, 192, 248, 0.15);
  color: var(--blue);
}

/* ===== Progress Bar ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width var(--transition-slow);
}

/* ===== Stat Grid ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-item {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Toast ===== */
.toast {
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 1rem;
  animation: toastIn 0.4s ease, toastOut 0.4s ease 2s forwards;
  pointer-events: none;
}

.toast-xp {
  background: var(--green);
  color: #131f24;
}

.toast-streak {
  background: var(--orange);
  color: #131f24;
}

.toast-error {
  background: var(--red);
  color: #fff;
  animation: toastIn 0.4s ease, toastOut 0.4s ease 3s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-20px) scale(0.9); }
}

.toast-with-panda {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-panda {
  display: flex;
  align-items: center;
}

.toast-panda .panda-mascot {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* ===== Lesson Card ===== */
.lesson-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}

.lesson-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.lesson-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.lesson-card-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.lesson-card-meta {
  display: flex;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: 8px;
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-select, .form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color var(--transition);
  appearance: none;
}

.form-select:focus, .form-input:focus {
  outline: none;
  border-color: var(--green);
}

/* ===== Rating Buttons ===== */
.rating-group {
  display: flex;
  gap: 8px;
}

.rating-btn {
  flex: 1;
  padding: 12px 8px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.rating-btn:hover { border-color: var(--blue); }
.rating-btn.selected {
  border-color: var(--green);
  background: rgba(88, 204, 2, 0.1);
  color: var(--green);
}

/* ===== Section ===== */
.section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

/* ===== Login Screen ===== */
.login-screen {
  min-height: 100vh;
  padding: 20px;
}

.login-title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green) 0%, var(--blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--text-secondary);
  margin-top: 8px;
}

.login-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== User Selection Grid ===== */
.user-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.user-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.user-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.user-card:active {
  transform: scale(0.98);
}

.user-card-new {
  border-style: dashed;
  background: transparent;
}

.user-card-new:hover {
  border-color: var(--blue);
  background: rgba(73, 192, 248, 0.05);
}

.user-avatar {
  font-size: 3rem;
  margin-bottom: 8px;
  line-height: 1;
}

.user-card-new .user-avatar {
  font-size: 2.5rem;
  color: var(--text-muted);
}

.user-name {
  font-weight: 700;
  font-size: 1.125rem;
  margin-bottom: 4px;
}

.user-stats {
  color: var(--text-muted);
  font-size: 0.8125rem;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.user-level {
  color: var(--blue);
  font-weight: 600;
}

.user-xp {
  color: var(--green);
  font-weight: 600;
}

.user-streak {
  color: var(--orange);
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 8px;
}

/* ===== New User Screen ===== */
.new-user-screen {
  min-height: 100vh;
  padding: 20px;
}

/* ===== Mascot Selection Grid ===== */
.mascot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.mascot-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.mascot-card:hover {
  border-color: var(--blue);
}

.mascot-card.selected {
  border-color: var(--green);
  background: rgba(88, 204, 2, 0.1);
}

.mascot-preview {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.mascot-name {
  font-weight: 700;
  font-size: 1rem;
}

.mascot-desc {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 4px;
}

/* ===== Form Errors ===== */
.form-error {
  color: var(--red);
  font-size: 0.8125rem;
  margin-top: 8px;
}

.form-input.shake {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ===== Settings Mascot ===== */
.settings-mascot-preview {
  width: 60px;
  height: 60px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  flex-shrink: 0;
}

.mascot-select-row {
  display: flex;
  gap: 8px;
}

.mascot-select-btn {
  flex: 1;
  padding: 12px 8px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all var(--transition);
}

.mascot-select-btn:hover {
  border-color: var(--blue);
}

.mascot-select-btn.selected {
  border-color: var(--green);
  background: rgba(88, 204, 2, 0.1);
}

/* ===== PIN Modal ===== */
.pin-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.pin-modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  max-width: 300px;
  width: 100%;
}

.pin-modal-avatar {
  font-size: 4rem;
  margin-bottom: 8px;
}

.pin-modal-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.pin-input-container {
  margin-bottom: 16px;
}

.pin-input {
  width: 100%;
  padding: 16px;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 8px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}

.pin-input:focus {
  outline: none;
  border-color: var(--green);
}

.pin-error {
  color: var(--red);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.pin-modal-buttons {
  display: flex;
  gap: 12px;
}

.pin-modal-buttons .btn {
  flex: 1;
}

/* ===== Admin Badge on User Cards ===== */
.user-card-admin {
  border-color: var(--orange);
}

.admin-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--orange);
  color: #131f24;
  font-size: 0.625rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.user-card {
  position: relative;
}

.user-pin-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.875rem;
}

/* ===== Admin User List ===== */
.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
}

.admin-user-item.current-user {
  border: 1px solid var(--green);
}

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-user-avatar {
  font-size: 1.5rem;
}

.admin-user-name {
  font-weight: 600;
}

.admin-user-badge {
  background: var(--orange);
  color: #131f24;
  font-size: 0.625rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.admin-user-pin {
  font-size: 0.75rem;
}

/* ===== Switch User Button ===== */
.switch-user-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--transition), transform var(--transition);
}

.switch-user-btn:hover {
  border-color: var(--green);
  transform: scale(1.05);
}
