/* ── Reset & Variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --teal:       #0d9488;
  --teal-dark:  #0f766e;
  --teal-light: #f0fdfa;
  --teal-glow:  rgba(13,148,136,.18);
  --text:       #0f172a;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --bg:         #f8fafc;
  --card:       #ffffff;
  --green:      #16a34a;
  --red:        #dc2626;
  --blue:       #4f6ef7;
  --radius:     12px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,.09);
  --nav-h:      62px;
  --sidebar-w:  230px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sp-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100; box-shadow: var(--shadow-sm);
  transition: transform .25s ease;
}

.sp-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sp-brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), #0e7490);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px var(--teal-glow); flex-shrink: 0;
}
.sp-brand-icon svg { width: 20px; height: 20px; fill: #fff; }
.sp-brand-text {}
.sp-brand-name  { font-size: .95rem; font-weight: 800; color: var(--text); }
.sp-brand-role  { font-size: .68rem; color: var(--teal); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.sp-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sp-nav-label {
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: var(--muted); padding: 8px 12px 4px;
}
.sp-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  text-decoration: none; color: var(--muted);
  font-size: .855rem; font-weight: 500; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sp-nav-link:hover { background: var(--bg); color: var(--text); }
.sp-nav-link.active {
  background: var(--teal-light);
  color: var(--teal);
  border-left: 2.5px solid var(--teal);
  padding-left: 9.5px;
}
.sp-nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }

.sp-sidebar-bottom {
  padding: 12px 10px 16px;
  border-top: 1px solid var(--border);
}
.sp-user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 12px;
}
.sp-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), #0e7490);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 8px var(--teal-glow);
}
.sp-user-name  { font-size: .8rem; font-weight: 600; color: var(--text); }
.sp-user-role  { font-size: .7rem; color: var(--muted); }
.sp-logout {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  background: none; border: 1.5px solid var(--border);
  font-size: .855rem; font-weight: 500; color: var(--muted);
  cursor: pointer; width: 100%; font-family: inherit;
  text-align: left; transition: all .15s;
}
.sp-logout:hover { background: #fef2f2; color: var(--red); border-color: #fca5a5; }
.sp-logout svg { width: 16px; height: 16px; }

/* Overlay + close btn for mobile */
.sp-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 99;
}
.sp-sidebar-close {
  display: none; margin-left: auto;
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 4px; border-radius: 6px;
}
.sp-sidebar-close:hover { color: var(--text); background: var(--bg); }

/* ── Main content ──────────────────────────────────────────── */
.sp-main { margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ────────────────────────────────────────────────── */
.sp-topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h); background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px; gap: 14px;
  box-shadow: var(--shadow-sm);
}
.sp-hamburger {
  display: none; background: none; border: none;
  cursor: pointer; padding: 6px; border-radius: 8px;
  color: var(--text);
}
.sp-hamburger:hover { background: var(--bg); }
.sp-page-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.sp-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ── Content ───────────────────────────────────────────────── */
.sp-content { padding: 28px 32px; flex: 1; }

