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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #eef1f8;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(99,102,241,0.12), transparent 35%),
    radial-gradient(circle at 90% 10%, rgba(129,140,248,0.10), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(165,180,252,0.10), transparent 45%);
  background-attachment: fixed;
  color: #333;
  line-height: 1.6;
}

nav {
  background: linear-gradient(135deg, #0f172a 0%, #1a2456 100%);
  padding: 1rem 2rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

nav .brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin-right: auto;
  text-decoration: none;
  padding: 0;
}

nav .brand span {
  color: #818cf8;
}

nav a {
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: all 0.15s;
}

nav a:hover {
  color: #fff;
  background: rgba(99,102,241,0.2);
}

nav a[href="/auth/logout"] {
  color: #fca5a5;
  margin-left: 0.5rem;
}

nav a[href="/auth/logout"]:hover {
  color: #fff;
  background: rgba(239,68,68,0.25);
}

nav a[href="/register"] {
  background: #6366f1;
  color: #fff;
}

nav a[href="/register"]:hover {
  background: #4f46e5;
}

main {
  max-width: 600px;
  margin: 2rem auto;
  padding: 0 1rem;
}

h1 {
  margin-bottom: 1.5rem;
  color: #2c3e50;
}

.card {
  background: #fff;
  border-radius: 14px;
  padding: 2rem;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  color: #555;
}

input, textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

input:focus, textarea:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.btn {
  display: inline-block;
  padding: 0.5rem 1.5rem;
  background: #3498db;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: #2980b9;
}

.btn-danger {
  background: #e74c3c;
}

.btn-danger:hover {
  background: #c0392b;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fde8e8;
  color: #c0392b;
  border: 1px solid #f8d7da;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }

select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  background: #fff;
}

select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

select[multiple] {
  height: auto;
  padding: 0.25rem;
}

select[multiple] optgroup {
  font-weight: 600;
  color: #2c3e50;
  padding: 0.25rem 0;
}

select[multiple] option {
  padding: 0.3rem 0.5rem;
  font-weight: 400;
}

.helper-text {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #777;
  line-height: 1.5;
}

.helper-text a {
  color: #3498db;
  text-decoration: underline;
  cursor: pointer;
}

.helper-text a:hover {
  color: #2980b9;
}

.onboarding-header {
  margin-bottom: 1.5rem;
}

.onboarding-header h1 {
  margin-bottom: 0.5rem;
}

.onboarding-header p {
  color: #666;
  font-size: 1rem;
}

hr {
  border: none;
  border-top: 1px solid #eee;
}

.role-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.role-student {
  background: #e8f5e9;
  color: #2e7d32;
}

.role-teacher {
  background: #e3f2fd;
  color: #1565c0;
}

.role-admin {
  background: #fce4ec;
  color: #c62828;
}

.module-select-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.25rem;
}

@media (max-width: 860px) {
  .module-select-group {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .module-select-group {
    grid-template-columns: 1fr;
  }
}

.module-select-item {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  overflow: hidden;
}

.module-select-item label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-select-item select {
  font-size: 0.85rem;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  width: 100%;
  min-width: 0;
}

.role-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.profile-info p {
  margin-bottom: 0.5rem;
}

.profile-info strong {
  display: inline-block;
  width: 110px;
}

.profile-info span {
  color: #555;
}


/* ---- Study Group Board additions ---- */

main.wide {
  max-width: 900px;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.board-header h1 {
  margin-bottom: 0;
}

.filter-bar {
  display: flex;
  align-items: center;
}

.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.listing-card {
  display: block;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.listing-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.listing-card h3 {
  margin: 0.5rem 0 0.35rem;
  color: #2c3e50;
}

.listing-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.listing-meta {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.15rem;
}

.module-tag {
  display: inline-block;
  background: #eaf4fc;
  color: #2980b9;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
}

.slots-tag {
  font-size: 0.8rem;
  font-weight: 600;
  color: #2e7d32;
  background: #e8f5e9;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
}

.slots-tag.slots-full {
  color: #c62828;
  background: #fce4ec;
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.action-buttons form {
    margin: 0;
}

.action-buttons .btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;

    min-width: 180px;
    height: 44px;

    text-decoration: none;
    box-sizing: border-box;
}

.back-link {
    display: inline-block;
    margin-bottom: 24px;
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
}

.back-link:hover {
    text-decoration: underline;
}

.btn-secondary {
    background: #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* ---- Admin Tabs ---- */

.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1rem;
}

.admin-tab {
  padding: 0.6rem 1.25rem;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.admin-tab:hover {
  color: #3498db;
}

.admin-tab.active {
  color: #3498db;
  border-bottom-color: #3498db;
}

.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
}

/* ---- Admin Table ---- */

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.admin-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: #f8fafc;
}

.codes-cell {
  max-width: 280px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.5rem;
}

.codes-empty {
  font-size: 0.82rem;
  color: #999;
  font-style: italic;
}

.code-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  white-space: nowrap;
  line-height: 1.4;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 4px;
}

.btn-edit {
  background: #f59e0b;
  color: #fff;
}

.btn-edit:hover {
  background: #d97706;
}

/* ---- Edit User Modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-header h2 {
  margin-bottom: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  padding: 0.25rem;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ---- Profile Module Grid ---- */

.class-codes-display {
  margin-top: 0.5rem;
}

.class-codes-display > strong {
  display: block;
  margin-bottom: 0.5rem;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.module-grid-item {
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.module-grid-item.enrolled {
  background: #e8f5e9;
  border-color: #c3e6cb;
}

.module-grid-code {
  font-weight: 700;
  font-size: 0.85rem;
  color: #2c3e50;
}

.module-grid-name {
  font-size: 0.78rem;
  color: #666;
}

.module-grid-class {
  font-size: 0.82rem;
  font-weight: 600;
  color: #155724;
}

.module-grid-item:not(.enrolled) .module-grid-class {
  color: #999;
  font-style: italic;
}

