@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

/* ─── Design Tokens ──────────────────────────────────────────────── */
:root {
  --blue-50:  #EFF6FF;
  --blue-100: #DBEAFE;
  --blue-500: #3B82F6;
  --blue-600: #2563EB;
  --blue-700: #1D4ED8;

  --gray-50:  #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  --green-100: #DCFCE7;
  --green-600: #16A34A;
  --red-100:   #FEE2E2;
  --red-600:   #DC2626;
  --yellow-100:#FEF9C3;
  --yellow-600:#CA8A04;
  --orange-100:#FFEDD5;
  --orange-600:#EA580C;

  --color-primary:    var(--blue-600);
  --color-primary-h:  var(--blue-700);
  --color-bg:         #FFFFFF;
  --color-surface:    var(--gray-50);
  --color-border:     var(--gray-200);
  --color-text:       var(--gray-900);
  --color-text-muted: var(--gray-500);
  --color-sidebar:    var(--gray-900);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);

  --sidebar-w: 240px;
  --header-h:  60px;
  --transition: 150ms ease;
}

/* ─── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-surface);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* ─── Auth Layout ────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  padding: 24px;
}
.auth-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-logo-mark {
  width: 36px; height: 36px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}
.auth-logo-name { font-size: 1.25rem; font-weight: 700; color: var(--gray-900); }
.auth-title    { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.auth-subtitle { color: var(--color-text-muted); margin-bottom: 28px; font-size: 0.875rem; }
.auth-footer   { margin-top: 20px; text-align: center; font-size: 0.875rem; color: var(--color-text-muted); }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--color-sidebar);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo-mark {
  width: 32px; height: 32px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.sidebar-logo-name { font-size: 1.125rem; font-weight: 700; color: #fff; }

.sidebar-nav { flex: 1; min-height: 0; padding: 12px 8px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,.15); color: var(--blue-500); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--blue-500);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue-600);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name  { font-size: 0.8125rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: 0.75rem; color: var(--gray-500); }

/* ─── Main Content ───────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }

.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--gray-900); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}
.notif-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.notif-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 8px; height: 8px;
  background: var(--blue-500);
  border-radius: 50%;
  border: 2px solid #fff;
}

.page-content { padding: 28px; }

/* ─── Cards ──────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.card-title { font-size: 0.9375rem; font-weight: 600; color: var(--gray-900); }
.card-body  { padding: 20px; }

/* ─── Stat Cards ─────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.stat-icon.blue   { background: var(--blue-50);   color: var(--blue-600); }
.stat-icon.green  { background: var(--green-100);  color: var(--green-600); }
.stat-icon.yellow { background: var(--yellow-100); color: var(--yellow-600); }
.stat-icon.orange { background: var(--orange-100); color: var(--orange-600); }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.8125rem; color: var(--color-text-muted); }

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
  cursor: pointer;
  white-space: nowrap;
  border: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary  { background: var(--color-primary); color: #fff; }
.btn-primary:hover  { background: var(--color-primary-h); text-decoration: none; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); text-decoration: none; }
.btn-danger   { background: var(--red-100); color: var(--red-600); }
.btn-danger:hover  { background: #FECACA; text-decoration: none; }
.btn-ghost    { background: transparent; color: var(--gray-500); }
.btn-ghost:hover  { background: var(--gray-100); color: var(--gray-700); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 0.8125rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Forms ──────────────────────────────────────────────────────── */
.form-group    { margin-bottom: 16px; }
.form-label    { display: block; font-size: 0.875rem; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-label .req { color: var(--red-600); margin-left: 2px; }
.form-control  {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  color: var(--gray-900);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}
.form-control:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control.is-error { border-color: var(--red-600); }
.form-hint  { font-size: 0.8125rem; color: var(--color-text-muted); margin-top: 4px; }
.form-error { font-size: 0.8125rem; color: var(--red-600); margin-top: 4px; }
textarea.form-control { resize: vertical; min-height: 96px; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2394A3B8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 20px; padding-right: 36px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── Table ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ─── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-blue   { background: var(--blue-50);   color: var(--blue-600); }
.badge-green  { background: var(--green-100);  color: var(--green-600); }
.badge-yellow { background: var(--yellow-100); color: var(--yellow-600); }
.badge-red    { background: var(--red-100);    color: var(--red-600); }
.badge-gray   { background: var(--gray-100);   color: var(--gray-600); }
.badge-orange { background: var(--orange-100); color: var(--orange-600); }
.badge-purple { background: #EDE9FE; color: #6D28D9; }

/* ─── Avatar ─────────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--blue-100);
  color: var(--blue-600);
  font-size: 0.8125rem;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.6875rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }

/* ─── Alert ──────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-error   { background: var(--red-100);   color: var(--red-600); }
.alert-success { background: var(--green-100); color: var(--green-600); }
.alert-info    { background: var(--blue-50);   color: var(--blue-600); }

/* ─── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 200ms ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--color-border);
}
.modal-title  { font-size: 1rem; font-weight: 600; }
.modal-close  { width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--gray-400); cursor: pointer; transition: background var(--transition); }
.modal-close:hover { background: var(--gray-100); color: var(--gray-600); }
.modal-body   { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--color-border); display: flex; gap: 10px; justify-content: flex-end; }

/* ─── Notifications Dropdown ─────────────────────────────────────── */
.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(var(--header-h) - 4px);
  right: 28px;
  width: 340px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  overflow: hidden;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header { padding: 14px 16px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.notif-dropdown-title  { font-size: 0.875rem; font-weight: 600; }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
  cursor: pointer;
}
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: var(--blue-50); }
.notif-item:last-child { border-bottom: none; }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-100); color: var(--blue-600); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon svg { width: 16px; height: 16px; }
.notif-text { font-size: 0.8125rem; color: var(--gray-700); line-height: 1.4; }
.notif-time { font-size: 0.75rem; color: var(--gray-400); margin-top: 3px; }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--gray-400); font-size: 0.875rem; }

