/* GuardRAIl v2 - Popup Styles (Modern EdTech Design) */
/* Inspired by: Google Classroom, Canvas, Schoology, Seesaw, ClassDojo */

/* Design tokens are loaded via <link> tag in popup.html */

/* === RESET === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === BASE === */
body {
  font-family: var(--font-family);
  background: var(--color-background-alt);
  color: var(--color-foreground);
  width: 360px;
  min-height: 480px;
  line-height: 1.5;
}

/* === CONTAINER === */
.container {
  display: flex;
  flex-direction: column;
  min-height: 480px;
  background: var(--color-card);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin: var(--space-3);
  box-shadow: var(--shadow-lg);
  position: relative;
}

/* === HEADER === */
.header {
  padding: var(--space-4) var(--space-5);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base);
}

.logo-icon svg {
  display: block;
}

.logo-icon:hover {
  transform: scale(1.05);
}

.logo-text {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: white;
  letter-spacing: var(--letter-spacing-tight);
}

/* Header right: theme + power (power only visible when logged in) */
.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Theme Toggle - subtle */
.theme-toggle {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.theme-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 1px;
}

/* Feedback button (speech bubble + exclamation) - matches header aesthetic */
.header-feedback-btn {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.header-feedback-btn.hidden {
  display: none;
}
.header-feedback-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}
.header-feedback-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 1px;
}
.feedback-icon {
  width: 16px;
  height: 16px;
  display: block;
}

/* GuardRAIl toggle in header: lock icon, On = solid white, Off = muted */
.guardrail-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all var(--transition-base);
  flex-shrink: 0;
  overflow: visible;
}

.guardrail-toggle-btn.hidden {
  display: none;
}

/* In header (on blue): ON = white pill, show locked icon */
.header .guardrail-toggle-btn[aria-checked="true"],
.header .guardrail-toggle-btn[data-state="on"] {
  background: white;
  color: var(--color-primary);
  border-color: white;
}
.header .guardrail-toggle-btn[aria-checked="true"] .guardrail-icon,
.header .guardrail-toggle-btn[data-state="on"] .guardrail-icon {
  stroke: var(--color-primary);
}
.header .guardrail-toggle-btn[aria-checked="true"] .icon-unlocked,
.header .guardrail-toggle-btn[data-state="on"] .icon-unlocked {
  display: none;
}
.header .guardrail-toggle-btn[aria-checked="true"] .icon-locked,
.header .guardrail-toggle-btn[data-state="on"] .icon-locked {
  display: block;
}
.header .guardrail-toggle-btn[aria-checked="true"]:hover,
.header .guardrail-toggle-btn[data-state="on"]:hover {
  background: rgba(255, 255, 255, 0.95);
  transform: scale(1.05);
}

/* In header: OFF = muted, show unlocked icon */
.header .guardrail-toggle-btn[aria-checked="false"],
.header .guardrail-toggle-btn[data-state="off"] {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.25);
}
.header .guardrail-toggle-btn[aria-checked="false"] .guardrail-icon,
.header .guardrail-toggle-btn[data-state="off"] .guardrail-icon {
  stroke: rgba(255, 255, 255, 0.85);
}
.header .guardrail-toggle-btn[aria-checked="false"] .icon-locked,
.header .guardrail-toggle-btn[data-state="off"] .icon-locked {
  display: none;
}
.header .guardrail-toggle-btn[aria-checked="false"] .icon-unlocked,
.header .guardrail-toggle-btn[data-state="off"] .icon-unlocked {
  display: block;
}
.header .guardrail-toggle-btn[aria-checked="false"]:hover,
.header .guardrail-toggle-btn[data-state="off"]:hover {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}
.header .guardrail-toggle-btn[aria-checked="false"]:hover .guardrail-icon,
.header .guardrail-toggle-btn[data-state="off"]:hover .guardrail-icon {
  stroke: white;
}

.guardrail-toggle-btn:active {
  transform: scale(0.98);
}
.guardrail-toggle-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 1px;
}

