/* =========================================================
   Components — Stable UI Elements (V5.0 - PROFESSIONAL MINIMAL)
   ========================================================= */

/* --- Interactive State System for Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-6);
  height: 44px; /* Optimal Touch Area: min-height 44px */
  min-width: 44px;
  border-radius: var(--radius-sm); /* Standardized Border Radius */
  font-weight: 600;
  font-size: 0.875rem;
  transition: all var(--duration-fast) var(--ease-premium);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

/* Default Primary Button */
.btn-primary {
  background: var(--color-primary-500);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-600);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  background: var(--color-primary-700);
  transform: translateY(1px);
}

/* Outline / Secondary Button */
.btn-outline {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-primary);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--neutral-400);
  background: var(--neutral-100);
  transform: translateY(-1px);
}
.btn-outline:active:not(:disabled) {
  background: var(--neutral-200);
  transform: translateY(1px);
}

/* Danger / Delete Action Button */
.btn-danger {
  background: var(--color-error);
  color: white;
}
.btn-danger:hover:not(:disabled) {
  background: oklch(50% 0.16 28);
  transform: translateY(-1px);
}
.btn-danger:active:not(:disabled) {
  background: oklch(42% 0.14 28);
  transform: translateY(1px);
}

/* Success / Save Action Button */
.btn-success {
  background: var(--color-success);
  color: white;
}
.btn-success:hover:not(:disabled) {
  background: oklch(54% 0.15 145);
  transform: translateY(-1px);
}
.btn-success:active:not(:disabled) {
  background: oklch(46% 0.13 145);
  transform: translateY(1px);
}

/* Warning Button */
.btn-warning {
  background: var(--color-warning);
  color: var(--neutral-900);
}
.btn-warning:hover:not(:disabled) {
  background: oklch(70% 0.13 75);
  transform: translateY(-1px);
}
.btn-warning:active:not(:disabled) {
  background: oklch(62% 0.11 75);
  transform: translateY(1px);
}

/* Disabled State */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Small Buttons */
.btn-sm { 
  height: 36px; 
  padding: 0 var(--sp-4); 
  font-size: 0.8125rem; 
  border-radius: var(--radius-xs); 
}

/* Full Width Button */
.btn-block { 
  width: 100%; 
}

/* --- Clean Flat Cards --- */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-normal) var(--ease-premium);
  position: relative;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--neutral-300);
}

/* --- Stats Widget System (No Hero Clichés, Symmetrical Grid Items) --- */
.stat-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.stat-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--neutral-900);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Progress Indicators --- */
.progress-track {
  width: 100%;
  height: 6px;
  background: var(--neutral-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--color-primary-500);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-premium);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}
.badge-primary { background: var(--color-primary-50); color: var(--color-primary-600); border: 1px solid var(--color-primary-100); }
.badge-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success-border); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); }
.badge-danger  { background: var(--color-error-bg); color: var(--color-error); border: 1px solid var(--color-error-border); }

/* --- Interactive Tabs System --- */
.tabs-container {
  display: flex;
  border-bottom: 1px solid var(--border-default);
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.tab-item {
  padding: var(--sp-3) var(--sp-1);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--duration-fast) var(--ease-premium);
}
.tab-item:hover {
  color: var(--neutral-900);
}
.tab-item.active {
  color: var(--color-primary-500);
  border-bottom-color: var(--color-primary-500);
}

/* --- Avatars --- */
.avatar {
  width: 36px; 
  height: 36px;
  border-radius: var(--radius-xs);
  background: var(--neutral-100);
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-weight: 700;
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.avatar-lg { 
  width: 56px; 
  height: 56px; 
  font-size: 1.25rem; 
}

/* --- Robust Form Inputs & Validation States --- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--neutral-800);
}
.input, select {
  width: 100%;
  height: 44px; /* Optimal Touch Target Height */
  padding: 0 var(--sp-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: all var(--duration-fast) var(--ease-premium);
}
.input:hover:not(:disabled), select:hover:not(:disabled) {
  border-color: var(--neutral-400);
}
.input:focus, select:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px var(--color-primary-50);
}
.input:disabled, select:disabled {
  background: var(--neutral-100);
  color: var(--neutral-400);
  cursor: not-allowed;
}

/* Error validation state */
.input.error {
  border-color: var(--color-error);
}
.input.error:focus {
  box-shadow: 0 0 0 3px var(--color-error-bg);
}
.error-message {
  font-size: 0.75rem;
  color: var(--color-error);
  font-weight: 600;
  margin-top: -2px;
}

/* --- Robust Table UX (Teacher Facing & Student List) --- */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  margin-bottom: var(--sp-6);
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}
.table th, .table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-default);
}
.table th {
  background: var(--neutral-100);
  font-weight: 700;
  color: var(--neutral-800);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr:hover {
  background: var(--neutral-50);
}

/* --- Empty States UX --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  background: var(--neutral-50);
  margin: var(--sp-4) 0;
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--neutral-400);
  margin-bottom: var(--sp-4);
}
.empty-state-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--neutral-900);
  margin-bottom: var(--sp-1);
}
.empty-state-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 380px;
  margin-bottom: var(--sp-6);
}

/* --- Custom Toast Notification System (Fixed & Smooth) --- */
.toast-container {
  position: fixed;
  top: var(--sp-6);
  right: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  z-index: 9999;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  animation: slideIn var(--duration-normal) var(--ease-premium) both;
  position: relative;
}
.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.toast-message {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--neutral-900);
  flex-1: 1;
}
.toast-close {
  cursor: pointer;
  background: none;
  border: none;
  color: var(--neutral-400);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast-close:hover {
  color: var(--neutral-900);
}

.toast-success { border-left: 3px solid var(--color-success); }
.toast-success .toast-icon { color: var(--color-success); }

.toast-error { border-left: 3px solid var(--color-error); }
.toast-error .toast-icon { color: var(--color-error); }

.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-warning .toast-icon { color: var(--color-warning); }

.toast-info { border-left: 3px solid var(--color-info); }
.toast-info .toast-icon { color: var(--color-info); }

@keyframes slideIn {
  from { transform: translateY(-16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* --- Clean Confirmation Modal Styles --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-4);
  animation: fadeIn var(--duration-fast) var(--ease-premium) both;
}
.modal-overlay.open {
  display: flex;
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-premium);
  width: 100%;
  max-width: 460px;
  padding: var(--sp-8);
  animation: scaleIn var(--duration-normal) var(--ease-premium) both;
}
.modal-header {
  margin-bottom: var(--sp-4);
}
.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--neutral-900);
}
.modal-body {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--sp-6);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
}

@keyframes scaleIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* --- Skeleton Loaders for Performance UX --- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--neutral-100);
  border-radius: var(--radius-xs);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  100% { transform: translateX(100%); }
}

.skeleton-text { height: 14px; width: 100%; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 50%; margin-bottom: 16px; }
.skeleton-avatar { width: 36px; height: 36px; border-radius: var(--radius-xs); }
.skeleton-card { height: 160px; width: 100%; border-radius: var(--radius-md); }

/* --- Spin Loader --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--neutral-200);
  border-top-color: var(--color-primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}


