/* ============================================================
   BUTTONS — Polished with depth
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition);
  min-height: 40px;
  border: 1px solid transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  letter-spacing: -0.01em;
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 16px var(--primary-glow);
}

.btn:active { transform: translateY(0) scale(0.98); box-shadow: none; }
.btn-secondary { background: var(--bg-elev); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--bg-soft); border-color: var(--border-hover); box-shadow: var(--shadow); }
.btn-success { background: var(--success); }
.btn-success:hover { box-shadow: 0 4px 12px rgba(22, 163, 74, 0.2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); box-shadow: none; }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; min-height: 30px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; min-height: 48px; border-radius: var(--radius); }
.btn-icon { padding: 8px; min-width: 36px; min-height: 36px; border-radius: 8px; }
.btn[disabled],
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ============================================================
   CARDS — Elevated with clean depth
   ============================================================ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

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

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

.card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.card-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 12px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border var(--transition);
}

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

.form-textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-help { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; gap: 12px; }

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 24px;
  transition: var(--transition);
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ============================================================
   NAV TABS
   ============================================================ */
.nav-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding: 5px;
  background: var(--bg-soft);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  transition: all var(--transition);
  border: none;
}
.nav-tab svg { flex-shrink: 0; }

.nav-tab:hover { color: var(--text); background: var(--primary-soft); }
.nav-tab.active { color: #fff; background: var(--primary); box-shadow: 0 4px 12px var(--primary-glow); }

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--bg-soft);
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--primary-soft); color: var(--primary); }

.difficulty-easy { background: var(--success-soft); color: var(--success); }
.difficulty-medium { background: var(--warning-soft); color: var(--warning); }
.difficulty-hard { background: var(--danger-soft); color: var(--danger); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 30, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms ease;
}

.modal-lg { max-width: 900px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 1.3rem; font-weight: 700; }
.modal-close { font-size: 1.4rem; color: var(--text-muted); padding: 4px 10px; border-radius: 6px; }
.modal-close:hover { background: var(--bg-soft); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* ============================================================
   TABLES
   ============================================================ */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { background: var(--bg-soft); font-weight: 700; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-soft); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-stack {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}

.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: slideIn 250ms ease;
  font-size: 0.9rem;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

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

/* ============================================================
   STAT BOXES
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--grad);
}

.stat:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px) scale(1.02);
}

.stat-value { font-size: 1.8rem; font-weight: 900; color: var(--primary); letter-spacing: -0.03em; }
.stat-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.chart-card h3 { font-size: 1rem; margin-bottom: 10px; }
.chart-canvas-wrap { position: relative; height: 280px; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  max-width: 420px;
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.login-card p { color: var(--text-muted); margin-bottom: 24px; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-fill {
  height: 100%;
  background: var(--grad);
  transition: width var(--transition);
}

/* ============================================================
   ADMIN
   ============================================================ */
.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.q-edit-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.q-edit-actions { display: flex; gap: 6px; flex-wrap: wrap; }