/* ─── Chat ───────────────────────────────────────────────────────── */
.chat-layout { display: flex; gap: 0; height: 460px; min-height: 300px; }
.chat-sidebar {
  width: 280px;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius) 0 0 var(--radius);
  flex-shrink: 0;
}
.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background var(--transition);
}
.chat-item:hover { background: var(--gray-50); }
.chat-item.active { background: var(--blue-50); }
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name { font-size: 0.875rem; font-weight: 500; color: var(--gray-900); }
.chat-item-preview { font-size: 0.8125rem; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { flex: 1; display: flex; flex-direction: column; background: #fff; border-radius: 0 var(--radius) var(--radius) 0; min-width: 0; }
.chat-header { padding: 14px 20px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.chat-back-btn { display: none; width: 32px; height: 32px; align-items: center; justify-content: center; border-radius: 8px; color: var(--gray-600); flex-shrink: 0; transition: background .15s; }
.chat-back-btn:hover { background: var(--gray-100); }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.msg { max-width: 68%; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}
.msg.from-me { align-self: flex-end; }
.msg.from-me .msg-bubble { background: var(--blue-600); color: #fff; border-bottom-right-radius: 4px; }
.msg.from-other .msg-bubble { background: var(--gray-100); color: var(--gray-800); border-bottom-left-radius: 4px; }
.msg-time { font-size: 0.6875rem; color: var(--gray-400); margin-top: 4px; }
.msg.from-me .msg-time { text-align: right; }
.chat-input-area {
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  display: flex; gap: 10px; align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
.chat-input { flex: 1; resize: none; min-height: 40px; max-height: 120px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 0.875rem; outline: none; transition: border-color var(--transition); overflow-y: auto; font-family: inherit; }
.chat-input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.chat-send { width: 40px; height: 40px; background: var(--blue-600); color: #fff; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background var(--transition); border: none; cursor: pointer; }
.chat-send:hover { background: var(--blue-700); }
.chat-send svg { width: 18px; height: 18px; }
.chat-placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--gray-400); gap: 8px; }
.chat-placeholder svg { width: 40px; height: 40px; opacity: .4; }

/* ─── Progress ───────────────────────────────────────────────────── */
.grade-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.875rem;
}
.grade-high   { background: var(--green-100); color: var(--green-600); }
.grade-mid    { background: var(--yellow-100); color: var(--yellow-600); }
.grade-low    { background: var(--red-100); color: var(--red-600); }

/* ─── Empty State ────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--gray-400);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .4; }
.empty-state-title { font-size: 0.9375rem; font-weight: 500; color: var(--gray-600); margin-bottom: 4px; }
.empty-state-text  { font-size: 0.875rem; }

/* ─── Utilities ──────────────────────────────────────────────────── */
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.mt-4   { margin-top: 16px; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--color-text-muted); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--color-border); margin: 20px 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title  { font-size: 1.25rem; font-weight: 700; color: var(--gray-900); }
.search-box  { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--gray-400); pointer-events: none; }
.search-box input { padding-left: 34px; width: 220px; }

/* ─── Toast ──────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--gray-900); color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: toast-in 200ms ease;
  max-width: 320px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.success { background: var(--green-600); }
.toast.error   { background: var(--red-600); }

/* ─── Trial Banner ───────────────────────────────────────────────── */
.trial-banner {
  background: var(--blue-50);
  border-bottom: 1px solid var(--blue-100);
  padding: 8px 28px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--blue-700);
}

