/* ============================================================
   IGA Academy — Design System v3 (Modern)
   Brand: #be3448 · Font: Inter
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Brand ── */
  --primary:        #be3448;
  --primary-dark:   #9c2a3a;
  --primary-light:  #fce8eb;
  --primary-50:     #fdf4f5;

  /* ── Status ── */
  --success:        #059669;
  --success-light:  #d1fae5;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --info:           #0284c7;
  --info-light:     #e0f2fe;

  /* ── Sidebar ── */
  --sidebar-bg:     #111827;
  --sidebar-top:    #0d1117;
  --sidebar-text:   rgba(255,255,255,.5);
  --sidebar-active: #be3448;
  --sidebar-hover:  rgba(255,255,255,.06);
  --sidebar-border: rgba(255,255,255,.07);

  /* ── Neutral ── */
  --bg:             #f8fafc;
  --bg-secondary:   #f3f4f6;
  --surface:        #ffffff;
  --border:         #e5e7eb;
  --border-light:   #f3f4f6;

  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;

  /* ── Geometry ── */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 20px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.15);

  --sidebar-w:  256px;
  --transition: 150ms ease;
}

/* ── Base ─────────────────────────────────────────────────── */
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.flatpickr-wrapper { display: block !important; width: 100% !important; }
html { font-size: 15px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }

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

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(255,255,255,.04);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--sidebar-top);
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 68px;
}
.logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.logo-icon { font-size: 26px; flex-shrink: 0; }
.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.2px;
  line-height: 1.2;
}

/* Role Switcher */
.role-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--sidebar-border);
}
.role-btn {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  color: var(--sidebar-text);
  background: rgba(255,255,255,.08);
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.role-btn.active, .role-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: rgba(255,255,255,.25);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,.85);
}
.nav-item.active {
  background: rgba(190,52,72,.15);
  color: #f87185;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-item .icon { width: 17px; height: 17px; flex-shrink: 0; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 14px;
  border-top: 1px solid var(--sidebar-border);
  background: var(--sidebar-top);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-name {
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-id { font-size: 11px; color: var(--sidebar-text); }
.btn-logout {
  color: rgba(255,255,255,.3);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
}
.btn-logout:hover { color: #f87185; background: rgba(190,52,72,.15); }
.btn-logout .icon { width: 17px; height: 17px; }

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  min-width: 0;
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.5px;
}
.page-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 3px;
}
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--primary); font-weight: 500; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-muted); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .icon { width: 16px; height: 16px; color: var(--primary); }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon .icon { width: 20px; height: 20px; }
.stat-icon.indigo { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.amber  { background: var(--warning-light); color: var(--warning); }
.stat-icon.blue   { background: var(--info-light);    color: var(--info); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1.2; letter-spacing: -.5px; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  outline: none;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: -.1px;
}
.btn .icon { width: 15px; height: 15px; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(190,52,72,.3); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #d1d5db; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; box-shadow: 0 4px 12px rgba(5,150,105,.25); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-ghost     { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }
.btn-sm  { padding: 5px 11px; font-size: 12px; }
.btn-sm .icon { width: 13px; height: 13px; }
.btn-lg  { padding: 11px 24px; font-size: 15px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.btn-icon.btn-sm { padding: 5px; width: 28px; height: 28px; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .1px;
}
.badge-primary   { background: var(--primary-light); color: var(--primary); }
.badge-success   { background: var(--success-light); color: var(--success); }
.badge-warning   { background: var(--warning-light); color: var(--warning); }
.badge-danger    { background: var(--danger-light);  color: var(--danger); }
.badge-info      { background: var(--info-light);    color: var(--info); }
.badge-secondary { background: #f3f4f6; color: #6b7280; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  transition: var(--transition);
  outline: none;
  font-family: inherit;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(190,52,72,.1); }
.form-control:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.1); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 5px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group input[type="checkbox"] {
  width: 17px; height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}
.checkbox-group label { font-size: 14px; cursor: pointer; }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--bg);
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-light); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 12px 16px; vertical-align: middle; }
.table-actions { display: flex; gap: 6px; align-items: center; }

