/* Design tokens ported from the Sniff Dashboard Lovable project (light theme). */

:root {
  --radius: 0.375rem;
  --background: oklch(0.985 0.004 90);
  --foreground: oklch(0.22 0.008 60);
  --card: oklch(1 0 0);
  --primary: oklch(0.24 0.01 60);
  --primary-foreground: oklch(0.985 0.004 90);
  --secondary: oklch(0.955 0.006 85);
  --secondary-foreground: oklch(0.24 0.01 60);
  --muted: oklch(0.955 0.006 85);
  --muted-foreground: oklch(0.53 0.01 70);
  --destructive: oklch(0.55 0.19 28);
  --border: oklch(0.9 0.007 85);
  --ring: oklch(0.6 0.06 55);
  --brand: oklch(0.58 0.13 45);
  --font-sans: "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}

/* Dark palette from the Lovable project's .dark block. A head script sets
   data-theme before first paint (localStorage, falling back to system). */
:root[data-theme="dark"] {
  --background: oklch(0.129 0.042 264.695);
  --foreground: oklch(0.984 0.003 247.858);
  --card: oklch(0.208 0.042 265.755);
  --primary: oklch(0.929 0.013 255.508);
  --primary-foreground: oklch(0.208 0.042 265.755);
  --secondary: oklch(0.279 0.041 260.031);
  --secondary-foreground: oklch(0.984 0.003 247.858);
  --muted: oklch(0.279 0.041 260.031);
  --muted-foreground: oklch(0.704 0.04 256.788);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --ring: oklch(0.551 0.027 264.364);
  color-scheme: dark;
}

.icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: block;
}

:root[data-theme="dark"] .icon-moon {
  display: none;
}

* {
  box-sizing: border-box;
  border-color: var(--border);
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.label-caps {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin: 0;
}

h1 {
  margin: 0.5rem 0 0;
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.subtitle {
  margin: 0.5rem 0 0;
  max-width: 28rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  line-height: 1.45;
}

.icon {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}

/* ---- dashboard layout ---- */

.container {
  max-width: 56rem;
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2rem;
}

.header-side {
  display: flex;
  align-items: flex-end;
  gap: 2.5rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.stats {
  display: flex;
  gap: 2.5rem;
}

.stat .label-caps {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.stat-value {
  margin: 0.25rem 0 0;
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  padding: 0.375rem 0.75rem;
  font: 500 0.75rem var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s;
}

.btn-outline:hover {
  background: var(--muted);
}

.theme-btn {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  padding: 0.5rem;
}

/* ---- controls row ---- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

.search {
  position: relative;
  flex: 1;
  min-width: 14rem;
}

.search .icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--muted-foreground);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem 0 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  font: 0.875rem var(--font-sans);
}

.search input::placeholder {
  color: var(--muted-foreground);
}

.search input:focus-visible,
.role-select:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.25rem;
}

.pill {
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--muted-foreground);
  padding: 0.375rem 0.75rem;
  font: 500 0.75rem var(--font-sans);
  text-transform: capitalize;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.pill:hover {
  background: var(--muted);
}

.pill.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* ---- members table ---- */

.table {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card);
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 1fr 9rem 6rem 6rem;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.row:last-child {
  border-bottom: 0;
}

.row.head {
  padding: 0.75rem 1.25rem;
}

.row:not(.head):hover {
  background: color-mix(in oklch, var(--muted) 50%, transparent);
}

.row .right {
  text-align: right;
  justify-self: end;
}

.member {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  font: 0.75rem var(--font-mono);
  text-transform: uppercase;
}

.member-name {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-email {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-select {
  height: 2.25rem;
  width: 100%;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  font: 0.875rem var(--font-sans);
  text-transform: capitalize;
  cursor: pointer;
}

.flag-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.flag-cell .icon {
  width: 1rem;
  height: 1rem;
  color: var(--brand);
}

.empty {
  margin: 0;
  padding: 2.5rem 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pagination .btn-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-range {
  margin-right: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

.footnote {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* ---- switch ---- */

.switch {
  position: relative;
  display: inline-block;
  width: 2rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background: var(--border);
  transition: background-color 0.15s;
  pointer-events: none;
}

.switch .track::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.125rem - 4px);
  height: calc(1.125rem - 4px);
  border-radius: 9999px;
  background: var(--card);
  transition: transform 0.15s;
}

.switch input:checked + .track {
  background: var(--primary);
}

.switch input:checked + .track::before {
  transform: translateX(0.875rem);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.switch input:disabled {
  cursor: not-allowed;
}

.switch input:disabled + .track {
  opacity: 0.5;
}

/* ---- login page ---- */

.login-wrap {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 24rem;
}

.alert {
  margin-top: 1.5rem;
  border: 1px solid color-mix(in oklch, var(--destructive) 35%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in oklch, var(--destructive) 7%, var(--card));
  color: var(--destructive);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  width: 100%;
  margin-top: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  padding: 0.625rem 1rem;
  font: 500 0.875rem var(--font-sans);
  text-decoration: none;
  transition: background-color 0.15s;
}

.btn-google:hover {
  background: var(--muted);
}

.btn-google svg {
  width: 1.125rem;
  height: 1.125rem;
}

.login-foot {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* ---- toast ---- */

#toasts {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10;
}

.toast {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  box-shadow: 0 4px 12px oklch(0.22 0.008 60 / 0.08);
  animation: toast-in 0.15s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 640px) {
  .stats {
    display: none;
  }

  .row {
    grid-template-columns: 1fr 7rem 4.5rem 4.5rem;
    gap: 0.5rem;
    padding: 0.875rem 0.75rem;
  }
}