/* ── Stats grid ────────────────────────────────────────────── */
.sp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.sp-stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.sp-stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.sp-stat-card:nth-child(1)::before { background: linear-gradient(90deg, var(--teal), #0e7490); }
.sp-stat-card:nth-child(2)::before { background: linear-gradient(90deg, #16a34a, #15803d); }
.sp-stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--blue), #3b56d9); }
.sp-stat-card:nth-child(4)::before { background: linear-gradient(90deg, #f59e0b, #d97706); }
.sp-stat-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.sp-stat-icon svg { width: 19px; height: 19px; }
.sp-stat-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.sp-stat-value { font-size: 1.7rem; font-weight: 800; color: var(--text); letter-spacing: -.4px; margin-top: 4px; }

/* ── Section header ────────────────────────────────────────── */
.sp-section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.sp-section-title { font-size: 1rem; font-weight: 800; color: var(--text); }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 10px; font-size: .875rem;
  margin-bottom: 18px; border: 1px solid transparent;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px; border-radius: 9px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff; border: none; font-size: .875rem; font-weight: 700;
  cursor: pointer; text-decoration: none; font-family: inherit;
  box-shadow: 0 2px 8px var(--teal-glow); transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }
.btn-primary svg { width: 15px; height: 15px; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 9px;
  border: 1.5px solid var(--border); background: var(--card);
  color: var(--muted); font-size: .83rem; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit;
  transition: all .15s;
}
.btn-secondary:hover { color: var(--text); border-color: #94a3b8; }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px;
  background: #fef2f2; color: var(--red);
  border: 1.5px solid #fecaca; font-size: .78rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.btn-danger:hover { background: #fee2e2; }

/* ── Card ──────────────────────────────────────────────────── */
.sp-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}

/* ── Filters ───────────────────────────────────────────────── */
.sp-filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.sp-search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.sp-search-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted);
}
.sp-search-wrap input {
  width: 100%; padding: 9px 14px 9px 36px;
  border: 1.5px solid var(--border); border-radius: 9px;
  font-size: .85rem; background: var(--card); outline: none;
  color: var(--text); font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.sp-search-wrap input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-glow); }
.sp-select {
  padding: 9px 30px 9px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: .83rem; background: var(--card); outline: none; color: var(--text);
  appearance: none; cursor: pointer; font-family: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  transition: border-color .15s;
}
.sp-select:focus { border-color: var(--teal); }
.btn-filter {
  padding: 9px 16px; background: var(--teal); color: #fff; border: none;
  border-radius: 9px; font-size: .83rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-reset {
  padding: 9px 12px; background: var(--card); border: 1.5px solid var(--border);
  border-radius: 9px; font-size: .83rem; color: var(--muted); text-decoration: none;
}

/* ── Table ─────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); padding: 11px 16px; text-align: left;
  border-bottom: 1px solid var(--border); background: #f8fafc;
}
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8faff; }
tbody td { padding: 12px 16px; font-size: .875rem; vertical-align: middle; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-av {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--teal-light); color: var(--teal);
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 1.5px solid #99f6e4;
}
.user-name  { font-weight: 700; font-size: .875rem; }
.user-email { font-size: .72rem; color: var(--muted); }

/* ── Badges ────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; }
.badge-active   { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-inactive { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-student  { background: var(--teal-light); color: var(--teal); border: 1px solid #99f6e4; }
.badge-user     { background: #f1f5f9; color: var(--muted); border: 1px solid var(--border); }

/* ── Row actions ───────────────────────────────────────────── */
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ra-link {
  font-size: .78rem; font-weight: 600; color: var(--teal);
  text-decoration: none; padding: 4px 8px; border-radius: 6px; transition: background .15s;
}
.ra-link:hover { background: var(--teal-light); }

/* ── Mobile table cards ────────────────────────────────────── */
.sp-mobile-cards { display: none; flex-direction: column; gap: 10px; }
.sp-desktop-table { display: block; }

.sp-m-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm);
}
.sp-m-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sp-m-card-info { flex: 1; min-width: 0; }
.sp-m-card-name  { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-m-card-sub   { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.sp-m-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid #f1f5f9; }
.sp-m-card-actions .btn-primary,
.sp-m-card-actions .ra-link { flex: 1; justify-content: center; text-align: center; }

/* ── Profile / Detail ──────────────────────────────────────── */
.sp-profile-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px;
  margin-bottom: 22px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.sp-profile-av {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--teal), #0e7490);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #fff;
  box-shadow: 0 4px 14px var(--teal-glow);
}
.sp-profile-name  { font-size: 1.15rem; font-weight: 800; }
.sp-profile-meta  { font-size: .82rem; color: var(--muted); margin-top: 3px; }
.sp-profile-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* Assign form */
.sp-assign-form { padding: 20px 22px; }
.sp-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.sp-field label { font-size: .8rem; font-weight: 600; color: var(--text); }
.sp-field select, .sp-field input {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: .875rem; color: var(--text); background: #fff; outline: none;
  transition: border-color .15s; width: 100%; font-family: inherit;
}
.sp-field select:focus, .sp-field input:focus { border-color: var(--teal); }
.field-error { font-size: .74rem; color: var(--red); margin-top: 2px; }

/* Assignment list */
.assign-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 18px; border-bottom: 1px solid #f1f5f9;
}
.assign-item:last-child { border-bottom: none; }
.assign-thumb {
  width: 56px; height: 40px; object-fit: cover; border-radius: 7px;
  background: #f1f5f9; flex-shrink: 0;
}
.assign-thumb-ph {
  width: 56px; height: 40px; border-radius: 7px; flex-shrink: 0;
  background: #f1f5f9; display: flex; align-items: center; justify-content: center;
}
.assign-info { flex: 1; min-width: 0; }
.assign-title  { font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assign-dates  { font-size: .73rem; color: var(--muted); margin-top: 2px; }
.days-left-chip {
  font-size: .72rem; font-weight: 700; color: #15803d;
  background: #f0fdf4; border: 1px solid #bbf7d0;
  padding: 3px 8px; border-radius: 20px; white-space: nowrap; flex-shrink: 0;
}

/* ── Login page ────────────────────────────────────────────── */
.sp-login-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px; background: var(--bg);
}
.sp-login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px 36px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-md);
}
.sp-login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.sp-login-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 5px; }
.sp-login-sub   { font-size: .82rem; color: var(--muted); margin-bottom: 28px; }
.sp-form-field  { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.sp-form-field label { font-size: .8rem; font-weight: 600; color: var(--text); }
.sp-form-field input {
  padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: .9rem; color: var(--text); background: #fff; outline: none;
  font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.sp-form-field input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-glow); }