/* ============================================================
   Attendance & Test Matrices
   ============================================================ */
.matrix-wrap {
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  max-height: 70vh;
}
.matrix-table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.matrix-table th,
.matrix-table td {
  border: 1px solid var(--border);
  padding: 0;
  text-align: center;
  vertical-align: middle;
}
.matrix-table thead th {
  background: #1e2837;
  color: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .4px;
  padding: 10px 8px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 3;
}
.matrix-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  text-align: left;
  padding-left: 14px;
  min-width: 180px;
  background: #151f2e;
}
.matrix-table tbody td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  white-space: nowrap;
  border-right: 2px solid var(--border);
}
.matrix-table tbody tr:hover td:first-child { background: var(--primary-50); }
.matrix-table tfoot td {
  background: var(--primary-50);
  font-weight: 700;
  font-size: 12px;
  padding: 10px 8px;
  color: var(--primary);
}
.matrix-table tfoot td:first-child {
  position: sticky; left: 0; z-index: 2;
  text-align: left; padding-left: 14px;
}

.matrix-cb { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; }
.matrix-cb input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

.result-cell {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
}
.result-cell:hover { background: var(--primary-50); }
.result-cell.correct { background: var(--success-light); color: var(--success); }
.result-cell.wrong   { background: var(--danger-light);  color: var(--danger); }
.result-cell.empty   { background: var(--bg); color: var(--text-muted); }
.result-cell .icon { width: 16px; height: 16px; }

.summary-cell { padding: 6px 12px !important; white-space: nowrap; }
.summary-val { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.summary-pct {
  font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 12px;
  margin-top: 2px; display: inline-block;
}
.pct-high   { background: var(--success-light); color: var(--success); }
.pct-medium { background: var(--warning-light); color: var(--warning); }
.pct-low    { background: var(--danger-light);  color: var(--danger); }

/* ============================================================
   Alerts & Flash
   ============================================================ */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
  border-left: 4px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-success { background: var(--success-light); color: #065f46; border-color: var(--success); }
.alert-error   { background: var(--danger-light);  color: #991b1b; border-color: var(--danger); }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: var(--warning); }
.alert-info    { background: var(--info-light);    color: #075985; border-color: var(--info); }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(.97);
  transition: transform 220ms cubic-bezier(.34,1.56,.64,1);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  padding: 4px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }
.modal-close .icon { width: 18px; height: 18px; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Tabs inside card */
.tab-nav-btn {
  background: none; border: none;
  padding: 11px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.tab-nav-btn:hover { color: var(--text-primary); }
.tab-nav-btn.tab-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state-icon { font-size: 44px; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.empty-state p { font-size: 14px; }

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1117;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 700px; height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(190,52,72,.15) 0%, transparent 65%);
  top: -250px; right: -200px;
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,.08) 0%, transparent 65%);
  bottom: -200px; left: -100px;
  pointer-events: none;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 40px 100px rgba(0,0,0,.4);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255,255,255,.06);
}
.login-header {
  background: linear-gradient(145deg, #1c0a0f 0%, var(--primary-dark) 50%, var(--primary) 100%);
  padding: 36px 40px 30px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.login-header::before {
  content: '';
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  top: -80px; right: -60px;
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.login-logo img {
  height: 64px;
  width: auto;
  object-fit: contain;
}
.login-logo-icon { font-size: 48px; }
.login-title { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.4px; }
.login-subtitle { font-size: 13px; color: rgba(255,255,255,.65); margin-top: 4px; }
.login-body { padding: 32px 40px 36px; }
.login-step { display: none; }
.login-step.active { display: block; }
.login-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.6;
}
.otp-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}
.otp-inputs input {
  width: 48px; height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: var(--transition);
  color: var(--text-primary);
  font-family: inherit;
}
.otp-inputs input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(190,52,72,.15); }
.otp-timer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 10px;
}
.otp-timer span { font-weight: 700; color: var(--primary); }
.resend-link {
  background: none; border: none;
  color: var(--primary); font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: underline;
  display: none;
}
.resend-link.visible { display: inline; }