.guardrail-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  position: relative;
}
.guardrail-icon {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  overflow: visible;
}
.guardrail-toggle-label {
  line-height: 1;
}

/* === VIEWS === */
.view {
  padding: var(--space-5);
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Welcome view: welcome + student buttons, then "or" + Teacher Login */
.welcome-view {
  display: flex;
  flex-direction: column;
}

.welcome-view .welcome-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.welcome-view .auth-options {
  margin-top: var(--space-5);
}

.view.hidden {
  display: none;
}

/* Dashboard view - warmer, aligned with app aesthetics */
.view-dashboard {
  background: var(--color-primary-lighter);
}

/* === WELCOME SECTION (Friendly, encouraging) === */
.welcome {
  margin-bottom: var(--space-6);
  text-align: center;
}

.welcome h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-foreground);
  letter-spacing: var(--letter-spacing-tight);
  margin-bottom: var(--space-2);
  line-height: var(--line-height-tight);
}

/* OPTIMIZED: Simplified wave animation - runs once on load, not infinite */
.welcome-emoji {
  display: inline-block;
  font-size: 28px;
  margin-right: var(--space-2);
  animation: wave 1s ease-in-out 1;
  transform-origin: 70% 70%;
  will-change: transform;
}

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(14deg); }
  50% { transform: rotate(-8deg); }
  75% { transform: rotate(14deg); }
}

.welcome p {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  color: var(--color-foreground-muted);
  line-height: var(--line-height-normal);
}

/* Encouraging subtext */
.welcome-hint {
  font-size: 13px;
  color: var(--color-foreground-subtle);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.welcome-hint::before {
  content: 'i';
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 50%;
  margin-right: var(--space-1);
}

/* === AUTH OPTIONS === */
.auth-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* === FORMS === */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-group label {
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  color: var(--color-foreground-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.form-group input {
  padding: var(--space-3) var(--space-4);
  background: var(--color-background-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-foreground);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  transition: all var(--transition-base);
}

.form-group input:focus {
  outline: none;
  background: var(--color-background);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-lighter);
}

.form-group input:hover:not(:focus) {
  border-color: var(--color-border);
}

.form-group input::placeholder {
  color: var(--color-foreground-subtle);
  font-weight: var(--font-weight-regular);
}

.form-group textarea {
  padding: var(--space-3) var(--space-4);
  background: var(--color-background-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-foreground);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  resize: vertical;
  min-height: 80px;
  transition: all var(--transition-base);
}
.form-group textarea:focus {
  outline: none;
  background: var(--color-background);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-lighter);
}
.form-group textarea::placeholder {
  color: var(--color-foreground-subtle);
}

.label-hint {
  font-size: 11px;
  font-weight: var(--font-weight-regular);
  color: var(--color-foreground-subtle);
  text-transform: none;
  letter-spacing: 0;
  margin-top: var(--space-1);
}

.form-hint {
  font-size: 12px;
  color: var(--color-foreground-subtle);
  margin-top: var(--space-1);
}

/* Classroom Badge */
.classroom-badge {
  padding: var(--space-3) var(--space-4);
  background: var(--color-secondary-light);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--color-secondary);
  text-align: center;
  font-weight: var(--font-weight-semibold);
  margin-top: var(--space-2);
}

.classroom-badge.hidden {
  display: none;
}

/* Student Fields */
.student-fields-container {
  margin-top: var(--space-2);
}

.student-fields-container.hidden {
  display: none;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: var(--space-4) 0;
  color: var(--color-foreground-subtle);
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 2px solid var(--color-border);
}

.divider span {
  padding: 0 var(--space-3);
}

/* Error */
.error {
  padding: var(--space-3) var(--space-4);
  background: var(--color-error-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--color-error);
  font-weight: var(--font-weight-medium);
}

.error.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

/* === BUTTONS (Duolingo inspired, playful) === */
.btn {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-base);
  border: none;
  text-align: center;
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  position: relative;
}

