/* Trust Portal — CockroachLabs docs-style theme (dark).
   Palette lifted from cockroachlabs.com/docs. */
:root {
  --bg: #FAFAFB;
  --surface: #FFFFFF;
  --surface-2: #F3F4F6;
  --border: rgba(15,23,42,0.08);
  --border-strong: rgba(15,23,42,0.16);
  --text: #171717;
  --text-strong: #0A0A0A;
  --muted: rgba(15,23,42,0.62);
  --muted-2: rgba(15,23,42,0.45);

  --primary: #6933FF;
  --primary-hover: #7d4dff;
  --primary-dark: #542abd;
  --primary-dim: rgba(105,51,255,0.10);
  --primary-glow: rgba(105,51,255,0.24);
  --on-primary: #FFFFFF;   /* text color for anything sitting on the primary purple */

  --cyan: #0891b2;
  --cyan-dim: rgba(8,145,178,0.12);
  --navy: #152849;

  --amber: #B45309;
  --amber-dim: rgba(180,83,9,0.12);
  --red: #DC2626;
  --red-dim: rgba(220,38,38,0.10);
  --blue: #2563EB;
  --blue-dim: rgba(37,99,235,0.10);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --sidebar-w: 240px;
  --topbar-h: 56px;
}

/* --- Base --- */
html, body { background: var(--bg); color: var(--text); }
body { font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
* { box-sizing: border-box; }

*:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(105,51,255,0.55); color: #fff; }
::-moz-selection { background: rgba(105,51,255,0.55); color: #fff; }
input::selection, textarea::selection { background: rgba(105,51,255,0.65); color: #fff; }
input::-moz-selection, textarea::-moz-selection { background: rgba(105,51,255,0.65); color: #fff; }

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

/* --- App shell (docs-style sidebar layout) --- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px 32px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 6px 10px 22px;
  color: var(--text-strong);
}
.sidebar-brand .brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff;
}
.sidebar-brand .sidebar-logo {
  display: block;
  width: 150px; height: 30px;
  background-color: var(--text-strong);
  -webkit-mask: url(/crl-logo.svg) no-repeat left center / contain;
          mask: url(/crl-logo.svg) no-repeat left center / contain;
}
.sidebar-brand .brand-sub {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-2);
  padding-left: 24px;
}
.sidebar-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted-2); font-weight: 600;
  padding: 14px 10px 6px;
}
.sidebar-link {
  position: relative;
  display: flex; align-items: center;
  padding: 8px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  border: none; background: transparent; width: 100%;
  text-align: left;
  transition: color 180ms ease, padding-left 200ms var(--ease-out);
  text-decoration: none;
  overflow: hidden;
}
/* Purple accent bar that slides in from the left on hover. */
.sidebar-link::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--primary);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 220ms var(--ease-out), width 180ms ease;
  border-radius: 0 2px 2px 0;
}
.sidebar-link:hover { color: var(--text); padding-left: 18px; background: rgba(15,23,42,0.03); }
.sidebar-link:hover::before { transform: scaleY(1); }
.sidebar-link.active {
  color: var(--text-strong);
  padding-left: 18px;
}
.sidebar-link.active::before {
  transform: scaleY(1);
  width: 3px;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}
.sidebar-link .sb-ico { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 90;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
}
.topbar-crumb { font-size: 13px; color: var(--muted); }
.topbar-crumb strong { color: var(--text); font-weight: 600; }

.content { padding: 32px 28px 64px; max-width: 1080px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .content { padding: 24px 20px 48px; }
}

/* --- Buttons (unified across .btn-primary and .btn-admin) --- */
.btn, .btn-admin {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  text-decoration: none;
  transition: transform 80ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
  background: transparent; color: var(--text);
}
.btn:hover, .btn-admin:hover { transform: translateY(-1px); }
.btn:active, .btn-admin:active { transform: translateY(0) scale(0.98); }
.btn:disabled, .btn-admin:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary, .btn-admin:not(.btn-neutral):not(.btn-danger) {
  background: var(--primary); color: var(--on-primary);
}
.btn-primary:hover, .btn-admin:not(.btn-neutral):not(.btn-danger):hover {
  background: var(--primary-hover); color: var(--on-primary);
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-danger { color: #FFFFFF; }
.btn-danger:hover { color: #FFFFFF; }

.btn-secondary, .btn-neutral {
  background: var(--surface); color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover, .btn-neutral:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--red); color: #fff;
}
.btn-danger:hover { background: #dc2626; box-shadow: 0 4px 14px rgba(239,68,68,0.25); }

.btn-sm, .btn-mini { padding: 4px 10px; font-size: 11px; }

/* --- Badges / pills / statuses (unify .badge-* .pill-* .req-status.*) --- */
.badge-sm, .badge, .status-pill, .req-status {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
}

.badge-public, .pill-fulfilled, .req-status.fulfilled, .pill-approved {
  background: var(--cyan-dim); color: var(--cyan);
}
.badge-confidential {
  background: rgba(15,23,42,0.05); color: var(--muted);
}
.badge.confidential {
  background: var(--red-dim); color: #FCA5A5;
}
.badge-expired, .pill-expired {
  background: var(--red-dim); color: var(--red);
}
.badge-expiring, .pill-expiring, .pill-pending, .req-status.pending {
  background: var(--amber-dim); color: var(--amber);
}
.pill-in_progress, .req-status.in_progress {
  background: var(--primary-dim); color: #b39dff;
}
.pill-rejected, .req-status.rejected {
  background: var(--red-dim); color: var(--red);
}
.pill-deactivated { color: var(--red); }

/* --- Cards / panels / surfaces --- */
.panel, .stat-card, .recent-card, .collection-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.stat-card:hover, .recent-card:hover {
  border-color: rgba(105,51,255,0.35);
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

/* --- Inputs --- */
input, select, textarea {
  background: #FFFFFF;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
input[type="checkbox"] { accent-color: var(--primary); }

/* --- Spinner --- */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Toast --- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  z-index: 300; display: none;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
  animation: slideUp 220ms var(--ease-out);
}
.toast.error { border-left-color: var(--red); }
.toast.leaving { animation: slideDown 200ms ease forwards; }
@keyframes slideUp   { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideDown { to   { transform: translateY(12px); opacity: 0; } }

/* --- Skeleton --- */
.skeleton {
  background: linear-gradient(90deg,
    rgba(15,23,42,0.05) 0%,
    rgba(15,23,42,0.09) 50%,
    rgba(15,23,42,0.05) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
  display: inline-block;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- Banners --- */
.error-banner, .success-banner, .error, .success {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.error-banner, .error { background: var(--red-dim); color: var(--red); }
.success-banner, .success { background: var(--primary-dim); color: #b39dff; }

/* --- Fade in --- */
.fade-in { animation: fadeIn 220ms var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
