/* ===== DESIGN TOKENS (from styles.css) ===== */
:root {
  --primary: #6c63ff;
  --primary-dark: #5a52e0;
  --accent: #8b83ff;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --bg: #faf6f1;
  --bg-alt: #f3ede5;
  --surface: #ffffff;
  --surface-alt: #f8f4ef;
  --text: #1a1a2e;
  --text-secondary: #5a5a7a;
  --text-muted: #8a8aaa;
  --border: #e8e4df;
  --shadow-sm: 0 2px 8px rgba(108,99,255,0.06);
  --shadow-md: 0 4px 20px rgba(108,99,255,0.1);
  --shadow-lg: 0 8px 40px rgba(108,99,255,0.14);
  --shadow-card: 0 2px 16px rgba(0,0,0,0.06);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 100px;
  --font: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  --gradient: linear-gradient(135deg, var(--primary), var(--accent));
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }

/* ===== LAYOUT ===== */
.dash-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 270px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-brand {
  padding: 28px 28px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .logo {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.sidebar-brand .logo span { color: var(--primary); }

.sidebar-user {
  margin-top: 14px;
}

.sidebar-user-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  display: block;
}

.sidebar-user-school {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 28px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-nav a.active {
  background: rgba(108,99,255,0.06);
  color: var(--primary);
  border-left-color: var(--primary);
}

.sidebar-nav a svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav a.active svg { opacity: 1; }

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 28px;
}

/* ===== MAIN CONTENT ===== */
.main {
  flex: 1;
  margin-left: 270px;
  padding: 40px 48px;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 36px;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
}

.page-header-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== STAT CARDS ===== */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.stat-card-icon svg {
  width: 24px;
  height: 24px;
}

.stat-card-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ===== SECTION ===== */
.section {
  margin-bottom: 40px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  line-height: 1;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-primary {
  background: var(--gradient);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 2px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm { padding: 9px 18px; font-size: 0.85rem; }

/* ===== TABLE ===== */
.data-table {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--surface-alt);
  padding: 16px 20px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-align: left;
}

.data-table td {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: var(--surface-alt);
}

.data-table tr { cursor: pointer; }

.data-table code {
  background: rgba(108,99,255,0.06);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-family: 'Fira Code', monospace;
  font-size: 0.82rem;
  font-weight: 700;
}

/* ===== PROGRESS BAR (inline in table) ===== */
.progress-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-track {
  flex: 1;
  height: 8px;
  background: var(--bg-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
  max-width: 120px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
}

/* ===== CLASS CARDS ===== */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.class-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
}

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

.class-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.class-card-top h3 {
  font-size: 1.2rem;
  font-weight: 800;
}

.class-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.class-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.class-stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== BADGE ===== */
.badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-admin { background: rgba(108,99,255,0.08); color: var(--primary); }
.badge-teacher { background: rgba(74,222,128,0.1); color: #16a34a; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 40px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
}

.empty-state h3 {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 24px 20px; }
  .stat-row { grid-template-columns: 1fr; }
  .class-grid { grid-template-columns: 1fr; }
}
/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 52px 44px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 440px;
}

.login-card .logo {
  font-size: 2.2rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text);
  letter-spacing: -0.5px;
}

.login-card h2 { text-align: center; font-size: 1.4rem; margin-bottom: 6px; }
.login-card .subtitle { text-align: center; color: var(--text-muted); font-size: 0.95rem; margin-bottom: 32px; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 700; font-size: 0.88rem; color: var(--text); margin-bottom: 8px; }

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,99,255,0.1); }

.login-btn {
  width: 100%;
  padding: 16px;
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: transform 0.15s, box-shadow 0.15s;
}

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

.login-footer { text-align: center; margin-top: 28px; font-size: 0.9rem; color: var(--text-muted); }
.login-footer a { color: var(--primary); font-weight: 700; cursor: pointer; }

.login-error { color: var(--error); font-size: 0.85rem; font-weight: 600; text-align: center; margin-bottom: 16px; min-height: 20px; }

.login-divider {
  display: flex; align-items: center; gap: 16px; margin: 28px 0;
  color: var(--text-muted); font-size: 0.82rem; font-weight: 600;
}
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ===== CLASS DETAIL ===== */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; font-weight: 600; color: var(--primary); margin-bottom: 8px; }

.class-info-bar {
  display: flex; align-items: center; gap: 20px; margin-bottom: 36px;
  padding: 20px 28px; background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-card);
}
.class-info-bar h1 { font-size: 1.6rem; }
.class-info-sep { width: 1px; height: 40px; background: var(--border); }
.class-info-item { text-align: center; }
.class-info-value { font-size: 1.3rem; font-weight: 800; color: var(--text); }
.class-info-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== STUDENT DETAIL ===== */
.student-header {
  display: flex; align-items: center; gap: 24px; margin-bottom: 36px;
  padding: 28px 32px; background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-card);
}
.student-avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1.4rem; flex-shrink: 0;
}
.student-header h1 { font-size: 1.6rem; margin-bottom: 2px; }
.student-meta { font-size: 0.9rem; color: var(--text-muted); }
.student-meta code {
  background: rgba(108,99,255,0.06); color: var(--primary); padding: 3px 10px;
  border-radius: var(--radius-full); font-family: 'Fira Code', monospace; font-size: 0.82rem; font-weight: 700;
}

/* WPM Chart */
.wpm-chart {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-card);
  padding: 28px; margin-bottom: 36px;
}
.wpm-chart h2 { font-size: 1.15rem; margin-bottom: 20px; }
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 10px; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bar { width: 100%; max-width: 48px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.chart-bar-label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); }
.chart-bar-value { font-size: 0.78rem; font-weight: 800; color: var(--text); }

/* ===== TEACHER CARDS ===== */
.teacher-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}
.teacher-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 28px;
  border: 1px solid var(--border); box-shadow: var(--shadow-card);
  display: flex; align-items: center; gap: 18px;
}
.teacher-avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1.1rem; flex-shrink: 0;
}
.teacher-card-name { font-weight: 800; font-size: 1rem; margin-bottom: 2px; }
.teacher-card-email { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }

/* Badges */
.badge { display: inline-block; padding: 4px 14px; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-admin { background: rgba(108,99,255,0.08); color: var(--primary); }
.badge-teacher { background: rgba(74,222,128,0.1); color: #16a34a; }

/* ===== RESPONSIVE extras ===== */
@media (max-width: 768px) {
  .login-card { padding: 32px 24px; }
  .class-info-bar { flex-direction: column; gap: 16px; }
  .student-header { flex-direction: column; text-align: center; }
  .teacher-cards { grid-template-columns: 1fr; }
}

/* Demo mode — hide all write action buttons */
.demo-mode .btn-primary:not(.login-btn),
.demo-mode button[onclick*="delete"],
.demo-mode button[onclick*="Delete"],
.demo-mode button[onclick*="Remove"],
.demo-mode [onclick*="showCreate"],
.demo-mode [onclick*="showAdd"] {
  display: none !important;
}

/* Show a small demo badge */
.demo-mode .sidebar-user-name::after {
  content: ' (Demo)';
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 400;
}

/* CEO mode — hide school-specific sidebar items */
.ceo-mode [data-section="classes"],
.ceo-mode [data-section="students"],
.ceo-mode [data-section="teachers"] {
  display: none !important;
}

/* Non-CEO users: hide CEO-only sidebar items */
body:not(.ceo-mode) [data-section="leads"] {
  display: none !important;
}