.btn:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary Button */
.btn-primary {
  background: var(--color-primary);
  color: white;
  border: none;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  background: var(--color-primary-active);
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

/* Secondary Button */
.btn-secondary {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  color: var(--color-foreground);
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-base);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-card-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:active:not(:disabled) {
  background: var(--color-card-active);
  transform: translateY(0);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--color-foreground-muted);
  padding: 12px var(--space-4);
  border: none;
  box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--color-primary);
  background: var(--color-primary-light);
  transform: translateY(-2px);
}

/* Accent Button (for special actions) */
.btn-accent {
  background: linear-gradient(180deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
  color: white;
  box-shadow: 0 4px 0 0 #C55A00, 0 6px 12px rgba(255, 146, 43, 0.3);
}

/* Google Button */
.btn-google {
  background: white;
  color: #1A202C;
  border: 2px solid var(--color-border);
  box-shadow: 0 3px 0 0 var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-weight: var(--font-weight-semibold);
}

[data-theme="dark"] .btn-google {
  background: var(--color-card);
  color: var(--color-foreground);
  border-color: var(--color-border);
}

.btn-google:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 0 var(--color-border);
  border-color: #4285F4;
}

.btn-google:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 0 var(--color-border);
}

.google-icon {
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #4285F4 0%, #34A853 50%, #FBBC05 75%, #EA4335 100%);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-bold);
  font-size: 12px;
  color: white;
  flex-shrink: 0;
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 0 #C55A00, 0 10px 20px rgba(255, 146, 43, 0.35);
}

/* Small Button */
.btn-small {
  padding: var(--space-2) var(--space-3);
  font-size: 13px;
  box-shadow: 0 2px 0 0 currentColor;
}

/* === DASHBOARD VIEW (Dashboard style) === */
.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: all var(--transition-base);
}

.user-info {
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-card) 100%);
  border-color: var(--color-primary-lighter);
}

.user-info:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.user-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-lg);
}

.user-avatar-wrap:hover .user-avatar {
  box-shadow: var(--shadow-md);
}

.user-avatar-wrap:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.user-avatar {
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: var(--font-weight-bold);
  color: white;
  transition: transform var(--transition-base), background var(--transition-base);
  box-shadow: var(--shadow-sm);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.user-avatar.avatar-emoji {
  font-size: 24px;
}

.user-avatar.avatar-icon-svg {
  font-size: 0;
  padding: 0;
}

.user-avatar.avatar-icon-svg svg {
  width: 26px;
  height: 26px;
}

.user-info:hover .user-avatar {
  transform: scale(1.05);
}

.user-details {
  position: relative;
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-foreground);
  margin-bottom: var(--space-1);
  letter-spacing: var(--letter-spacing-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* School pill (placeholder until DB) */
.user-school-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--color-background-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-foreground-muted);
}

.user-school-pill-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-foreground-subtle);
}

.user-school-pill-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.user-access-code {
  font-size: 11px;
  color: var(--color-foreground-subtle);
  margin-top: 4px;
}

.user-access-code code {
  background: var(--color-background);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  letter-spacing: 0.5px;
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-foreground);
}

/* === HERO METRIC (Learning Focus) === */
.stat-hero {
  background: linear-gradient(180deg, var(--color-card) 0%, var(--color-primary-lighter) 100%);
  border: 1px solid var(--color-primary-lighter);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  text-align: center;
  position: relative;
  overflow: visible;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.3s ease both;
  transition: all var(--transition-base);
}

.stat-hero:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.stat-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--color-primary);
}

/* Tile title pill - top left */
.stat-tile-pill {
  position: absolute;
  top: var(--space-3);
  left: var(--space-4);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
}

.stat-hero-pill {
  background: var(--color-primary);
  color: white;
}

.stat-card-streak-pill {
  background: var(--color-stat-orange);
  color: white;
}

.stat-hero-value-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
}

.stat-hero-value {
  font-size: 56px;
  font-weight: var(--font-weight-extrabold);
  color: var(--color-foreground);
  line-height: 1;
  display: inline-block;
}

