: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;
  place-items: center;       /* centers the card */
  -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); }


/* ---------- Floating Action Button (Bottom Left) ---------- */
.fab-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 56px;
  height: 56px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4);
  cursor: pointer;
  z-index: 1000;
  display: none;
  place-items: center;
  transition: transform 0.2s ease, background 0.2s;
}

.fab-btn:hover { background: var(--primary-dark); transform: scale(1.05); }
.fab-btn:active { transform: scale(0.95); }
/* Right-side positioning for List Button */
.list-btn-right {
  left: auto !important; /* Override the left position */
  right: 24px;           /* Move to right */
  background: #6366f1;   /* Optional: Different color (Indigo) to distinguish */
}
.list-btn-right:hover { background: #4f46e5; }


/* Grant Button - Positioned above the List Button */
.grant-btn-right {
  left: auto !important;
  right: 24px;
  /* 24px (bottom) + 56px (btn height) + 16px (gap) = 96px */
  bottom: 96px; 
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); /* Orange color */
  color: white;
  display: none; /* Hidden by default, shown via JS */
}
.grant-btn-right:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(217, 119, 6, 0.4);
}
.grant-btn-right:active {
  transform: scale(0.95);
}

/* ---------- Modal Popup ---------- */
.modal-overlay {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5); /* Dimmed background */
  z-index: 2000;
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
}

/* When we add the class 'active' via JS, it will show */
.modal-overlay.active { display: flex; }

.modal-content {
  background: #fff;
  width: 90%;
  max-width: 400px;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  animation: fade-in 0.3s ease;
}

