/* ============================================================
   COMPONENTS.CSS  —  Buttons, Forms, Cards, Badges, Tables
   Donor-Student Management Portal
   ============================================================ */

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-md);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}
.btn:focus-visible {
  outline: 3px solid var(--primary-mid);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Variants */
.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,60,94,0.3);
}

.btn-accent {
  background: var(--accent);
  color: var(--white);
}
.btn-accent:hover {
  background: var(--accent-hover);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(232,146,58,0.35);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover {
  background: #a93226;
  color: var(--white);
}

.btn-success {
  background: var(--success);
  color: var(--white);
}

/* Sizes */
.btn-sm {
  padding: 6px var(--space-3);
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding: 14px var(--space-8);
  font-size: 1rem;
  border-radius: var(--radius-md);
}
.btn-full { width: 100%; }

/* Icon button */
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

/* Loading state */
.btn.loading {
  pointer-events: none;
  opacity: 0.8;
}
.btn.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: var(--space-2);
}

/* ── FORM ELEMENTS ─────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}
.form-control::placeholder { color: var(--text-light); }
.form-control:hover { border-color: var(--gray-400); }
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(46,109,164,0.12);
}
.form-control.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.10);
}
.form-control.success {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(45,125,90,0.10);
}

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7689' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}
.form-error {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: var(--space-1);
  display: none;
}
.form-group.has-error .form-error { display: block; }
.form-group.has-error .form-control { border-color: var(--danger); }

/* Input with icon */
.input-wrapper {
  position: relative;
}
.input-wrapper .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 1rem;
  pointer-events: none;
}
.input-wrapper .form-control { padding-left: 42px; }
.input-wrapper.icon-right .form-control { padding-left: 14px; padding-right: 42px; }
.input-wrapper.icon-right .input-icon { left: auto; right: 14px; cursor: pointer; pointer-events: all; }
.input-wrapper.icon-right .input-icon:hover { color: var(--primary); }

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 17px; height: 17px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}
.form-check-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Password strength meter */
.strength-meter {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--gray-200);
  margin-top: var(--space-2);
  overflow: hidden;
}
.strength-bar {
  height: 100%;
  border-radius: var(--radius-full);
  width: 0;
  transition: width 0.4s ease, background 0.4s ease;
}

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text-primary);
}
.card-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.card-body  { padding: var(--space-6); }
.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Stat card */
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-md), transform var(--transition-md);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.btn-icon { display: inline-flex; align-items: center; vertical-align: -2px; }
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.orange { background: var(--accent-light);  color: var(--accent); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }

.stat-info { flex: 1; }
.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--text-primary);
  line-height: 1.1;
  margin-top: 2px;
}
.stat-change {
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: var(--space-1);
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

.stat-card.unassigned-alert {
  position: relative;
  isolation: isolate;
  border-color: #eec6c2;
  box-shadow:
    0 0 0 1px rgba(192, 57, 43, 0.1),
    0 6px 14px rgba(192, 57, 43, 0.08);
}

.stat-card.unassigned-alert::before {
  content: '';
  position: absolute;
  inset: -4px;
  pointer-events: none;
  border-radius: calc(var(--radius-lg) + 4px);
  border: 1.5px solid rgba(192, 57, 43, 0.26);
  background: transparent;
  box-shadow:
    0 0 8px 2px rgba(192, 57, 43, 0.22),
    0 0 16px 4px rgba(192, 57, 43, 0.12);
  z-index: -1;
  opacity: 0.4;
  animation: breathingUnderglow 2.2s ease-in-out infinite;
}

@keyframes breathingUnderglow {
  0%, 100% {
    transform: scale(0.996);
    opacity: 0.3;
    border-color: rgba(192, 57, 43, 0.2);
  }
  50% {
    transform: scale(1.006);
    opacity: 0.52;
    border-color: rgba(192, 57, 43, 0.34);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stat-card.unassigned-alert::before {
    animation: none;
    opacity: 0.38;
  }
}

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  line-height: 1.4;
}
.badge-primary { background: var(--primary-light);  color: var(--primary); }
.badge-success { background: var(--success-light);  color: var(--success); }
.badge-danger  { background: var(--danger-light);   color: var(--danger); }
.badge-warning { background: var(--warning-light);  color: var(--warning); }
.badge-info    { background: var(--info-light);     color: var(--info); }
.badge-gray    { background: var(--gray-100);       color: var(--gray-600); }
.badge-accent  { background: var(--accent-light);   color: var(--accent); }

/* Dot indicator */
.badge::before {
  content: '●';
  font-size: 0.5rem;
}

/* ── TABLE ─────────────────────────────────────────────────── */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table thead th {
  padding: 12px 16px;
  background: var(--gray-50);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 13px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── AVATAR ────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--primary-light);
  color: var(--primary);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm  { width: 28px; height: 28px; font-size: 0.75rem; }
.avatar-lg  { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar-xl  { width: 72px; height: 72px; font-size: 1.5rem; }

/* ── ALERT ─────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  border: 1px solid;
}
.alert-success { background: var(--success-light); color: var(--success); border-color: #a8d5bf; }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border-color: #f0b8b2; }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: #f5d5a5; }
.alert-info    { background: var(--info-light);    color: var(--info);    border-color: #a8d1f0; }

/* ── DIVIDER ───────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── SEARCH BAR ────────────────────────────────────────────── */
.search-bar {
  position: relative;
  max-width: 320px;
}
.search-bar input {
  width: 100%;
  padding: 8px 14px 8px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  background: var(--white);
  color: var(--text-primary);
  transition: border-color var(--transition);
  outline: none;
}
.search-bar input::placeholder { color: var(--text-light); }
.search-bar input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(46,109,164,0.10); }
.search-bar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.875rem;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
}
.search-bar .search-icon svg {
  width: 15px;
  height: 15px;
}

/* ── PAGINATION ────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.page-btn {
  min-width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.page-btn:hover   { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.page-btn.active  { background: var(--primary); border-color: var(--primary); color: var(--white); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,20,32,0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-6);
  opacity: 0; visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s ease;
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }
.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
}
.modal-body   { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--space-3);
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.2rem;
  padding: 4px; border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--gray-100); }

.import-choice-modal {
  max-width: 620px;
}
.import-choice-header {
  background: linear-gradient(135deg, rgba(26, 60, 94, 0.08), rgba(232, 146, 58, 0.08));
}
.import-choice-subtitle {
  margin-top: 4px;
  font-size: 0.84rem;
  color: var(--text-muted);
}
.import-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.import-choice-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  background: var(--gray-50);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
}
.import-choice-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.import-choice-students:hover {
  border-color: rgba(45, 125, 90, 0.4);
  background: rgba(45, 125, 90, 0.06);
}
.import-choice-donors:hover {
  border-color: rgba(26, 60, 94, 0.36);
  background: rgba(26, 60, 94, 0.06);
}
.import-choice-icon {
  font-size: 1.2rem;
}
.import-choice-label {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text-primary);
}
.import-choice-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .import-choice-grid {
    grid-template-columns: 1fr;
  }
}

/* ── PROGRESS BAR ──────────────────────────────────────────── */
.progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--gray-200);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width 0.6s ease;
}
.progress-bar.accent  { background: var(--accent); }
.progress-bar.success { background: var(--success); }
