/* Sojourn admin UI — small custom SPA for PM onboarding review.
   Palette + typography match the marketing site for brand consistency. */

:root {
  --primary: #0177b5;
  --primary-dark: #004863;
  --success: #01aa34;
  --warning: #d97706;
  --danger: #b91c1c;
  --bg: #edf6f6;
  --bg-card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --code-bg: #f3f4f6;
}

* { box-sizing: border-box; }

/* Author rules with display: flex on .modal, #admin-nav, etc. override the
   user-agent's [hidden] { display: none }. Restore the hidden-attribute
   semantics explicitly. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: "Lora", Georgia, serif;
  color: var(--primary-dark);
  margin: 0 0 12px;
  font-weight: 600;
}

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

.muted { color: var(--text-muted); }
.small { font-size: 13px; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header ===== */

.admin-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header .container {
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand-logo { height: 32px; width: auto; }
.brand-text {
  font-family: "Lora", serif;
  font-size: 18px;
  color: var(--primary-dark);
  font-weight: 600;
}

#admin-nav {
  display: flex;
  gap: 18px;
  flex: 1;
}

#admin-nav a {
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 4px;
  font-weight: 500;
}
#admin-nav a:hover {
  color: var(--primary-dark);
  background: var(--border-light);
  text-decoration: none;
}
#admin-nav a.active {
  color: var(--primary-dark);
  background: var(--bg);
}

#user-strip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tier-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--border-light);
  color: var(--text-muted);
}
.tier-badge.tier-1 { background: #dbeafe; color: #1e40af; }
.tier-badge.tier-2 { background: #fef3c7; color: #92400e; }

/* ===== Buttons ===== */

.btn {
  display: inline-block;
  border: 1px solid transparent;
  background: var(--bg-card);
  color: var(--text);
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.btn:hover { background: var(--border-light); }

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

.btn--ghost {
  background: transparent;
  border-color: var(--border);
}

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

.btn--small { padding: 4px 10px; font-size: 13px; }

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Views ===== */

main { padding: 32px 0; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  gap: 16px;
}

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

.filter-row label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: var(--text-muted);
}

.filter-row select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  font-family: inherit;
  font-size: 14px;
}

.loading-card,
.signin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  max-width: 480px;
  margin: 60px auto;
}

.signin-card .lede {
  margin-bottom: 24px;
  color: var(--text-muted);
}

/* ===== Tables ===== */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
}

table thead {
  background: var(--bg);
  border-bottom: 2px solid var(--border-light);
}

table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table td {
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
  vertical-align: top;
}

table tbody tr:hover {
  background: #f9fafb;
  cursor: pointer;
}

.status-pill {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--border-light);
  color: var(--text-muted);
}
.status-pill.status-submitted { background: #dcfce7; color: #166534; }
.status-pill.status-quarantined { background: #fee2e2; color: #991b1b; }
.status-pill.status-awaiting_scan,
.status-pill.status-awaiting_upload { background: #fef3c7; color: #92400e; }
.status-pill.status-reviewed { background: #ede9fe; color: #5b21b6; }

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

/* ===== Detail view ===== */

.back-btn { margin-bottom: 16px; }

.detail-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 4px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.detail-grid dt {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.detail-grid dd {
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  word-break: break-word;
}
.detail-grid dt:last-of-type,
.detail-grid dd:last-of-type { border-bottom: none; }

.detail-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.audit-rows-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 20px;
}
.audit-rows-card h3 { margin-bottom: 12px; }

/* ===== Modal ===== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}
.modal-card--wide { max-width: 720px; }

.modal-card h2 { margin-top: 0; }

#reason-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin: 12px 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.codeblock {
  background: var(--code-bg);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow: auto;
}

/* ===== Toast/notification (lightweight) ===== */

#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
#toast.show { opacity: 1; }
#toast.toast-error { background: var(--danger); }
#toast.toast-success { background: var(--success); }

/* ===== Mobile ===== */

@media (max-width: 760px) {
  .admin-header .container { flex-wrap: wrap; gap: 12px; }
  #admin-nav { width: 100%; order: 3; }
  #user-strip { margin-left: auto; }
  .view-header { flex-direction: column; align-items: flex-start; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid dt { padding-bottom: 0; border-bottom: none; }
  .detail-grid dd { padding-top: 0; padding-bottom: 12px; margin-bottom: 4px; }
  table { font-size: 13px; }
  table th, table td { padding: 8px 10px; }
}
