/* ============================================================
   Neumorphism (Soft UI) — Views
   Classroom board & seats, student cards, dashboard, summary,
   tracker, timer, noise, grouping + responsive.
   ============================================================ */

/* --- student roster cards: extruded pills --- */
.student-cards-container {
  padding: 18px 36px;
  background: var(--background);
  display: none;
}
.student-cards-container.has-students { display: block; }

.student-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 14px;
}

.mini-student-card {
  background: var(--background);
  border-radius: var(--radius-base);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-extruded-sm);
  transition: transform var(--transition), box-shadow var(--transition), color var(--transition);
}
.mini-student-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-extruded-hover);
}

.mini-student-card.male { box-shadow: var(--shadow-extruded-sm), inset 4px 0 0 var(--male-color); }
.mini-student-card.female { box-shadow: var(--shadow-extruded-sm), inset 4px 0 0 var(--female-color); }

.mini-student-card .name {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-student-card .score {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 500;
  margin-top: 4px;
}
.mini-student-card .score.positive { color: var(--success-color); }
.mini-student-card .score.negative { color: var(--danger-color); }
.mini-student-card .score.neutral { color: var(--muted-foreground); }

/* --- classroom board: deep inset well --- */
.classroom-wrapper {
  position: relative;
  background: var(--background);
  margin: 22px 36px;
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-inset-deep);
  overflow: auto;
  touch-action: pan-x pan-y;
}

.classroom {
  position: relative;
  min-height: 720px;
  min-width: 1200px;
  background-size: var(--grid-size) var(--grid-size);
  background-image:
    linear-gradient(to right, rgba(109,122,140,0.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(109,122,140,0.12) 1px, transparent 1px);
  transform-origin: top left;
}

/* Add student button: accent, extruded */
.add-student-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-foreground);
  border: none;
  font-size: var(--text-2xl);
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  box-shadow: var(--shadow-extruded);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.add-student-btn:hover { background: var(--accent-light); transform: translateY(-1px); box-shadow: var(--shadow-extruded-hover); }
.add-student-btn:active { transform: translateY(0.5px); box-shadow: var(--shadow-accent); }
.add-student-btn span { line-height: 1; margin-top: -2px; }

#marquee-box {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: var(--radius-inner);
  background-color: rgba(108, 99, 255, 0.12);
  display: none;
  pointer-events: none;
  z-index: 2000;
}

/* --- seats: extruded pillows; occupied = pressed --- */
.seat {
  position: absolute;
  width: clamp(96px, 26vw, 120px);
  height: clamp(96px, 26vw, 120px);
  background: var(--background);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-extruded);
  cursor: grab;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  font-size: var(--text-xs);
  user-select: none;
  padding: 10px;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  touch-action: none;
}

.seat:hover { box-shadow: var(--shadow-extruded-hover); }
.seat.dragging {
  cursor: grabbing;
  transform: rotate(2deg) scale(1.05);
  z-index: 1000;
  opacity: 0.98;
  box-shadow: var(--shadow-extruded-hover);
  transition: none;
}

/* functional gender coding via inset accent notches */
.seat.male { box-shadow: var(--shadow-extruded), inset 5px 0 0 var(--male-color); }
.seat.female { box-shadow: var(--shadow-extruded), inset 5px 0 0 var(--female-color); }

/* occupied = pressed into the board */
.seat.occupied {
  box-shadow: var(--shadow-inset);
  background: var(--background);
}
.seat.occupied:hover { box-shadow: var(--shadow-inset-deep); }
.seat.occupied.male { box-shadow: var(--shadow-inset), inset 5px 0 0 var(--male-color); }
.seat.occupied.female { box-shadow: var(--shadow-inset), inset 5px 0 0 var(--female-color); }

.seat.selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.student-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  padding: 6px 8px;
  border-radius: var(--radius-inner);
  background: rgba(255,255,255,0.6);
  color: var(--foreground);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.2;
}