.stat-hero-max {
  font-size: 42px;
  font-weight: var(--font-weight-extrabold);
  color: var(--color-foreground);
  display: inline-block;
  line-height: 1;
  padding-bottom: 4px;
}

.stat-hero-progress {
  width: 100%;
  height: 12px;
  background: var(--color-muted);
  border-radius: var(--radius-full);
  margin: var(--space-4) 0 var(--space-2);
  overflow: hidden;
  border: 2px solid var(--color-border);
}

.stat-hero-desc {
  font-size: var(--font-size-xs);
  color: var(--color-foreground-muted);
  margin: 0;
  line-height: 1.4;
}

.stat-hero-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 800ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  position: relative;
  overflow: hidden;
}

/* Animated shimmer effect on progress bar */
.stat-hero-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progress-shimmer 2s ease-in-out infinite;
}

@keyframes progress-shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* === STATS GRID (Dashboard style) === */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
  animation: fadeIn 0.4s ease 0.1s both;
  max-width: 100%;
}

.stat-card {
  background: linear-gradient(180deg, var(--color-card) 0%, var(--color-background-alt) 100%);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  text-align: center;
  transition: all var(--transition-base);
  position: relative;
  overflow: visible;
  box-shadow: var(--shadow-sm);
  cursor: help;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-border);
  z-index: 10;
}

/* Colored top accent bar */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.stat-card-streak::before { 
  background: var(--color-stat-orange); 
}

.stat-card-streak {
  padding-top: 2.5rem;
}

/* Slate - not in teacher classroom color palette */
.stat-card-classrooms::before {
  background: #64748B;
}

.stat-card-classrooms {
  padding-top: 2.5rem;
  text-align: left;
}

.stat-card-classrooms-pill {
  background: #64748B;
  color: white;
}

.connected-classrooms-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
  min-height: 32px;
}

.connected-classroom-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: white;
  border: none;
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connected-classroom-pill .connected-classroom-icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  opacity: 0.95;
}

.connected-classroom-pill .connected-classroom-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.stat-card-quality::before { 
  background: linear-gradient(90deg, var(--color-stat-green) 0%, #4ADE80 100%); 
}

.stat-card-moments::before { 
  background: linear-gradient(90deg, var(--color-stat-blue) 0%, #818CF8 100%); 
}

/* Dashboard Stat Icon */
.stat-icon {
  font-size: 28px;
  margin-bottom: var(--space-2);
  display: block;
  transition: transform var(--transition-bounce);
}

.stat-card:hover .stat-icon {
  transform: scale(1.2) rotate(-5deg);
}

/* Streak Icon - Star, scale grows with streak, gentle pulse */
.stat-icon-streak {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2);
  --streak-scale: 0.8;
}

.stat-icon-streak[data-streak="1"],
.stat-icon-streak[data-streak="2"] { --streak-scale: 0.9; }
.stat-icon-streak[data-streak="3"],
.stat-icon-streak[data-streak="4"] { --streak-scale: 1; }
.stat-icon-streak[data-streak="5"],
.stat-icon-streak[data-streak="6"] { --streak-scale: 1.1; }
.stat-icon-streak[data-streak="7"],
.stat-icon-streak[data-streak="8"],
.stat-icon-streak[data-streak="9"] { --streak-scale: 1.25; }
.stat-icon-streak[data-streak="10"],
.stat-icon-streak[data-streak="11"],
.stat-icon-streak[data-streak="12"],
.stat-icon-streak[data-streak="13"],
.stat-icon-streak[data-streak="14"],
.stat-icon-streak[data-streak="15"],
.stat-icon-streak[data-streak="16"],
.stat-icon-streak[data-streak="17"],
.stat-icon-streak[data-streak="18"],
.stat-icon-streak[data-streak="19"],
.stat-icon-streak[data-streak="20"] { --streak-scale: 1.4; }

.stat-streak-svg {
  color: var(--color-stat-orange);
  transform: scale(var(--streak-scale, 1));
  animation: streak-glow 2.5s ease-in-out infinite;
}

@keyframes streak-glow {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 2px rgba(242, 92, 5, 0.4)); }
  50% { opacity: 0.88; filter: drop-shadow(0 0 6px rgba(242, 92, 5, 0.5)); }
}

