:root {
  --primary: #0d6efd;
  --primary-dark: #0b5ed7;
  --page: #f6f7fb;          /* Solid page background fixes the "column" */
  --card-bg: #ffffff;
  --radius: 16px;
  --transition: 0.25s ease;
}

/* Reset & base */
* { box-sizing: border-box; }
html { height: 100%; }
body {
  min-height: 100svh;
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--page);
  display: grid;
  /* Changed to 'start center' to allow scrolling on long pages without cutting off top */
  place-items: start center; 
  padding-top: 40px; /* added padding so login card isn't stuck to top edge */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px 36px;
  background: var(--card-bg);       /* solid white, no frosted blur */
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
  text-align: center;
  animation: fade-in 0.45s ease both;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary);
}

.subtitle {
  font-size: 0.95rem;
  color: #6b7280;
  margin-bottom: 24px;
}

/* ---------- Form ---------- */
.field { position: relative; margin-bottom: 14px; }

.field input {
  width: 100%;
  padding: 14px 44px 14px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.field input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.12);
}

.toggle-password {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  color: #9ca3af;
  padding: 2px 6px;
  border-radius: 8px;
}

.toggle-password:hover { color: var(--primary); }

/* ---------- Button ---------- */
.btn {
  width: 100%;
  padding: 14px;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition), transform 0.05s ease;
}

.btn:hover,
.btn:focus-visible { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }

/* ---------- Messages ---------- */
#message {
  margin-top: 14px;
  font-size: 0.93rem;
  font-weight: 500;
  min-height: 1.2em;
}

.error { color: #d52731; }
.success { color: #269f53; }

/* ---------- Logout button ---------- */
/* Tiny logout icon (top-left of the page) */
.logout-icon {
  position: fixed;
  top: 12px;
  left: 12px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(16, 24, 40, 0.12);
  transition: background var(--transition), transform 0.05s ease;
  z-index: 1000;
}
.logout-icon i {
  font-size: 14px;   /* slightly larger than before */
  line-height: 1;
}

.logout-icon:hover { background: var(--primary-dark); }
.logout-icon:active { transform: translateY(1px); }


.teacher-grid {
  width: 100%;
  max-width: 1600px;  /* Changed: Much wider to fit more students clearly */
  padding: 20px;
  display: flex;      /* Keeps it 1 column (vertical list) */
  flex-direction: column;
  gap: 20px;
  margin: 0 auto;     /* Centers the list on the screen */
}

.teacher-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
  padding: 20px;
  animation: fade-in 0.3s ease both;
}

.teacher-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.teacher-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 700;
}

.teacher-info {
  flex: 1;
  min-width: 0;
}

