/* ==========================================================================
   BaseAuth Design System — baseauth-auth.css
   Custom CSS for server-rendered auth pages (login, consent, profile, etc.)
   No framework dependencies. shadcn/ui aesthetic via CSS custom properties.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   2. Design Tokens — Light Mode
   -------------------------------------------------------------------------- */

:root {
  /* Surface */
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;

  /* Brand */
  --primary: 221 83% 53%;
  --primary-foreground: 0 0% 100%;
  --accent: 263 70% 50%;
  --accent-foreground: 0 0% 100%;

  /* Neutral */
  --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%;

  /* Semantic */
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 100%;
  --success: 142 71% 45%;
  --success-foreground: 0 0% 100%;

  /* Borders & Focus */
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 221 83% 53%;

  /* Sizing */
  --radius: 0.75rem;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono',
    Menlo, Consolas, 'Liberation Mono', monospace;

  /* Brand gradient */
  --gradient: linear-gradient(135deg, hsl(221 83% 53%), hsl(263 70% 50%));

  color-scheme: light dark;
}

/* --------------------------------------------------------------------------
   3. Design Tokens — Dark Mode
   -------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 3.9%;
    --card-foreground: 0 0% 98%;
    --popover: 240 10% 3.9%;
    --popover-foreground: 0 0% 98%;

    --primary: 221 83% 53%;
    --primary-foreground: 0 0% 100%;
    --accent: 263 70% 50%;
    --accent-foreground: 0 0% 100%;

    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;

    --destructive: 0 62% 55%;
    --destructive-foreground: 0 0% 98%;
    --success: 142 71% 45%;
    --success-foreground: 0 0% 98%;

    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 221 83% 53%;
  }
}

[data-theme="dark"] {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 240 10% 3.9%;
  --popover-foreground: 0 0% 98%;

  --primary: 221 83% 53%;
  --primary-foreground: 0 0% 100%;
  --accent: 263 70% 50%;
  --accent-foreground: 0 0% 100%;

  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;

  --destructive: 0 62% 55%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 71% 45%;
  --success-foreground: 0 0% 98%;

  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 221 83% 53%;
}

/* --------------------------------------------------------------------------
   4. Base
   -------------------------------------------------------------------------- */

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

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

/* --------------------------------------------------------------------------
   5. Typography
   -------------------------------------------------------------------------- */

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: hsl(var(--foreground));
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

h3 {
  font-size: 1.1rem;
  margin-bottom: 0.375rem;
}

p {
  color: hsl(var(--muted-foreground));
  margin-bottom: 1rem;
}

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

a {
  color: hsl(var(--primary));
  text-decoration: none;
  transition: color 150ms ease;
}

a:hover {
  color: hsl(var(--accent));
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
  border-radius: 2px;
}

strong, b {
  font-weight: 600;
  color: hsl(var(--foreground));
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  padding: 0.125rem 0.375rem;
  border-radius: calc(var(--radius) * 0.5);
}