/* ============================================================
   Progress Bar
   ============================================================ */
.progress { height: 5px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar {
  height: 100%; background: var(--primary);
  border-radius: 4px; transition: width 400ms ease;
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ============================================================
   Messages (chat bubbles)
   ============================================================ */
.msg-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  height: calc(100vh - 120px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.msg-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.msg-sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  flex-shrink: 0;
}
.msg-sidebar-header h3 { font-size: 14px; font-weight: 700; }
.msg-thread-list { flex: 1; overflow-y: auto; }
.msg-thread-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.msg-thread-item:hover { background: var(--bg); }
.msg-thread-item.active { background: var(--primary-50); border-left: 3px solid var(--primary); }
.msg-thread-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.msg-thread-name { font-size: 13px; font-weight: 600; }
.msg-thread-preview { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.msg-thread-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.msg-unread-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 4px;
}
.msg-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.msg-main-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  flex-shrink: 0;
}
.msg-main-header h4 { font-size: 14px; font-weight: 700; }
.msg-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bubble-wrap { display: flex; gap: 8px; max-width: 75%; }
.bubble-wrap.me { margin-left: auto; flex-direction: row-reverse; }
.bubble-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0; margin-top: 2px;
}
.bubble-me .bubble-avatar { background: var(--primary); color: #fff; }
.bubble-other .bubble-avatar { background: #e5e7eb; color: #4b5563; }
.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.bubble-me .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble-other .bubble { background: #f3f4f6; color: var(--text-primary); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.bubble-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.bubble-wrap.me .bubble-meta { text-align: right; }

.msg-compose {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.msg-compose textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 13px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: var(--transition);
  background: var(--surface);
  line-height: 1.5;
}
.msg-compose textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(190,52,72,.1); }

/* ============================================================
   Misc Utilities
   ============================================================ */
.flex            { display: flex; }
.flex-1          { flex: 1; }
.items-center    { align-items: center; }
.gap-2           { gap: 8px; }
.gap-3           { gap: 12px; }
.gap-4           { gap: 16px; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm    { font-size: 13px; }
.text-xs    { font-size: 12px; }
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }
.font-bold  { font-weight: 700; }
.truncate   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider    { height: 1px; background: var(--border); margin: 20px 0; }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tag */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Section separator */
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

/* Info List */
.info-list  { display: flex; flex-direction: column; gap: 10px; }
.info-item  { display: flex; align-items: center; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.info-item-label { color: var(--text-secondary); min-width: 130px; font-size: 13px; flex-shrink: 0; }
.info-item-value { color: var(--text-primary); font-weight: 500; min-width: 0; word-break: break-all; }

/* Training Detail */
.detail-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) { .detail-grid { grid-template-columns: 1fr; } }

/* Student search dropdown */
.search-result-item:last-child { border-bottom: none !important; }
.search-result-item:hover { background: var(--primary-50) !important; }

/* Save indicator */
.save-indicator {
  font-size: 12px;
  color: var(--success);
  display: none;
  align-items: center;
  gap: 4px;
}
.save-indicator.show { display: flex; }
.save-indicator .icon { width: 13px; height: 13px; }

/* Tabs wrapper */
.tabs-wrapper { }
.tabs-wrapper .tab-btn { font-family: inherit; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 250ms ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .msg-layout { grid-template-columns: 1fr; height: auto; }
  .msg-sidebar { display: none; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .login-body { padding: 24px 24px 28px; }
  .login-header { padding: 28px 24px 22px; }
}
