/* Admin page only — not used on main app pages */

.admin-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-header h1 {
  margin: 0.5rem 0 0.25rem;
}

.admin-subtitle {
  margin: 0;
  color: #94a3b8;
}

.admin-back-link {
  color: #818cf8;
  text-decoration: none;
}

.admin-back-link:hover {
  text-decoration: underline;
}

.admin-logout-btn {
  width: auto;
  margin-top: 0;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.admin-backfill-btn {
  width: auto;
  margin-top: 0;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.admin-toolbar-hint {
  color: #94a3b8;
  font-size: 0.875rem;
}

.admin-loading {
  margin-bottom: 1rem;
  color: #94a3b8;
}

.admin-message {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.admin-message.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid #334155;
  border-radius: 12px;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.admin-users-table th,
.admin-users-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #334155;
  text-align: left;
  vertical-align: middle;
}

.admin-users-table th {
  background: #1e293b;
  color: #cbd5e1;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-users-table tbody tr.admin-user-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.admin-users-table tbody tr.admin-user-row:hover {
  background: rgba(59, 130, 246, 0.08);
}

.admin-users-table tbody tr.admin-user-row.is-self {
  background: rgba(99, 102, 241, 0.06);
}

.admin-users-table tr:last-child td {
  border-bottom: none;
}

.admin-role-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
}

.admin-role-badge.admin {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.admin-role-badge.staff {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

.admin-uid-cell {
  font-family: monospace;
  font-size: 0.8rem;
  color: #94a3b8;
  word-break: break-all;
}

.admin-empty {
  text-align: center;
  color: #94a3b8;
}

/* User detail modal — extends shared task modal styles from styles.css */
.admin-user-detail-modal {
  max-width: 500px;
}

.admin-user-meta-section {
  padding: 0.625rem;
  background: #0f172a;
  border-radius: 6px;
  border: 1px solid #334155;
}

.admin-user-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
  font-size: 0.8125rem;
}

.admin-user-meta-row + .admin-user-meta-row {
  border-top: 1px solid #334155;
}

.admin-user-meta-value {
  color: #e2e8f0;
  text-align: right;
  word-break: break-word;
}

.admin-user-form-field {
  margin-bottom: 0.75rem;
}

.admin-user-form-field:last-of-type {
  margin-bottom: 0;
}

.admin-user-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.625rem;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #f1f5f9;
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

.admin-user-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.admin-user-backend-note {
  margin: 0.75rem 0 0;
  padding: 0.625rem 0.75rem;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  font-size: 0.75rem;
  line-height: 1.45;
}

.admin-user-status {
  margin-top: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  line-height: 1.45;
  display: none;
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
}

.admin-user-status:not(:empty) {
  display: block;
}

.admin-user-status.error {
  display: block;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.admin-user-status.success {
  display: block;
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

.admin-user-status.warning {
  display: block;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fcd34d;
}

.admin-user-account-section {
  padding-top: 0.5rem;
}

.admin-user-secondary-btn {
  width: 100%;
  padding: 0.5rem 0.875rem;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.admin-user-secondary-btn:hover:not(:disabled) {
  background: #334155;
}

.admin-user-secondary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.admin-user-danger-section {
  margin-top: 0.25rem;
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(127, 29, 29, 0.12);
}

.admin-user-danger-copy {
  margin: 0.25rem 0 0.75rem;
  font-size: 0.8125rem;
  color: #fca5a5;
  line-height: 1.45;
}

.admin-user-delete-btn {
  width: 100%;
  margin-top: 0.5rem;
}

.admin-user-modal-busy {
  opacity: 0.85;
  pointer-events: none;
}

body.light-mode .admin-subtitle,
body.light-mode .admin-loading,
body.light-mode .admin-uid-cell,
body.light-mode .admin-empty {
  color: #64748b;
}

body.light-mode .admin-users-table th {
  background: #f1f5f9;
  color: #475569;
}

body.light-mode .admin-users-table th,
body.light-mode .admin-users-table td {
  border-bottom-color: #e2e8f0;
}

body.light-mode .admin-table-wrap {
  border-color: #e2e8f0;
}

body.light-mode .admin-user-meta-section {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.light-mode .admin-user-meta-row + .admin-user-meta-row {
  border-top-color: #e2e8f0;
}

body.light-mode .admin-user-meta-value {
  color: #0f172a;
}

body.light-mode .admin-user-input {
  background: #fff;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.light-mode .admin-user-status {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
}

body.light-mode .admin-user-secondary-btn {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.light-mode .admin-user-danger-section {
  background: rgba(254, 226, 226, 0.5);
  border-color: rgba(239, 68, 68, 0.35);
}

body.light-mode .admin-user-danger-copy {
  color: #b91c1c;
}

@media (max-width: 768px) {
  .admin-page {
    padding: 1rem 0.75rem 2rem;
  }

  .admin-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .admin-header h1 {
    font-size: 1.25rem;
  }

  .admin-logout-btn {
    width: 100%;
  }

  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-backfill-btn {
    width: 100%;
  }

  .admin-table-wrap {
    overflow-x: visible;
    border: none;
    background: transparent;
    border-radius: 0;
  }

  .admin-users-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  .admin-users-table thead {
    display: none;
  }

  .admin-users-table tbody tr.admin-user-row {
    display: block;
    margin-bottom: 0.75rem;
    border: 1px solid #334155;
    border-radius: 10px;
    overflow: hidden;
    background: #1e293b;
  }

  .admin-users-table tbody tr.admin-user-row:hover {
    background: rgba(59, 130, 246, 0.08);
  }

  .admin-users-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid #334155;
  }

  .admin-users-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    min-width: 4.75rem;
    padding-top: 0.1rem;
  }

  .admin-users-table td:last-child {
    border-bottom: none;
  }

  .admin-users-table tr:last-child td {
    border-bottom: 1px solid #334155;
  }

  .admin-users-table tr:last-child td:last-child {
    border-bottom: none;
  }

  .admin-uid-cell {
    font-size: 0.75rem;
    word-break: break-all;
    text-align: right;
  }

  .admin-users-table td.admin-empty {
    display: block;
    text-align: center;
    justify-content: center;
  }

  .admin-users-table td.admin-empty::before {
    display: none;
  }

  .admin-user-detail-modal {
    width: min(100%, 500px);
  }

  .admin-user-meta-row {
    flex-direction: column;
    gap: 0.15rem;
  }

  .admin-user-meta-value {
    text-align: left;
  }

  .admin-user-danger-section {
    padding: 0.625rem;
  }

  body.light-mode .admin-users-table tbody tr.admin-user-row {
    background: #fff;
    border-color: #e2e8f0;
  }

  body.light-mode .admin-users-table td {
    border-bottom-color: #e2e8f0;
  }
}

/* Admin user modal — mobile (modal is portaled to document.body) */

.modal-overlay:has(.admin-user-detail-modal) {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  padding:
    max(0.75rem, env(safe-area-inset-top))
    max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom))
    max(0.75rem, env(safe-area-inset-left));
}

.admin-user-detail-modal {
  width: min(100%, 500px);
  max-height: calc(100dvh - 1.5rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  margin: auto;
}

.admin-user-detail-modal .task-modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: inherit;
}

.admin-user-detail-modal .task-modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: inherit;
  margin-bottom: 0;
}

@media (hover: none), (pointer: coarse) {
  .admin-backfill-btn,
  .admin-logout-btn,
  .admin-user-secondary-btn,
  .admin-user-delete-btn,
  .admin-user-detail-modal .task-modal-close,
  .admin-user-detail-modal .task-modal-save-btn {
    min-height: 44px;
  }
}

@media (max-width: 360px) {
  .admin-toolbar-hint {
    display: none;
  }
}