small {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

/* --------------------------------------------------------------------------
   6. Auth Page Layout
   -------------------------------------------------------------------------- */

.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background-color: hsl(var(--background));
  background-image:
    radial-gradient(ellipse at 20% 50%, hsl(221 83% 53% / 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, hsl(263 70% 50% / 0.06) 0%, transparent 50%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --------------------------------------------------------------------------
   7. Card
   -------------------------------------------------------------------------- */

/* Auth card — glassmorphism-inspired variant for login/consent */
.auth-card {
  background: hsl(var(--card) / 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow:
    0 1px 3px hsl(var(--foreground) / 0.04),
    0 4px 16px hsl(var(--foreground) / 0.06);
  animation: card-fade-in 0.3s ease-out;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@keyframes card-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Regular card — for profile, settings, etc. */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px hsl(var(--foreground) / 0.04);
}

.card-header {
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid hsl(var(--border));
}

.card-header h1,
.card-header h2,
.card-header h3 {
  margin-bottom: 0.25rem;
}

.card-header p {
  margin-bottom: 0;
}

.card-footer {
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   8. Logo
   -------------------------------------------------------------------------- */

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.logo a {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
}

.logo a:hover {
  text-decoration: none;
  opacity: 0.85;
}

/* --------------------------------------------------------------------------
   9. Buttons
   -------------------------------------------------------------------------- */

button,
[type="submit"],
[type="button"],
[type="reset"],
[role="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  height: 2.5rem;
  padding: 0 1rem;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease,
    color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
  text-decoration: none;
  user-select: none;

  /* Default: primary style */
  background: var(--gradient);
  color: hsl(var(--primary-foreground));
}

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

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

button:active,
[type="submit"]:active,
[role="button"]:active {
  opacity: 0.85;
}

/* Primary — explicit class for clarity */
.btn-primary {
  background: var(--gradient);
  color: hsl(var(--primary-foreground));
  border-color: transparent;
}

/* Secondary */
.btn-secondary,
.secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}

.btn-secondary:hover,
.secondary:hover {
  background: hsl(var(--muted));
  opacity: 1;
}

/* Outline */
.btn-outline,
.outline {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}

.btn-outline:hover,
.outline:hover {
  background: hsl(var(--secondary));
  opacity: 1;
}

/* Destructive */
.btn-destructive,
.destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-color: transparent;
}

.btn-destructive:hover,
.destructive:hover {
  background: hsl(var(--destructive) / 0.9);
  opacity: 1;
}

/* Social / third-party provider buttons */
.btn-social {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
  font-weight: 500;
}

.btn-social:hover {
  background: hsl(var(--muted));
  border-color: hsl(var(--muted-foreground) / 0.25);
  opacity: 1;
}

.btn-social img,
.btn-social svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

/* Button group — horizontal row of buttons */
.btn-group {
  display: flex;
  gap: 0.75rem;
}

.btn-group > button,
.btn-group > [role="button"],
.btn-group > a {
  flex: 1;
}

/* Disabled state */
button:disabled,
[role="button"][aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   10. Form Inputs
   -------------------------------------------------------------------------- */

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

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
textarea,
select {
  display: block;
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background: transparent;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  transition: border-color 150ms ease, box-shadow 150ms ease;
  outline: none;
}

textarea {
  height: auto;
  min-height: 5rem;
  padding: 0.5rem 0.75rem;
  resize: vertical;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.22 4.47a.75.75 0 0 1 1.06 0L6 7.19l2.72-2.72a.75.75 0 0 1 1.06 1.06L6.53 8.78a.75.75 0 0 1-1.06 0L2.22 5.53a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

input::placeholder,
textarea::placeholder {
  color: hsl(var(--muted-foreground));
  opacity: 0.7;
}

input:focus,
textarea:focus,
select:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
}

/* Form layout */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-description {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

/* --------------------------------------------------------------------------
   11. Divider
   -------------------------------------------------------------------------- */

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.5rem 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  text-transform: lowercase;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: hsl(var(--border));
}

/* --------------------------------------------------------------------------
   12. Alert
   -------------------------------------------------------------------------- */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.5;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.alert-error,
[role="alert"] {
  background: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive) / 0.3);
  color: hsl(var(--destructive));
}

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

/* --------------------------------------------------------------------------
   13. Badge / Mark
   -------------------------------------------------------------------------- */

mark,
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   14. Table
   -------------------------------------------------------------------------- */

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

thead {
  border-bottom: 1px solid hsl(var(--border));
}

th {
  text-align: left;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  padding: 0.625rem 0.75rem;
}

td {
  padding: 0.625rem 0.75rem;
  color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border) / 0.5);
}

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

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

/* --------------------------------------------------------------------------
   15. Page Container
   -------------------------------------------------------------------------- */

.page-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* --------------------------------------------------------------------------
   16. Navigation
   -------------------------------------------------------------------------- */

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: color 150ms ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: hsl(var(--foreground));
}

.nav-links a[aria-current="page"] {
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   17. Avatar
   -------------------------------------------------------------------------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid hsl(var(--border));
  overflow: hidden;
  background: hsl(var(--muted));
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 1.75rem;
  height: 1.75rem;
}

/* --------------------------------------------------------------------------
   18. Auth Footer
   -------------------------------------------------------------------------- */

.auth-footer {
  text-align: center;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.auth-footer a {
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  text-decoration: none;
}

.auth-footer a:hover {
  color: hsl(var(--foreground));
}

/* --------------------------------------------------------------------------
   19. Consent Specific
   -------------------------------------------------------------------------- */

.consent-card {
  max-width: 480px;
}

.consent-card .btn-group {
  margin-top: 1rem;
}

/* --------------------------------------------------------------------------
   20. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .auth-card {
    padding: 1.5rem;
  }

  h1 {
    font-size: 1.25rem;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group > button,
  .btn-group > [role="button"],
  .btn-group > a {
    flex: unset;
    width: 100%;
  }

  .page-container {
    padding: 1rem;
  }

  .nav-bar {
    flex-direction: column;
    gap: 0.75rem;
  }

  .nav-links {
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   21. Utilities
   -------------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.text-sm { font-size: 0.8125rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.hidden { display: none; }
