/* shadcn-inspired design system — standalone, no framework needed */

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 71% 45.3%;
  --success-foreground: 144 80% 10%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: hsl(var(--foreground));
  letter-spacing: -0.025em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
  margin-bottom: 1rem;
  line-height: 1.6;
}

a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 0.15s;
}

a:hover {
  color: hsl(var(--muted-foreground));
}

ul, ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

hr {
  border: none;
  border-top: 1px solid hsl(var(--border));
  margin: 1.5rem 0;
}

/* ── Layout ────────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

main.container {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .grid {
    grid-auto-flow: row;
    grid-auto-columns: auto;
  }
}

/* ── Navigation ────────────────────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0.5rem 0;
}

nav.container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
  margin: 0;
}

nav ul li a {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  color: hsl(var(--muted-foreground));
  transition: background 0.15s, color 0.15s;
}

nav ul li a:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.nav-brand {
  text-decoration: none !important;
  color: hsl(var(--foreground)) !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.025em;
  padding: 0.4rem 0.75rem;
}

.nav-brand:hover {
  color: hsl(var(--foreground)) !important;
  background: transparent !important;
}

/* ── Buttons ───────────────────────────────────────────────────── */
button,
[type="submit"],
[type="button"],
a[role="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  white-space: nowrap;
}

button:hover,
[type="submit"]:hover,
[type="button"]:hover,
a[role="button"]:hover {
  opacity: 0.9;
}

button:focus-visible,
[type="submit"]:focus-visible,
[type="button"]:focus-visible,
a[role="button"]:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

button:disabled,
[type="submit"]:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Outline variant */
.outline,
button.outline,
a[role="button"].outline {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input));
}

.outline:hover,
button.outline:hover,
a[role="button"].outline:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  opacity: 1;
}

/* Secondary variant */
.secondary,
button.secondary,
a[role="button"].secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: transparent;
}

.secondary:hover,
button.secondary:hover,
a[role="button"].secondary:hover {
  background: hsl(var(--secondary) / 0.8);
  opacity: 1;
}

/* Outline + secondary combo (used for cancel buttons) */
.outline.secondary,
a[role="button"].outline.secondary {
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--input));
}

.outline.secondary:hover,
a[role="button"].outline.secondary:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* Destructive */
.btn-destructive {
  background: transparent !important;
  color: hsl(var(--destructive)) !important;
  border: 1px solid hsl(var(--destructive)) !important;
}

.btn-destructive:hover {
  background: hsl(var(--destructive)) !important;
  color: hsl(var(--destructive-foreground)) !important;
  opacity: 1 !important;
}

/* ── Forms ─────────────────────────────────────────────────────── */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="search"],
input[type="tel"],
select,
textarea {
  display: block;
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  padding: 0.5rem 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
  color: hsl(var(--foreground));
}

label > input,
label > select,
label > textarea {
  margin-top: 0.375rem;
}

textarea {
  resize: vertical;
  min-height: 4rem;
}

select {
  appearance: auto;
}

/* Fieldset / legend (form sections) */
fieldset,
.form-section {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 0.25rem;
  margin-bottom: 1.25rem;
}

.form-section legend,
fieldset legend {
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0 0.5rem;
  color: hsl(var(--foreground));
}

/* ── Cards (articles) ──────────────────────────────────────────── */
article {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

article p:last-child {
  margin-bottom: 0;
}

/* ── Tables ────────────────────────────────────────────────────── */
figure {
  overflow-x: auto;
  margin: 0 0 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0.625rem 0.75rem;
}

tbody td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: hsl(var(--muted) / 0.5);
}

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-success {
  background: hsl(var(--success) / 0.1);
  color: hsl(var(--success-foreground));
  border: 1px solid hsl(var(--success) / 0.3);
}

.alert-error {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.3);
}

.alert ul {
  margin: 0;
  padding-left: 1.25rem;
}

/* ── hgroup ────────────────────────────────────────────────────── */
hgroup {
  margin-bottom: 1.5rem;
}

hgroup h1,
hgroup h2,
hgroup h3 {
  margin-bottom: 0.25rem;
}

hgroup p {
  margin-bottom: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

/* ── Details / Summary ─────────────────────────────────────────── */
details {
  margin-bottom: 1rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.5rem 0;
  color: hsl(var(--foreground));
}

summary:hover {
  color: hsl(var(--muted-foreground));
}

/* ── Audit log ─────────────────────────────────────────────────── */
.audit-log {
  margin-top: 2rem;
}

.audit-log summary {
  font-weight: 600;
  cursor: pointer;
}

.audit-entry {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.audit-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.audit-header time {
  margin-left: auto;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
}

.audit-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: calc(var(--radius) * 10);
}

.audit-badge-created {
  background: hsl(var(--success) / 0.15);
  color: hsl(142 71% 35%);
}

.audit-badge-updated {
  background: hsl(217 91% 60% / 0.15);
  color: hsl(217 91% 50%);
}

.audit-badge-deleted {
  background: hsl(var(--destructive) / 0.15);
  color: hsl(var(--destructive));
}

.audit-changes {
  font-size: 0.8125rem;
  margin-bottom: 0;
}

.audit-changes th,
.audit-changes td {
  padding: 0.35rem 0.65rem;
}

/* ── Utility ───────────────────────────────────────────────────── */
.text-destructive {
  color: hsl(var(--destructive));
}