.stat-icon-quality::before {
  content: '✓';
  font-size: 28px;
  color: var(--color-stat-green);
  line-height: 1;
  display: block;
  font-weight: var(--font-weight-bold);
}

.stat-icon-moments::before {
  content: '◉';
  font-size: 28px;
  color: var(--color-stat-blue);
  line-height: 1;
  display: block;
  font-weight: normal;
}

.stat-value {
  font-size: 42px;
  font-weight: var(--font-weight-extrabold);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-2);
  line-height: 1;
  color: var(--color-foreground);
  transition: transform var(--transition-bounce), color var(--transition-base);
}

.stat-card:hover .stat-value {
  transform: scale(1.05);
  color: var(--color-primary);
}

.stat-value-container {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-2);
  position: relative;
}

.stat-trend {
  font-size: 20px;
  font-weight: var(--font-weight-bold);
  line-height: 1;
  position: absolute;
  top: -8px;
  right: -12px;
}

/* Trend indicators removed - using glow borders instead */

/* Responsive adjustments */
@media (max-width: 320px) {
  .stat-hero-value {
    font-size: 48px;
  }
  
  .stat-hero-max {
    font-size: 28px;
  }
}

/* Animated number highlight on good stats */
.stat-value.highlight {
  animation: stat-pop 0.3s ease;
}

@keyframes stat-pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.stat-label {
  font-size: 11px;
  color: var(--color-foreground-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--font-weight-semibold);
}

/* Mini progress bar under stat */
.stat-progress {
  margin-top: var(--space-3);
  height: 5px;
  background: var(--color-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.stat-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.stat-card-streak .stat-progress-fill { background: var(--color-stat-orange); }
.stat-card-quality .stat-progress-fill { background: var(--color-stat-green); }
.stat-card-moments .stat-progress-fill { background: var(--color-stat-blue); }

/* Empty state */
.stat-value.empty {
  opacity: 0.25;
  font-size: 28px;
}

.stat-card.empty-state {
  opacity: 0.6;
  border: 2px dashed var(--color-border);
  box-shadow: none;
}

/* Streak badge (Duolingo style) */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--color-streak-light);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  color: #B8860B;
  margin-top: var(--space-2);
}

.streak-badge::before {
  content: '🔥';
  font-size: 12px;
}

/* === ACTIONS === */
.actions {
  display: flex;
  gap: var(--space-3);
  margin-top: auto;
}

.actions .btn {
  flex: 1;
  padding: 12px var(--space-4);
  font-size: 13px;
}

/* === AVATAR EDIT MODAL === */
.avatar-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.avatar-modal.hidden {
  display: none;
}

.avatar-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.avatar-modal-content {
  position: relative;
  background: var(--color-card);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 320px;
}

.avatar-modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-foreground);
  margin-bottom: var(--space-1);
}

.avatar-modal-hint {
  font-size: var(--font-size-sm);
  color: var(--color-foreground-muted);
  margin-bottom: var(--space-4);
}

.avatar-modal-icons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.avatar-icon-opt {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: var(--color-background-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--color-foreground-muted);
  padding: 0;
}

.avatar-icon-opt svg {
  width: 24px;
  height: 24px;
}

.avatar-icon-opt:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  transform: scale(1.05);
}

.avatar-icon-opt.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 2px var(--color-primary-lighter);
}

