/* =============================================================
   kiteclass-teacher — Wave 1.6 ADD-ON
   Persona: Teacher (homeroom GVCN + subject) — Tier 2 KC user
   Density: medium-dense (data tables, attendance roster)
   Device: tablet primary (1024px), desktop secondary
   Theme: KiteClass blue
   ============================================================= */

@import "../_shared/colors_and_type.css";

/* Force KiteClass blue brand for the whole kit */
:root,
html {
  /* override default kitehub sky → kiteclass blue */
  --primary: 221.2 83.2% 53.3%;
  --primary-foreground: 210 40% 98%;
  --ring: 221.2 83.2% 53.3%;
  --radius: 0.5rem;
}

/* =============================================================
   Attendance code colors (P/V/M/L/S) — VN MoET attendance system
   Always icon + letter, never color-only (WCAG)
   ============================================================= */
:root {
  --att-present: 160 84% 39%;     /* green-600 — P */
  --att-excused: 217 91% 60%;     /* blue-500 — V */
  --att-absent: 0 84.2% 60.2%;    /* red-500 — M */
  --att-late: 38 92% 50%;         /* amber-500 — L */
  --att-sick: 280 65% 55%;        /* purple-500 — S (rare) */

  --grade-excellent: 142 76% 36%; /* Xuất sắc ≥9 */
  --grade-good: 160 84% 39%;      /* Giỏi ≥8 */
  --grade-fair: 38 92% 50%;       /* Khá ≥6.5 */
  --grade-pass: 217 91% 60%;      /* Trung bình ≥5 */
  --grade-fail: 0 84.2% 60.2%;    /* Yếu <5 */
}

.dark {
  --att-present: 160 60% 50%;
  --att-excused: 217 90% 70%;
  --att-absent: 0 75% 65%;
  --att-late: 38 90% 60%;
  --att-sick: 280 60% 70%;
}

/* =============================================================
   Touch targets — tablet first (44×44 minimum, 48 for grids)
   ============================================================= */
.tap-target  { min-width: 44px; min-height: 44px; }
.tap-target-lg { min-width: 48px; min-height: 48px; }

/* =============================================================
   Attendance code chip — letter + icon together
   ============================================================= */
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.att-p { background: hsl(var(--att-present) / 0.12); color: hsl(var(--att-present)); }
.att-v { background: hsl(var(--att-excused) / 0.12); color: hsl(var(--att-excused)); }
.att-m { background: hsl(var(--att-absent) / 0.12); color: hsl(var(--att-absent)); }
.att-l { background: hsl(var(--att-late) / 0.12); color: hsl(var(--att-late)); }
.att-s { background: hsl(var(--att-sick) / 0.12); color: hsl(var(--att-sick)); }

/* =============================================================
   Attendance toggle button (4-way P/V/M/L)
   ============================================================= */
.att-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all .12s ease-out;
}
.att-toggle:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.att-toggle:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}
.att-toggle.active-p { background: hsl(var(--att-present)); color: white; border-color: hsl(var(--att-present)); }
.att-toggle.active-v { background: hsl(var(--att-excused)); color: white; border-color: hsl(var(--att-excused)); }
.att-toggle.active-m { background: hsl(var(--att-absent)); color: white; border-color: hsl(var(--att-absent)); }
.att-toggle.active-l { background: hsl(var(--att-late)); color: white; border-color: hsl(var(--att-late)); }

/* =============================================================
   Grade scale chips (VN honor classification)
   ============================================================= */
.grade-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
}
.grade-xuatsac    { background: hsl(var(--grade-excellent) / 0.15); color: hsl(var(--grade-excellent)); }
.grade-gioi       { background: hsl(var(--grade-good) / 0.15); color: hsl(var(--grade-good)); }
.grade-kha        { background: hsl(var(--grade-fair) / 0.15); color: hsl(var(--grade-fair)); }
.grade-trungbinh  { background: hsl(var(--grade-pass) / 0.15); color: hsl(var(--grade-pass)); }
.grade-yeu        { background: hsl(var(--grade-fail) / 0.15); color: hsl(var(--grade-fail)); }

/* =============================================================
   Sticky first column for grade entry & attendance roster tables
   ============================================================= */
.sticky-col {
  position: sticky;
  left: 0;
  background: hsl(var(--card));
  z-index: 10;
  box-shadow: 1px 0 0 hsl(var(--border));
}
.dark .sticky-col {
  background: hsl(var(--card));
}

/* =============================================================
   Grade input cell — inline editing
   ============================================================= */
.grade-cell {
  width: 64px;
  height: 40px;
  text-align: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  background: transparent;
  font-family: var(--font-mono);
}
.grade-cell:hover { background: hsl(var(--muted)); }
.grade-cell:focus {
  outline: none;
  border-color: hsl(var(--ring));
  background: hsl(var(--card));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}
.grade-cell.invalid {
  border-color: hsl(var(--destructive));
  color: hsl(var(--destructive));
}
.grade-cell.locked {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  cursor: not-allowed;
}

/* =============================================================
   Schedule grid cells
   ============================================================= */
.schedule-cell {
  border: 1px solid hsl(var(--border));
  min-height: 56px;
  padding: 0.5rem;
  font-size: var(--text-xs);
}
.schedule-slot {
  background: hsl(var(--primary) / 0.1);
  border-left: 3px solid hsl(var(--primary));
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  margin: 0.125rem;
}
.schedule-slot.conflict {
  background: hsl(var(--destructive) / 0.12);
  border-left-color: hsl(var(--destructive));
}

/* =============================================================
   Heatmap (calendar) — for reports detail
   ============================================================= */
.heatmap-cell {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.hm-100 { background: hsl(var(--att-present)); color: white; }
.hm-90  { background: hsl(var(--att-present) / 0.65); color: hsl(var(--att-present)); }
.hm-75  { background: hsl(var(--att-present) / 0.4); color: hsl(var(--att-present)); }
.hm-50  { background: hsl(var(--att-late) / 0.5); color: hsl(var(--att-late)); }
.hm-low { background: hsl(var(--att-absent) / 0.5); color: hsl(var(--att-absent)); }
.hm-none { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

/* =============================================================
   Sparkline mini-bar (KPI cards — reports overview)
   ============================================================= */
.sparkbar {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
}
.sparkbar > i {
  display: block;
  width: 4px;
  background: hsl(var(--primary));
  border-radius: 1px;
  opacity: 0.85;
}

/* =============================================================
   Save bar (sticky bottom, with unsaved indicator)
   ============================================================= */
.save-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: hsl(var(--card));
  border-top: 1px solid hsl(var(--border));
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -4px 12px hsl(var(--background) / 0.4);
}
.unsaved-pulse::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: hsl(var(--warning));
  border-radius: 50%;
  margin-right: 0.5rem;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* =============================================================
   Skeleton loader
   ============================================================= */
.skeleton {
  background: linear-gradient(90deg,
    hsl(var(--muted)) 25%,
    hsl(var(--muted) / 0.6) 50%,
    hsl(var(--muted)) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =============================================================
   Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .skeleton, .unsaved-pulse::before { animation: none; }
  .att-toggle, .hover-lift { transition: none; }
}

/* =============================================================
   Responsive (320 / 768 / 1440)
   ============================================================= */
@media (max-width: 767px) {
  .desktop-only { display: none; }
  .save-bar { padding: 0.5rem 1rem; }
}
@media (min-width: 768px) {
  .mobile-only { display: none; }
}