/* ─── Dashboard Grid ─────────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ─── Group chat (student/groups.php) ───────────────────────────── */
.gchat-layout        { display:flex; height:520px; background:#fff; border-radius:14px; border:1px solid #E2E8F0; overflow:hidden; }
.gchat-sidebar       { width:220px; border-right:1px solid #E2E8F0; overflow-y:auto; flex-shrink:0; }
.gchat-back-btn      { display:none; width:32px; height:32px; align-items:center; justify-content:center; border-radius:8px; color:#475569; flex-shrink:0; text-decoration:none; transition:background .15s; }
.gchat-back-btn:hover { background:#F1F5F9; }
.gchat-group-item    { display:flex; align-items:center; gap:10px; padding:12px 16px; text-decoration:none; color:#334155; border-bottom:1px solid #F8FAFC; transition:background .1s; }
.gchat-group-item:hover { background:#F8FAFC; }
.gchat-group-item.active { background:#EFF6FF; border-left:3px solid #2563EB; }
.gchat-group-dot     { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.gchat-group-name    { font-size:13px; font-weight:600; line-height:1.3; }
.gchat-group-sub     { font-size:11px; color:#94A3B8; }
.gchat-main          { flex:1; display:flex; flex-direction:column; min-width:0; }
.gchat-header        { padding:14px 20px; border-bottom:1px solid #E2E8F0; display:flex; align-items:center; gap:10px; background:#fff; flex-shrink:0; }
.gchat-messages-wrap { flex:1; overflow-y:auto; padding:16px 20px; display:flex; flex-direction:column; gap:8px; background:#F8FAFC; }
.gchat-form-area     { padding:12px 16px; border-top:1px solid #E2E8F0; background:#fff; display:flex; gap:10px; align-items:flex-end; flex-shrink:0; }
.gchat-msg           { display:flex; flex-direction:column; max-width:72%; }
.gchat-mine          { align-self:flex-end; align-items:flex-end; }
.gchat-other         { align-self:flex-start; align-items:flex-start; }
.gchat-sender        { font-size:11px; font-weight:700; color:#64748B; margin-bottom:3px; padding-left:2px; }
.gchat-bubble        { padding:8px 12px; border-radius:12px; font-size:14px; line-height:1.5; word-break:break-word; }
.gchat-mine  .gchat-bubble { background:#2563EB; color:#fff; border-bottom-right-radius:4px; }
.gchat-other .gchat-bubble { background:#fff; color:#0F172A; border:1px solid #E2E8F0; border-bottom-left-radius:4px; }
.gchat-time  { font-size:11px; color:#94A3B8; margin-top:3px; padding:0 2px; }

/* ─── Responsive ─────────────────────────────────────────────────── */
.menu-toggle { display: none; width: 40px; height: 40px; border-radius: var(--radius-sm); align-items: center; justify-content: center; color: var(--gray-500); cursor: pointer; flex-shrink: 0; }
.menu-toggle:hover { background: var(--gray-100); }
.menu-toggle svg { width: 22px; height: 22px; }

/* Overlay for sidebar on mobile */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ─── Mobile Bottom Navigation ───────────────────────────────────── */
/* Hidden on desktop, shown on mobile via media query */
.mobile-bottom-nav { display: none; }

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px 4px;
  min-width: 52px;
  flex: 1;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  position: relative;
  transition: color .15s;
  max-width: 76px;
}
/* Force SVG size — important needed to beat any cascade from nav-item svg rules */
.mobile-nav-item svg {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px;
  min-height: 22px;
  max-width: 22px;
  max-height: 22px;
  display: block;
  flex-shrink: 0;
}
.mobile-nav-item span { white-space: nowrap; overflow: hidden; max-width: 68px; text-overflow: ellipsis; line-height: 1.2; }
.mobile-nav-item:hover { text-decoration: none; color: var(--gray-600); }
.mobile-nav-item.active { color: var(--blue-600); }
.mobile-nav-badge {
  position: absolute; top: 3px; right: calc(50% - 18px);
  background: var(--blue-500); color: #fff;
  font-size: 9px; font-weight: 700;
  min-width: 14px; height: 14px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

@media (max-width: 768px) {
  /* Sidebar — slides in as drawer, bottom nav is primary navigation */
  .sidebar { transform: translateX(-100%); z-index: 200; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-nav { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }

  /* Mobile bottom nav */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--color-border);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 150;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  }
  .mobile-bottom-nav::-webkit-scrollbar { display: none; }
  .mobile-nav-item { flex: 1; min-width: 52px; padding: 7px 4px 5px; }

  /* Topbar */
  .topbar { padding: 0 16px; gap: 8px; }
  .topbar-title { font-size: 0.9375rem; }

  /* Page — extra bottom padding so content isn't behind bottom nav */
  .page-content { padding: 16px; padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .page-header { flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
  .page-title { font-size: 1.125rem; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.5rem; }

  /* Tables — scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 0; width: 100%; }

  /* Cards */
  .card-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .card-body { padding: 16px; }

  /* Dashboard grid */
  .dashboard-grid { grid-template-columns: 1fr; gap: 16px; }

  /* Chat — mobile sliding panels */
  .chat-layout {
    position: relative;
    overflow: hidden;
    height: calc(100vh - var(--header-h) - 74px - env(safe-area-inset-bottom));
    height: calc(100svh - var(--header-h) - 74px - env(safe-area-inset-bottom));
    min-height: 300px;
    flex-direction: row;
  }
  .chat-sidebar {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    max-height: unset;
    border-right: none; border-bottom: none;
    border-radius: var(--radius);
    z-index: 2;
    transform: translateX(0);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .chat-main {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    min-height: unset;
    border-radius: var(--radius);
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .chat-layout.chat-open .chat-sidebar { transform: translateX(-110%); }
  .chat-layout.chat-open .chat-main { transform: translateX(0); }
  /* Student single-panel chat (no sidebar) */
  .card > .chat-main { position: static; transform: none; height: calc(100svh - var(--header-h) - 74px - env(safe-area-inset-bottom) - 32px); min-height: 300px; border-radius: var(--radius); }
  .chat-messages { padding: 14px; gap: 10px; min-height: 0 !important; max-height: unset !important; }
  .chat-back-btn { display: flex; }
  .chat-input-area { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .msg { max-width: 85%; }

  /* Group chat — mobile: full-screen sliding panels */
  .gchat-layout {
    height: calc(100vh - var(--header-h) - 74px) !important;
    height: calc(100svh - var(--header-h) - 74px) !important;
    min-height: 300px;
    position: relative !important;
    overflow: hidden !important;
    border-radius: 10px !important;
  }
  .gchat-sidebar {
    position: absolute !important; top: 0; left: 0;
    width: 100% !important; height: 100% !important;
    border-right: none;
    transform: translateX(0);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 2;
  }
  .gchat-main {
    position: absolute !important; top: 0; left: 0;
    width: 100% !important; height: 100% !important;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .gchat-layout.gchat-open .gchat-sidebar { transform: translateX(-110%); }
  .gchat-layout.gchat-open .gchat-main   { transform: translateX(0); }
  .gchat-back-btn  { display: flex !important; }
  .gchat-form-area { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .gchat-bubble    { font-size: 15px; }
  .gchat-msg       { max-width: 85%; }

  /* Notifications */
  .notif-dropdown { right: 8px; width: calc(100vw - 16px); }

  /* Search */
  .search-box { flex: 1; }
  .search-box input { width: 100%; }

  /* Trial banner */
  .trial-banner { padding: 8px 16px; flex-direction: column; gap: 6px; align-items: flex-start; }

  /* Toast — above bottom nav */
  #toast-container { bottom: calc(74px + env(safe-area-inset-bottom) + 8px); right: 8px; left: 8px; }
  .toast { max-width: 100%; }

  /* Modals — sheet slides up from bottom, clear of bottom nav */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 90vh; padding-bottom: env(safe-area-inset-bottom); }

  /* Buttons — touch-friendly */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }

  /* Form inputs — prevent iOS zoom */
  .form-control, .chat-input { font-size: 16px; }
}

@media (max-width: 480px) {
  .auth-page { padding: 16px; }
  .auth-card { padding: 24px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1.375rem; }
  .stat-label { font-size: 0.75rem; }

  /* Page header — stack vertically */
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Chat — 480px tweaks */
  .msg { max-width: 90%; }
  .chat-input-area { padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

  .modal-body { padding: 16px; }
  .modal-header { padding: 16px 16px 12px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; justify-content: center; }
}

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
