/* shadcn-inspired design tokens */
:root {
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.55 0 0);
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
}

/* Layout */
.app-container {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Navigation - shadcn header style */
nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

nav a {
  color: var(--foreground);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

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

nav span {
  color: var(--muted-foreground);
  font-size: 0.8125rem;
}

.nav-spacer {
  flex: 1;
}

nav .nav-logout-form {
  display: inline-flex;
  margin: 0;
}

nav .nav-logout-form input[type="submit"],
nav .btn {
  margin: 0;
}

/* Main content */
main {
  padding: 2rem 1.5rem;
}

/* Typography */
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
  font-family: inherit;
}

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

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

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

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

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

.btn-danger, input[type="submit"][data-method="delete"] {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn-danger:hover {
  opacity: 0.9;
}

/* Form elements - Bootstrap-compatible for Doorkeeper */
.form-group {
  margin-bottom: 1rem;
}

.form-group.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

.form-group.row > label {
  flex: 0 0 auto;
  min-width: 8rem;
  padding-top: 0.5rem;
}

.form-group.row > div {
  flex: 1 1 0;
  min-width: 0;
}

.form-control, input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  font-family: inherit;
}

.form-control:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px oklch(0.55 0 0 / 20%);
}

.form-control.is-invalid, input.is-invalid {
  border-color: var(--destructive);
}

.form-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.form-check-label, .form-group.row label {
  font-weight: 500;
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  margin-right: 0.5rem;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-narrow {
  max-width: 24rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 500;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
}

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

code {
  padding: 0.125rem 0.375rem;
  font-size: 0.8125rem;
  background: var(--muted);
  border-radius: var(--radius);
  font-family: ui-monospace, monospace;
}

/* Links */
a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Flash messages */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-info, [style*="color: green"], .notice {
  background: oklch(0.97 0.02 145);
  color: oklch(0.25 0.05 145);
  border: 1px solid oklch(0.85 0.03 145);
}

.alert-danger, [style*="color: red"], .alert {
  background: oklch(0.98 0.02 25);
  color: oklch(0.45 0.15 25);
  border: 1px solid oklch(0.9 0.05 25);
}

/* Doorkeeper-specific: navbar (override Bootstrap dark navbar) */
.navbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--card) !important;
}

.navbar-brand {
  font-weight: 600;
  color: var(--foreground) !important;
  text-decoration: none;
}

.navbar-nav {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  color: var(--muted-foreground) !important;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
}

.nav-link:hover, .nav-item.active .nav-link {
  color: var(--foreground) !important;
  background: var(--muted);
}

/* Doorkeeper container */
.doorkeeper-admin.container {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Font weight utilities (used by Doorkeeper) */
.font-weight-bold {
  font-weight: 600;
}

/* Col grid (Bootstrap compat) */
.col-sm-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-sm-10 { flex: 1 0 83.333333%; max-width: 83.333333%; }
.col-sm-offset-2 { margin-left: 16.666667%; }

.col-sm-offset-2 .btn,
.col-sm-offset-2 .btn-primary,
.col-sm-offset-2 .btn-secondary {
  margin-right: 0.5rem;
}

.d-inline { display: inline; }

/* Extra utilities for Doorkeeper views */
.btn-success { background: oklch(0.55 0.15 155); color: white; }
.btn-success:hover { opacity: 0.9; }

.btn-link {
  background: transparent;
  color: var(--primary);
}

.btn-link:hover {
  background: transparent;
  text-decoration: underline;
}

.table-striped tbody tr:nth-child(odd) {
  background: var(--muted);
}

.table-striped tbody tr:hover {
  background: var(--accent);
}

.align-middle { vertical-align: middle; }

.bg-light { background: var(--muted); }

.font-italic { font-style: italic; }

.text-uppercase { text-transform: uppercase; }

.text-muted { color: var(--muted-foreground); }

.row { display: flex; flex-wrap: wrap; margin: 0 -0.75rem; }
.row > .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; padding: 0 0.75rem; }
.row > .col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; padding: 0 0.75rem; }

@media (max-width: 768px) {
  .row > .col-md-4, .row > .col-md-8 { flex: 0 0 100%; max-width: 100%; }
}

h3 { font-size: 1.125rem; font-weight: 600; margin: 0 0 0.75rem; }
h4 { font-size: 1rem; font-weight: 600; margin: 0 0 0.5rem; }

/* Show page */
.show-field {
  margin-bottom: 1.5rem;
}

.show-field:last-child {
  margin-bottom: 0;
}

.show-value {
  margin: 0.25rem 0 0.25rem 0;
}

.redirect-uri-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

@media (max-width: 576px) {
  .col-sm-2, .col-sm-10 { flex: 0 0 100%; max-width: 100%; }
  .form-group.row { flex-direction: column; }
  .form-group.row > label { min-width: 100%; }
}

/* Spacing */
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }
.mr-auto { margin-right: auto; }

/* Border utilities */
.border-bottom {
  border-bottom: 1px solid var(--border);
}

/* Field errors */
.field_with_errors .form-control,
.field_with_errors input {
  border-color: var(--destructive);
}

/* Hide collapse for simple nav - show inline */
.navbar-expand-lg .navbar-collapse {
  display: flex !important;
}

.text-secondary {
  color: var(--muted-foreground) !important;
}