.student-name[contenteditable="true"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.behavior-display {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 10px;
  gap: 6px;
  margin-top: 8px;
}

.behavior-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: var(--radius-full);
  background: var(--background);
  color: var(--muted-foreground);
  box-shadow: var(--shadow-inset-sm);
  font-weight: 700;
}

/* --- dashboard: extruded cards --- */
#dashboardContainer { padding: 26px 36px; }

#dashboardHeader {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--foreground);
  margin-bottom: 16px;
  padding-bottom: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

.student-card {
  background: var(--background);
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-extruded);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.student-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-extruded-hover); }

.card-header {
  padding: 16px 18px;
  background: var(--background);
}
.card-header h3 { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 800; color: var(--foreground); }

.card-body {
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.behavior-section h4 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-foreground);
  margin-bottom: 8px;
  font-weight: 700;
}

.behavior-list { list-style: none; padding: 0; }
.behavior-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
  padding: 6px 0;
}
.behavior-list .count { font-family: var(--font-mono); font-weight: 500; font-size: var(--text-base); }
.behavior-list .positive .count { color: var(--success-color); }
.behavior-list .negative .count { color: var(--danger-color); }

.card-footer {
  padding: 16px 18px;
  background: var(--background);
  text-align: center;
}
.net-score-label { font-family: var(--font-body); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-foreground); margin-bottom: 4px; }
.net-score-display { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 800; }
.net-score-positive { color: var(--success-color); }
.net-score-negative { color: var(--danger-color); }
.net-score-neutral { color: var(--muted-foreground); }

/* --- grouping --- */
#groupingControls {
  padding: 22px 36px;
  background: var(--background);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
#groupingResults { padding: 26px 36px; }

.grouping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}

.group-card {
  background: var(--background);
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-extruded);
  transition: transform var(--transition), box-shadow var(--transition);
}
.group-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-extruded-hover); }

.group-card-header {
  padding: 14px 16px;
  background: var(--background);
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: var(--text-xs);
  color: var(--accent);
}

.group-card-body { padding: 14px 16px; }
.group-card-body ul { list-style: none; padding: 0; }
.group-card-body li {
  padding: 9px 12px;
  border-radius: var(--radius-inner);
  color: var(--foreground);
  margin-bottom: 6px;
  background: var(--background);
  box-shadow: var(--shadow-inset-sm);
  font-weight: 500;
}
.group-card-body li:last-child { margin-bottom: 0; }

.group-card-body li.male-student { box-shadow: var(--shadow-inset-sm), inset 4px 0 0 var(--male-color); }
.group-card-body li.female-student { box-shadow: var(--shadow-inset-sm), inset 4px 0 0 var(--female-color); }

/* random student picker */
.random-student-result {
  text-align: center;
  margin: 18px auto;
  padding: 26px;
  border-radius: var(--radius-container);
  background: var(--background);
  box-shadow: var(--shadow-extruded-hover);
  max-width: 520px;
}
.random-student-result .label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-bottom: 8px;
}
.random-student-result .student-name-display {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 800;
  margin-top: 6px;
  padding: 12px 24px;
  border-radius: var(--radius-base);
  display: inline-block;
  background: var(--background);
  box-shadow: var(--shadow-inset);
}
.random-student-result .student-name-display.male { color: var(--male-color); box-shadow: var(--shadow-inset), inset 0 0 0 3px var(--male-color); }
.random-student-result .student-name-display.female { color: var(--female-color); box-shadow: var(--shadow-inset), inset 0 0 0 3px var(--female-color); }
.random-student-result .student-name-display.other { color: var(--muted-foreground); }

.random-student-actions {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* --- tracker --- */
.tracker-controls {
  padding: 22px 36px;
  background: var(--background);
}
#trackerContent { padding: 26px 36px; }

.tracker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 18px;
}
.tracker-student-info { display: flex; align-items: center; gap: 16px; }

.tracker-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: #fff;
  box-shadow: var(--shadow-extruded);
}
.tracker-avatar.male { background: var(--male-color); }
.tracker-avatar.female { background: var(--female-color); }
.tracker-avatar.other { background: var(--neutral-color); }

.tracker-name { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 800; color: var(--foreground); }

