/* ============================================================
   COMPONENTS — Buttons, Cards, Inputs, Badges, Lists
   ============================================================ */

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity .15s, box-shadow .15s;
  border: none;
  white-space: nowrap;
}
.btn:active { opacity: .8; }
.btn:disabled { opacity: .4; cursor: default; }

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:active { box-shadow: none; }

.btn-secondary {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.btn-danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

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

.btn-full { width: 100%; }

/* FAB (Floating Action Button) */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--space-4));
  right: var(--space-4);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 50;
  touch-action: manipulation;
  transition: transform .15s;
}
.fab:active { transform: scale(.95); }

/* ---- Cards ---- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-list .card + .card { margin-top: var(--space-2); }

/* ---- List Items ---- */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  touch-action: manipulation;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--color-bg); }

.list-item-content {
  flex: 1;
  overflow: hidden;
}
.list-item-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}
.list-item-action {
  flex-shrink: 0;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  padding: 0 var(--space-1);
}

.grade-badge {
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---- Inputs ---- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.form-input {
  width: 100%;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: 16px;
  color: var(--color-text);
  appearance: none;
  outline: none;
  transition: border-color .15s;
}
.form-input:focus {
  border-color: var(--color-primary);
  background: var(--color-surface);
}

/* ---- Toggle Switch ---- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
}
.toggle-label {
  font-size: 15px;
  font-weight: 500;
}
.toggle-switch {
  position: relative;
  width: 50px; height: 28px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0; width: 0; height: 0;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 14px;
  transition: background .2s;
  cursor: pointer;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  background: white;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-track {
  background: var(--color-primary);
}
.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(22px);
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.tab-btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: all .2s;
  touch-action: manipulation;
}
.tab-btn.active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* ---- Stepper ---- */
.stepper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.stepper-value {
  font-size: 18px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}
.stepper-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background .15s;
}
.stepper-btn:active { background: var(--color-primary); color: white; }

/* ---- Empty State ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-text-secondary);
  gap: var(--space-3);
}
.empty-state-icon {
  font-size: 48px;
  opacity: .6;
}
.empty-state-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
}
.empty-state-text { font-size: 14px; }

/* ---- Grade buttons (1-5) for entry ---- */
.grade-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-2);
  margin: var(--space-4) 0;
}
.grade-btn {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  font-size: 22px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform .1s, box-shadow .1s;
  touch-action: manipulation;
  border: 2.5px solid transparent;
}
.grade-btn:active { transform: scale(.92); }
.grade-btn.selected {
  border-color: currentColor;
  box-shadow: 0 0 0 3px rgba(0,0,0,.1);
}
.grade-btn span.grade-label {
  font-size: 9px;
  font-weight: 600;
  opacity: .75;
  text-transform: uppercase;
  letter-spacing: .03em;
  text-align: center;
  line-height: 1.1;
}

/* ---- Slider ---- */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-text-secondary);
}
input[type="range"] {
  width: 100%;
  height: 6px;
  appearance: none;
  background: var(--color-border);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ---- Context Picker ---- */
.context-section { margin-bottom: var(--space-4); }
.context-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}
.context-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.context-chip-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  font-size: 14px;
  font-weight: 500;
  background: var(--color-surface);
  color: var(--color-text);
  touch-action: manipulation;
  transition: all .15s;
}
.context-chip-item.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}
.context-chip-item:active { opacity: .8; }

/* ---- Student detail grade history ---- */
.grade-history-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.grade-history-item:last-child { border-bottom: none; }
.grade-history-meta {
  flex: 1;
  overflow: hidden;
}
.grade-history-date { font-size: 13px; color: var(--color-text-secondary); }
.grade-history-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-secondary);
  margin-top: 2px;
}
.grade-history-note {
  font-size: 13px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