.modal-content h3 { margin-top: 0; color: #333; }

/* New Student Header Style */
.student-header {
  background: #eef2ff; /* Light blue tint */
  color: var(--primary);
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 24px;
  border: 1px dashed #c7d2fe;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* ---------- Autocomplete Suggestions ---------- */
.suggestions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  top: 100%; /* pushes it right below the input */
  left: 0;
  width: 100%;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 3000; /* Must be higher than modal */
  display: none; /* Hidden by default */
}

.suggestions-list.active {
  display: block;
}

.suggestions-list li {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  text-align: left;
  font-size: 0.9rem;
}

.suggestions-list li:last-child { border-bottom: none; }
.suggestions-list li:hover { background-color: #f6f7fb; color: var(--primary); }


/* Style for the added phone item rows */
.phone-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f9fafb;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-size: 0.9rem;
}
.phone-item strong { margin-right: 8px; color: var(--primary); }


/* ---------- Table & Badges ---------- */
.table-container {
  width: 95%;
  max-width: 1200px;
  background: #fff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
  margin-top: 20px;
  animation: fade-in 0.45s ease both;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.table-header h2 { margin: 0; color: #333; font-size: 1.5rem; }

.refresh-btn {
  background: #f3f4f6; border: none; width: 40px; height: 40px;
  border-radius: 50%; cursor: pointer; color: #555; transition: 0.2s;
}
.refresh-btn:hover { background: #e5e7eb; transform: rotate(15deg); }

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px; /* Ensures table doesn't squish too much */
}

th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
}

th {
  background-color: #f9fafb;
  font-weight: 600;
  color: #4b5563;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tr:hover { background-color: #fafbfc; }

/* The Badge Style */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Colors for different badges */
.badge-hv { background: #e0f2fe; color: #0284c7; } /* Blue */
.badge-cha { background: #dcfce7; color: #16a34a; } /* Green */
.badge-me { background: #fce7f3; color: #db2777; } /* Pink */
.badge-chi { background: #f3e8ff; color: #9333ea; } /* Purple */
.badge-ba { background: #ffedd5; color: #ea580c; } /* Orange */
.badge-ong { background: #fef9c3; color: #ca8a04; } /* Yellow */

/* Phone Link Style */
.phone-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  text-decoration: none;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.phone-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.phone-link i {
  font-size: 0.7rem;
}

/* Email subtitle under name */
.email-sub {
  font-size: 0.75rem;
  color: #9ca3af;
  font-weight: 400;
}

/* Better table header */
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid #f0f0f0;
}

.table-header h2 {
  margin: 0;
  font-size: 1.6rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Improved table rows */
tr:hover {
  background-color: #f8fafc;
  transition: background-color 0.2s;
}

th {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}



th {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}



/* ========== MAIN SEARCH SECTION ========== */
.search-section {
  width: 100%;
  max-width: 600px;
  padding: 20px;
  animation: fade-in 0.5s ease both;
}

.search-card {
  background: #fff;
  border-radius: 24px;
  padding: 40px 32px;
  box-shadow: 
    0 20px 50px rgba(16, 24, 40, 0.1),
    0 0 0 1px rgba(0,0,0,0.02);
}

.search-greeting {
  text-align: center;
  margin-bottom: 32px;
}

.search-greeting i {
  font-size: 3rem;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  display: inline-block;
  animation: phone-bounce 2s ease-in-out infinite;
}

@keyframes phone-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-5px) rotate(-5deg); }
  75% { transform: translateY(-5px) rotate(5deg); }
}

.search-greeting h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.search-greeting p {
  font-size: 0.95rem;
  color: #6b7280;
  margin: 0;
}

/* Search Input */
.search-input-wrapper {
  position: relative;
  margin-bottom: 8px;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 1rem;
  pointer-events: none;
  transition: color 0.2s;
}

.search-input-wrapper input {
  width: 100%;
  padding: 18px 50px 18px 50px;
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  font-size: 1.05rem;
  background: #f9fafb;
  outline: none;
  transition: all 0.25s ease;
}

.search-input-wrapper input:focus {
  border-color: #6366f1;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.search-input-wrapper input:focus + .search-icon,
.search-input-wrapper input:focus ~ .search-icon {
  color: #6366f1;
}

.clear-search-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: #e5e7eb;
  border-radius: 50%;
  cursor: pointer;
  color: #6b7280;
  display: grid;
  place-items: center;
  transition: all 0.2s;
}

.clear-search-btn:hover {
  background: #d1d5db;
  color: #374151;
}

/* Main Suggestions List */
.main-suggestions {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

.main-suggestions.active {
  display: block;
}

.main-suggestions li {
  padding: 16px 20px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background 0.15s;
}

.main-suggestions li:last-child {
  border-bottom: none;
}

.main-suggestions li:hover {
  background: #f8fafc;
}

.main-suggestions li .suggestion-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}

.main-suggestions li .suggestion-info {
  flex: 1;
  min-width: 0;
}

.main-suggestions li .suggestion-name {
  font-weight: 600;
  color: #1f2937;
  font-size: 0.95rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-suggestions li .suggestion-email {
  font-size: 0.85rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Selected Student Card */
.selected-student-card {
  margin-top: 24px;
  padding: 24px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  animation: slide-up 0.3s ease;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.student-info {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px dashed #d1d5db;
}

.student-avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.student-details h3 {
  margin: 0 0 4px 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1f2937;
}

.student-details p {
  margin: 0;
  font-size: 0.9rem;
  color: #6b7280;
}

/* Phone Buttons Grid */
.phone-buttons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .phone-buttons-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.phone-call-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 12px;
  border: none;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.phone-call-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.phone-call-btn:active {
  transform: scale(0.97);
}

.phone-call-btn.disabled {
  background: #f3f4f6 !important;
  color: #9ca3af !important;
  cursor: not-allowed;
  box-shadow: none !important;
}

.phone-call-btn.disabled:hover {
  transform: none;
}

/* Button Colors */
.phone-call-btn.btn-hv { background: linear-gradient(135deg, #0ea5e9, #0284c7); color: #fff; }
.phone-call-btn.btn-cha { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; }
.phone-call-btn.btn-me { background: linear-gradient(135deg, #ec4899, #db2777); color: #fff; }
.phone-call-btn.btn-chi { background: linear-gradient(135deg, #a855f7, #9333ea); color: #fff; }
.phone-call-btn.btn-ba { background: linear-gradient(135deg, #f97316, #ea580c); color: #fff; }
.phone-call-btn.btn-ong { background: linear-gradient(135deg, #eab308, #ca8a04); color: #fff; }

/* No results message */
.no-results {
  padding: 24px;
  text-align: center;
  color: #6b7280;
}

.no-results i {
  font-size: 2rem;
  color: #d1d5db;
  margin-bottom: 8px;
  display: block;
}




/* ---------- NEW: Missing Contacts Stats ---------- */
.missing-stats {
  background: #fff4f2; /* Light red/orange background */
  border: 1px solid #fee2e2;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: fade-in 0.5s ease;
}

.missing-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.missing-content i {
  color: #ef4444;
  font-size: 1.1rem;
}

.btn-sm {
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #ffcdcd;
  color: #dc2626;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.btn-sm:hover {
  background: #fef2f2;
  border-color: #dc2626;
}

/* Missing list items in modal */
.missing-item {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #333;
}
.missing-item:last-child { border-bottom: none; }
.missing-item i { color: #ccc; }


/* ---------- NEW: Top Right Compact Badges ---------- */
.top-badges-container {
  position: fixed;
  top: 8px;           /* Closer to top */
  right: 8px;         /* Closer to right */
  display: flex;
  align-items: center;
  gap: 8px;           /* Reduce gap between items */
  z-index: 2500;
  
  /* Compact Container styling */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  padding: 4px 10px 4px 8px; /* Tighter padding */
  border-radius: 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.05);
  animation: fade-in 0.5s ease;
}

/* The "Cần cập nhật SĐT" text */
.group-label {
  font-size: 0.75rem; /* Smaller font */
  font-weight: 600;
  color: #6b7280;     /* Slightly lighter gray */
  margin-right: 2px;
}

/* The colored badges */
.compact-badge {
  padding: 4px 10px;  /* Smaller padding inside badge */
  border-radius: 12px;
  font-size: 0.75rem; /* Smaller font */
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;           /* Tighter gap between icon and text */
  cursor: pointer;
  transition: transform 0.2s ease;
}

.compact-badge:hover {
  transform: translateY(-1px);
}

.compact-badge i {
  font-size: 0.75rem; /* Smaller icon */
}

.compact-badge strong {
  font-size: 0.8rem;
  font-weight: 800;
}

/* Red Badge (Student) */
.badge-alert-red {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* Yellow Badge (Teacher) */
.badge-alert-yellow {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}


/* ========== STATS DASHBOARD GRID ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
  border: 1px solid #f1f5f9;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 12px rgba(0,0,0,0.05);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
}

/* Card Themes */
.stat-card.blue .stat-icon { background: #eff6ff; color: #3b82f6; }
.stat-card.blue { border-bottom: 3px solid #3b82f6; }

.stat-card.purple .stat-icon { background: #faf5ff; color: #a855f7; }
.stat-card.purple { border-bottom: 3px solid #a855f7; }

.stat-card.orange .stat-icon { background: #fff7ed; color: #f97316; }
.stat-card.orange { border-bottom: 3px solid #f97316; }

.stat-card.pink .stat-icon { background: #fdf2f8; color: #ec4899; }
.stat-card.pink { border-bottom: 3px solid #ec4899; }

/* Responsive adjustments */
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
  .stat-value { font-size: 1.2rem; }
}




/* Red Card Theme */
.stat-card.red .stat-icon { background: #fef2f2; color: #ef4444; }
.stat-card.red { border-bottom: 3px solid #ef4444; }