.tracker-gender-badge {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  margin-top: 4px;
  display: inline-block;
  background: var(--background);
  box-shadow: var(--shadow-inset-sm);
  color: var(--muted-foreground);
}
.tracker-gender-badge.male { color: var(--male-color); }
.tracker-gender-badge.female { color: var(--female-color); }

.tracker-trend { text-align: right; }
.trend-label { font-family: var(--font-body); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-foreground); margin-bottom: 4px; }
.trend-value { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 800; }
.trend-value.improving { color: var(--success-color); }
.trend-value.declining { color: var(--danger-color); }
.trend-value.stable { color: var(--warning-color); }

.tracker-section {
  background: var(--background);
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-extruded);
  margin-bottom: 26px;
  overflow: hidden;
}
.tracker-section-header {
  padding: 16px 18px;
  background: var(--background);
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: var(--text-xs);
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tracker-section-body { padding: 18px; }

/* ranking chart: inset track, colored extruded bars */
.ranking-chart { display: flex; flex-direction: column; gap: 10px; }
.ranking-bar-container { display: flex; align-items: center; gap: 12px; }
.ranking-bar-label {
  min-width: 120px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ranking-bar-label.current-student { color: var(--foreground); font-weight: 700; }

.ranking-bar-wrapper {
  flex: 1;
  height: 28px;
  background: var(--background);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-inset);
  overflow: hidden;
  position: relative;
}

.ranking-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: #fff;
  min-width: 30px;
  box-shadow: var(--shadow-extruded-sm);
}
.ranking-bar.positive { background: var(--success-color); }
.ranking-bar.negative { background: var(--danger-color); }
.ranking-bar.neutral { background: var(--neutral-color); }
.ranking-bar.current-student { background: var(--accent); }

.ranking-position { min-width: 40px; text-align: right; font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500; color: var(--muted-foreground); }
.ranking-position.top3 { color: var(--warning-color); font-weight: 700; }

/* timeline */
.timeline { position: relative; padding-left: 30px; max-height: none; overflow: visible; }
.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: var(--radius-full);
  background: rgb(163,177,198,0.7);
}
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -25px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-extruded-sm);
}
.timeline-dot.positive { background: var(--success-color); }
.timeline-dot.negative { background: var(--danger-color); }
.timeline-content {
  background: var(--background);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-extruded-sm);
  padding: 12px 14px;
}
.timeline-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.timeline-type { font-family: var(--font-body); font-weight: 700; font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; }
.timeline-type.positive { color: var(--success-color); }
.timeline-type.negative { color: var(--danger-color); }
.timeline-date { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted-foreground); }
.timeline-description { font-size: var(--text-sm); color: var(--muted-foreground); }
.timeline-empty { text-align: center; padding: 40px 20px; color: var(--muted-foreground); }
.timeline-month-divider {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  padding: 10px 0;
  margin-left: -30px;
}

/* stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--background);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-extruded-sm);
  padding: 16px;
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-extruded-hover); }
.stat-value { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 800; margin-bottom: 4px; }
.stat-value.positive { color: var(--success-color); }
.stat-value.negative { color: var(--danger-color); }
.stat-label { font-family: var(--font-body); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted-foreground); }

/* --- period view buttons --- */
.time-view-btn { padding: 12px 18px; border-radius: var(--radius-full); }
.time-view-btn.active {
  background: var(--background);
  color: var(--accent);
  box-shadow: var(--shadow-inset-sm);
  transform: translateY(0.5px);
}

/* --- timer --- */
#timerContainer { padding: 34px; text-align: center; }
.timer-tabs { display: flex; justify-content: center; gap: 12px; margin-bottom: 30px; flex-wrap: wrap; }
.timer-tab-btn { background: var(--background); color: var(--muted-foreground); padding: 13px 26px; border-radius: var(--radius-full); }
.timer-tab-btn.active { color: var(--accent); box-shadow: var(--shadow-inset-sm); transform: translateY(0.5px); }
.timer-tab-content.hidden { display: none; }