.avatar-modal-colors {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.avatar-color-opt {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.avatar-color-opt:hover {
  transform: scale(1.15);
}

.avatar-color-opt.selected {
  border-color: var(--color-foreground);
  box-shadow: 0 0 0 2px var(--color-card);
}

#avatar-modal-done {
  width: 100%;
}

/* === FOOTER LINK (or + Teacher Login, just below student buttons) === */
.footer-link {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.footer-link .divider {
  width: 100%;
  margin: 0 0 var(--space-3) 0;
}

.footer-link .btn {
  width: 100%;
  color: var(--color-foreground-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px;
}

.footer-link .btn.teacher-dashboard-login-btn {
  font-size: var(--font-size-base);
  text-transform: none;
  letter-spacing: var(--letter-spacing-tight);
  padding: var(--space-3) var(--space-5);
}

/* === REFRESH BUTTON === */
.refresh-btn {
  width: 32px;
  height: 32px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-foreground-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.refresh-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: rotate(180deg) scale(1.1);
}

/* Loading state for refresh button */
.refresh-btn.loading {
  animation: spin 1s linear infinite;
  pointer-events: none;
}

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

/* === ANIMATIONS === */
@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(8px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.view {
  animation: fadeIn 0.3s ease;
}

/* Staggered animations for dashboard elements */
.user-info {
  animation: slideInUp 0.3s ease both;
}

.stat-hero {
  animation: slideInUp 0.4s ease 0.1s both;
}

.stat-card:nth-child(1) {
  animation: scaleIn 0.3s ease 0.2s both;
}

/* Loading Skeleton */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-muted) 25%,
    var(--color-background-alt) 50%,
    var(--color-muted) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
}

.skeleton-stat {
  height: 40px;
  width: 60px;
  margin: 0 auto var(--space-2);
  border-radius: var(--radius-md);
}

/* Enhanced skeleton for hero stat */
.skeleton-hero {
  height: 80px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}

/* Pulse animation for loading states */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Focus Ring Enhancement */
*:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Skip to content link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: var(--radius-md);
  z-index: 1000;
  font-weight: var(--font-weight-bold);
}

.skip-link:focus {
  top: 0;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === CELEBRATION ANIMATIONS (Duolingo style) === */
@keyframes confetti-fall {
  0% { transform: translateY(-100%) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes celebrate-bounce {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.1) rotate(-3deg); }
  50% { transform: scale(1.15); }
  75% { transform: scale(1.1) rotate(3deg); }
}

.celebrate {
  animation: celebrate-bounce 0.6s ease;
}

/* Achievement Badge */
.achievement {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: linear-gradient(135deg, var(--color-streak-light) 0%, #FFF9DB 100%);
  border: 2px solid var(--color-streak);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  color: #B8860B;
  box-shadow: 0 2px 8px rgba(255, 212, 59, 0.3);
}

.achievement-icon {
  font-size: 16px;
}

/* Milestone celebration */
.milestone {
  text-align: center;
  padding: var(--space-5);
  background: linear-gradient(180deg, var(--color-secondary-light) 0%, var(--color-card) 100%);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-4);
}

.milestone-icon {
  font-size: 48px;
  margin-bottom: var(--space-2);
  animation: celebrate-bounce 1s ease infinite;
}

.milestone-title {
  font-size: 18px;
  font-weight: var(--font-weight-extrabold);
  color: var(--color-secondary);
  margin-bottom: var(--space-1);
}

.milestone-desc {
  font-size: 13px;
  color: var(--color-foreground-muted);
}

/* Progress Ring (circular progress like Khan Academy) */
.progress-ring {
  position: relative;
  width: 60px;
  height: 60px;
}

.progress-ring-circle {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.progress-ring-bg {
  fill: none;
  stroke: var(--color-muted);
  stroke-width: 6;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--color-secondary);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

/* Encouragement toast */
.encouragement {
  position: fixed;
  bottom: var(--space-4);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: var(--space-3) var(--space-5);
  background: var(--color-secondary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: var(--font-weight-bold);
  box-shadow: 0 4px 16px rgba(56, 176, 0, 0.4);
  opacity: 0;
  transition: all var(--transition-bounce);
  z-index: 100;
}

.encouragement.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.encouragement::before {
  content: '🎉';
  margin-right: var(--space-2);
}