.teacher-name {
  font-weight: 700;
  font-size: 1rem;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.teacher-email {
  font-size: 0.8rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ---------- Student Sections ---------- */
.student-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.student-section {
  background: #f8fafc;
  border-radius: 12px;
  padding: 14px;
}

.student-section.ttkb-section {
  border-left: none; /* Removes the blue line */
}

.student-section.breakout-section {
  border-left: none; /* Removes the purple line */
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.section-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
}

.ttkb-section .section-icon {
  background: #dbeafe;
  color: #1e40af;
}

.breakout-section .section-icon {
  background: #ede9fe;
  color: #6d28d9;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
}

.section-count {
  font-size: 0.7rem;
  color: #64748b;
  margin-left: auto;
  background: #fff;
  padding: 2px 8px;
  border-radius: 10px;
}

.student-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.student-chip {
  padding: 6px 12px;
  background: #fff;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #334155;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.no-students {
  color: #94a3b8;
  font-size: 0.8rem;
  font-style: italic;
}

.loading-msg {
  text-align: center;
  color: #64748b;
  padding: 40px;
}



/* ---------- Student Chip with Status ---------- */
.student-chip-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-chip {
  padding: 2px 6px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 600;
}

/* ---------- Multi-Teacher Section ---------- */
.multi-section {
  border-left: none; /* Removes the orange line */
}

.multi-section .section-icon {
  background: #fef3c7;
  color: #d97706;
}

.multi-teacher-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.multi-teacher-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.multi-teacher-item .student-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #1e293b;
}

.multi-teacher-item .other-teachers {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 2px;
}

/* ---------- Refresh Button ---------- */
.refresh-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.refresh-btn:hover {
  background: var(--primary);
  color: #fff;
}


/* ---------- Two-Column Student Rows ---------- */
.student-rows {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* Creates 4 equal columns */
  gap: 12px;
}

.student-row {
  position: relative; /* Required to place badge in top-right corner */
  display: flex;
  flex-direction: column; /* Stacks name on top, info on bottom */
  align-items: flex-start; /* Aligns text to the left */
  justify-content: center;
  padding: 12px;
  background: #fff;
  border: 1px solid #e2e8f0; /* Adds a subtle border definition */
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  gap: 6px;
  height: 100%; /* Ensures all cards in a row are same height */
}

.student-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.student-right {
  width: 100%;
  text-align: left; /* Aligns text to start of card */
  margin-top: 4px;
}

.shared-with {
  font-size: 0.7rem;
  color: #64748b;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.shared-badge {
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  margin-left: 8px;
}

/* Hover effect on student rows */
.student-row:hover {
  background: #f8fafc;
}

.student-row:hover .shared-with {
  color: #334155;
}

/* ---------- Shared Section Redesign ---------- */
.shared-section {
  width: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
  display: flex;
  flex-direction: row;   /* Aligns items in a single horizontal line */
  align-items: center;   /* Centers the icon vertically with the text */
  gap: 8px;              /* Adds space between the icon and the names */
}

.shared-label {
  font-size: 1rem;       /* Slightly larger for better visibility */
  color: #f59e0b;        /* Vibrant Orange/Amber color */
  margin-bottom: 0;      /* Removes unnecessary bottom spacing */
  line-height: 1;        /* Keeps the icon tightly fitted */
  display: flex;         /* Helps icon alignment */
}

.shared-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.shared-badge {
  background: #ffffff;      /* White background */
  color: #475569;
  font-size: 0.75rem;       /* Slightly more readable */
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  white-space: nowrap;
  font-weight: 500;
}


/* ---------- Badges Container & Mismatch Alert ---------- */
.badges-container {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.level-badge {
  /* Removed absolute position, handled by container now */
  background-color: #e0f2fe;
  color: #0369a1;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* The red warning icon */
.mismatch-icon {
  color: #dc2626; /* Red color */
  font-size: 0.8rem;
  animation: pulse 2s infinite;
}

/* The red dotted border for the card */
.student-row.mismatched-level {
  border: 2px dotted #dc2626;
  background: #fef2f2; /* Very light red bg */
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}


/* ---------- Filter Section ---------- */
.filter-section {
  width: 100%;
  max-width: 1600px;
  padding: 0 20px;
  margin: 0 auto 10px; /* Spacing before grid */
  animation: fade-in 0.3s ease both;
}

.filter-container {
  background: #fff;
  padding: 16px 24px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

/* Search Box */
.search-box {
  position: relative;
  width: 300px;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.search-box input {
  width: 100%;
  padding: 10px 10px 10px 36px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  outline: none;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* Mismatch Toggle */
.mismatch-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.mismatch-toggle input {
  width: 16px;
  height: 16px;
  accent-color: #dc2626;
  cursor: pointer;
}

.toggle-text {
  font-size: 0.9rem;
  color: #334155;
  font-weight: 500;
}

/* Total Badge */
.mismatch-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fef2f2;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #fecaca;
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #7f1d1d;
}

.stat-badge {
  background: #dc2626;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 24px;
  text-align: center;
}

/* ---------- New Student Actions ---------- */
.student-actions {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  opacity: 0;             /* Hidden by default */
  pointer-events: none;   /* Prevent clicking when hidden */
  transition: opacity 0.2s ease;
}

/* Show on hover */
.student-row:hover .student-actions {
  opacity: 1;
  pointer-events: auto;
}

.action-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 0.95rem;
  color: #94a3b8; /* Gray default */
  transition: color 0.2s;
}

.action-icon:hover {
  color: var(--primary); /* Blue hover for comment */
}

.action-icon.accept-icon:hover {
  color: #16a34a; /* Green hover for accept */
}


/* ---------- Comment Modal ---------- */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5); z-index: 2000;
  display: flex; justify-content: center; align-items: center;
}

.modal-content {
  background: #fff; width: 90%; max-width: 500px;
  border-radius: 16px; overflow: hidden; display: flex; flex-direction: column;
  max-height: 85vh; box-shadow: 0 20px 25px rgba(0,0,0,0.1);
}

.modal-header {
  padding: 16px 20px; background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; color: #1e293b; }
.close-modal { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #64748b; }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 15px; overflow-y: auto; }
#modalStudentName { margin: 0; color: var(--primary); font-size: 0.95rem; }

.comments-list {
  background: #f1f5f9; border-radius: 12px; padding: 10px;
  min-height: 100px; max-height: 300px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}

.comment-item { background: #fff; padding: 10px; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.comment-meta { font-size: 0.75rem; color: #94a3b8; margin-bottom: 4px; display: flex; justify-content: space-between; }
.comment-text { font-size: 0.9rem; color: #334155; white-space: pre-wrap; }

.comment-input-area textarea {
  width: 100%; height: 80px; padding: 10px; border: 1px solid #cbd5e1;
  border-radius: 8px; resize: none; font-family: inherit; margin-bottom: 8px;
}
.btn-small {
  align-self: flex-end; padding: 8px 16px; background: var(--primary);
  color: #fff; border: none; border-radius: 8px; cursor: pointer;
}


/* ---------- Card Comments List ---------- */
.card-comments-list {
  width: 100%;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-comment-item {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 8px;
  border: 1px dotted #e2e8f0;
  font-size: 0.75rem;
}

.card-comment-item .comment-author {
  background: var(--primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.7rem;
}

.card-comment-item .comment-date {
  color: #94a3b8;
  font-size: 0.65rem;
}

.card-comment-item .comment-text {
  width: 100%;
  color: #334155;
  font-style: italic;
  margin-top: 4px;
  line-height: 1.4;
}

/* Delete button for comments */
.comment-delete-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 0.7rem;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  opacity: 0;
}

.card-comment-item:hover .comment-delete-btn {
  opacity: 1;
}

.comment-delete-btn:hover {
  color: #ef4444;
  background: #fef2f2;
}

/* ---------- Inline Comment Section ---------- */
.inline-comment-box {
  margin-top: 10px;
  padding: 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-radius: 12px;
  border: 2px solid #c7d2fe;
  animation: fade-in 0.2s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.inline-comment-box textarea {
  width: 100%;
  height: 70px;
  padding: 12px;
  border: 2px solid #c7d2fe;
  border-radius: 10px;
  resize: none;
  font-family: inherit;
  font-size: 0.85rem;
  margin-bottom: 10px;
  background: #fff;
  transition: all 0.2s ease;
}

.inline-comment-box textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.inline-comment-box textarea::placeholder {
  color: #a5b4fc;
}

.inline-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  float: right;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.inline-btn:hover { 
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.inline-btn:active {
  transform: translateY(0);
}

/* Clearfix for the float button */
.inline-comment-box::after {
  content: "";
  display: table;
  clear: both;
}


/* ---------- Approved Badge ---------- */
.approved-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background-color: #16a34a; /* Green */
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 10;
  pointer-events: none;
  letter-spacing: 0.5px;
}


/* ---------- Interactive Approved Badge (Remove Feature) ---------- */
.approved-badge.interactive {
  pointer-events: auto; /* Enable clicking */
  cursor: pointer;
  transition: all 0.2s ease;
}

.approved-badge.interactive:hover {
  background-color: #ef4444; /* Turn Red */
}

/* Hide the "ACCEPTED" text on hover */
.approved-badge.interactive:hover .badge-text {
  display: none;
}

/* Show "REMOVE" text on hover */
.approved-badge.interactive:hover::after {
  content: "REMOVE";
  font-weight: 800;
}