.timer-display-container {
  background: var(--background);
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-inset-deep);
  padding: 44px;
  margin-bottom: 30px;
  position: relative;
}

.timer-display {
  font-family: var(--font-mono);
  font-size: clamp(60px, 15vw, 120px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--foreground);
  letter-spacing: 0.02em;
}

.timer-alert {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 22px 44px;
  border-radius: var(--radius-container);
  display: none;
  z-index: 10;
}
.timer-alert.warning { background: var(--warning-color); color: #fff; display: block; box-shadow: var(--shadow-extruded-hover); }
.timer-alert.danger { background: var(--danger-color); color: #fff; display: block; box-shadow: var(--shadow-extruded-hover); }
.timer-alert.finished { background: var(--success-color); color: #fff; display: block; box-shadow: var(--shadow-extruded-hover); }

.timer-setup { margin-bottom: 20px; }
.timer-controls-row { display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }
.timer-btn { padding: 15px 32px; font-size: var(--text-sm); min-width: 140px; border-radius: var(--radius-full); }

/* --- noise meter --- */
#noiseContainer { padding: 34px; text-align: center; }

.noise-display-container {
  background: var(--background);
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-extruded);
  padding: 40px;
  margin-bottom: 30px;
}

.noise-meter {
  position: relative;
  height: 60px;
  background: var(--background);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-inset-deep);
  overflow: hidden;
  margin-bottom: 20px;
}

.noise-bar {
  height: 100%;
  width: 0%;
  transition: width 0.1s linear;
  border-radius: var(--radius-full);
}
.noise-bar.low { background: var(--success-color); }
.noise-bar.medium { background: var(--warning-color); }
.noise-bar.high { background: var(--danger-color); }
.noise-bar.extreme { background: var(--danger-color); animation: pulse-bar 0.5s ease-in-out infinite; }

@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.noise-levels {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  pointer-events: none;
}
.level-marker {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.noise-value { font-family: var(--font-display); font-size: clamp(40px, 10vw, 72px); font-weight: 800; color: var(--foreground); margin-bottom: 10px; }
.noise-status { font-family: var(--font-body); font-size: var(--text-sm); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-foreground); }
.noise-status.low { color: var(--success-color); }
.noise-status.medium { color: var(--warning-color); }
.noise-status.high { color: var(--danger-color); }
.noise-status.extreme { color: var(--danger-color); animation: blink 0.5s ease-in-out infinite; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.noise-settings {
  margin-top: 30px;
  padding: 24px;
  background: var(--background);
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-inset);
}

/* --- confetti (transient celebration) --- */
#confetti-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; overflow: hidden; }
.confetti { position: absolute; width: 10px; height: 10px; top: -20px; opacity: 0; border-radius: var(--radius-inner); animation: fall 4s linear forwards; }
@keyframes fall {
  0% { transform: translateY(0vh) rotateZ(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotateZ(720deg); opacity: 0; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  body { padding: 12px; }
  .header { padding: 16px 18px; border-radius: var(--radius-container) var(--radius-container) 0 0; }
  .header h1 { font-size: var(--text-xl); }
  .controls { padding: 18px; }
  .classroom-wrapper { margin: 16px; border-radius: var(--radius-base); }
  .control-group { flex-direction: column; align-items: flex-start; gap: 10px; }
  .control-group label { min-width: auto; }
  .dashboard-grid, .grouping-grid { grid-template-columns: 1fr; }
  #dashboardContainer { padding: 18px; }
  .seat { width: clamp(110px, 32vw, 140px); height: clamp(110px, 32vw, 140px); border-radius: var(--radius-base); }
  .student-name { font-size: var(--text-xs); -webkit-line-clamp: 3; }
  .tracker-header { flex-direction: column; align-items: flex-start; }
  .tracker-trend { text-align: left; }
  .ranking-bar-label { min-width: 80px; font-size: var(--text-xs); }
  .timer-display { font-size: clamp(40px, 12vw, 80px); }
  .timer-btn { min-width: 100px; padding: 12px 20px; }
  .student-cards-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  #timerContainer, #noiseContainer { padding: 20px; }
}