.sp-btn-login {
  width: 100%; padding: 12px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff; border: none; font-size: .95rem; font-weight: 700;
  cursor: pointer; font-family: inherit; margin-top: 8px;
  box-shadow: 0 2px 10px var(--teal-glow); transition: opacity .15s;
}
.sp-btn-login:hover { opacity: .9; }

/* ── Pagination ────────────────────────────────────────────── */
.sp-pag {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-top: 1px solid var(--border);
  font-size: .82rem; color: var(--muted); background: #fafafa;
}
.sp-pag-btns { display: flex; gap: 8px; }
.sp-pag-btn {
  padding: 7px 14px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .82rem; font-weight: 600; color: var(--text);
  text-decoration: none; background: #fff; transition: all .15s;
}
.sp-pag-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-light); }
.sp-pag-btn.disabled { opacity: .4; pointer-events: none; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sp-sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sp-sidebar.open { transform: translateX(0); }
  .sp-overlay.open { display: block; }
  .sp-sidebar-close { display: flex; align-items: center; justify-content: center; }
  .sp-hamburger { display: flex; align-items: center; justify-content: center; }
  .sp-main { margin-left: 0; }

  /* Topbar: prevent title wrapping */
  .sp-topbar { padding: 0 12px; gap: 8px; }
  .sp-page-title {
    font-size: .88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }
  .sp-topbar-right { flex-shrink: 0; }
  .sp-topbar-right .btn-primary { font-size: .78rem; padding: 7px 10px; }
  /* Hide button text on very small screens, keep icon */
  .sp-topbar-right .btn-primary span { display: none; }

  .sp-content { padding: 16px; }
  .sp-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .sp-desktop-table { display: none; }
  .sp-mobile-cards { display: flex; }

  /* Filters: search full-width, buttons side-by-side below */
  .sp-filters { flex-direction: column; gap: 8px; }
  .sp-search-wrap { max-width: 100%; width: 100%; }
  .sp-filters .btn-filter,
  .sp-filters .btn-reset { flex: 1; text-align: center; justify-content: center; }
  /* Wrap Search + Reset in a row */
  .sp-filter-btns { display: flex; gap: 8px; width: 100%; }

  .sp-pag { flex-direction: column; gap: 10px; text-align: center; }
  .sp-profile-card { flex-direction: column; align-items: flex-start; }
  .sp-profile-actions { margin-left: 0; width: 100%; }
  .sp-profile-actions .btn-secondary,
  .sp-profile-actions form { flex: 1; }
  .sp-login-card { padding: 28px 20px; }
}
@media (max-width: 480px) {
  .sp-stats { grid-template-columns: 1fr; }
}
