/* ===== Admin Styles ===== */
/* Imports shared design tokens */

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

:root {
  --primary: #1a1a6e;
  --primary-dark: #0e0e4a;
  --primary-light: #2d2d9e;
  --accent: #c8a951;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --danger: #dc2626;
  --success: #16a34a;
  --google-blue: #4285f4;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max-width: 960px;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

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

.btn-sm {
  padding: 6px 16px;
  font-size: 0.9rem;
}

.btn-google {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
}
.btn-google:hover { border-color: var(--google-blue); background: var(--gray-50); }
.btn-google svg { width: 20px; height: 20px; }

/* Header */
.admin-header {
  background: var(--primary);
  color: var(--white);
  padding: 0 20px;
  box-shadow: var(--shadow-md);
}

.admin-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-logo { height: 44px; width: auto; }

.admin-badge {
  background: var(--accent);
  color: var(--primary-dark);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-back-link {
  color: var(--gray-300);
  font-size: 0.95rem;
}
.admin-back-link:hover { color: var(--white); }

.admin-header-right .btn-sm {
  background: transparent;
  color: var(--gray-300);
  border: 1px solid var(--gray-500);
}
.admin-header-right .btn-sm:hover {
  color: var(--white);
  border-color: var(--white);
}

/* Auth */
.admin-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px);
  padding: 20px;
}

.admin-auth-card {
  background: var(--white);
  border-radius: 8px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
}

.admin-auth-card h1 {
  font-size: 1.6rem;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.admin-auth-card p {
  color: var(--gray-500);
  margin-bottom: 24px;
}

.admin-auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Main Content */
.admin-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* Stats */
.admin-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.9rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
  display: block;
}

/* Tabs */
.admin-tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
}

.admin-tab {
  background: none;
  border: none;
  padding: 12px 24px;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.admin-tab:hover { color: var(--primary); }
.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Panels */
.admin-panel { display: none; }
.admin-panel.active { display: block; }

.admin-panel h2 {
  font-size: 1.4rem;
  color: var(--gray-900);
  margin-bottom: 16px;
}

.panel-desc {
  color: var(--gray-500);
  margin-bottom: 20px;
}

/* Forms */
.admin-form {
  background: var(--white);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 26, 110, 0.1);
}

.form-group textarea { resize: vertical; min-height: 60px; }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.form-check label {
  font-size: 0.95rem;
  color: var(--gray-700);
  cursor: pointer;
}

/* CSV Upload */
.csv-upload {
  margin-bottom: 24px;
}

.csv-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  color: var(--gray-500);
}

.csv-upload-label:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(26, 26, 110, 0.02);
}

.csv-upload-label input { display: none; }

.csv-upload-label span { font-size: 1rem; font-weight: 500; }

/* Column Mapping */
.csv-mapping {
  background: var(--white);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.csv-mapping h3 {
  font-size: 1.1rem;
  color: var(--gray-800);
  margin-bottom: 16px;
  margin-top: 24px;
}

.csv-mapping h3:first-child { margin-top: 0; }

.mapping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mapping-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mapping-row label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  min-width: 90px;
}

.mapping-row select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 0.95rem;
  color: var(--gray-700);
  background: var(--white);
}

/* CSV Preview */
.preview-count {
  font-weight: 400;
  color: var(--gray-500);
  font-size: 0.95rem;
}

.csv-preview-wrap {
  overflow-x: auto;
  margin-bottom: 20px;
}

.csv-preview {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.csv-preview th,
.csv-preview td {
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--gray-200);
}

.csv-preview th {
  background: var(--gray-100);
  font-weight: 600;
  color: var(--gray-700);
}

.csv-preview td {
  color: var(--gray-600);
}

.csv-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

/* Progress Bar */
.import-progress {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s;
}

#progressText {
  font-size: 0.9rem;
  color: var(--gray-500);
  white-space: nowrap;
}

/* Donor Table */
.admin-search {
  margin-bottom: 16px;
}

.admin-search input {
  width: 100%;
  max-width: 360px;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--gray-800);
}

.admin-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 26, 110, 0.1);
}

.admin-table-wrap {
  overflow-x: auto;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
}

.admin-table th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table tbody tr:hover {
  background: var(--gray-50);
}

.msg-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-cell {
  white-space: nowrap;
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 6px;
  cursor: pointer;
  color: var(--gray-500);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover { color: var(--primary); border-color: var(--primary); }
.btn-delete:hover { color: var(--danger); border-color: var(--danger); }

.anon-badge {
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 500;
  margin-left: 6px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--white);
  border-radius: 8px;
  padding: 32px;
  max-width: 520px;
  width: 90%;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal h2 {
  font-size: 1.3rem;
  margin-bottom: 20px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--gray-400);
  cursor: pointer;
}
.modal-close:hover { color: var(--gray-700); }

.hidden { display: none !important; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--gray-900);
  color: var(--white);
  border-radius: var(--radius);
  font-size: 1rem;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  animation: slideUp 0.3s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .mapping-grid { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr; }
  .admin-tab { padding: 10px 16px; font-size: 0.9rem; }
}

@media (max-width: 480px) {
  .admin-header-inner { height: 52px; }
  .admin-logo { height: 36px; }
  .admin-auth-card { padding: 32px 20px; }
  .admin-form { padding: 16px; }
  .csv-mapping { padding: 16px; }
}
