@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=Outfit:wght@400;500;600;700&display=swap');

/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  color-scheme: light dark;
  --color-bg: #f8f7f4;
  --color-bg-gradient: radial-gradient(ellipse at 30% 0%, rgba(167,139,250,0.06) 0%, transparent 50%), radial-gradient(ellipse at 70% 100%, rgba(99,102,241,0.04) 0%, transparent 50%);
  --color-surface: #ffffff;
  --color-text: #2d2a3e;
  --color-text-muted: #8b8599;
  --color-primary: #4338ca;
  --color-primary-hover: #3730a3;
  --color-primary-subtle: rgba(67,56,202,0.08);
  --color-primary-glow: rgba(67,56,202,0.15);
  --color-border: #e8e6e1;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-success: #059669;
  --color-success-bg: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-surface-alt: #f1efe9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 24px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.03);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'DM Sans', system-ui, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --color-bg: #0c0b10;
  --color-bg-gradient: radial-gradient(ellipse at 30% 0%, rgba(167,139,250,0.05) 0%, transparent 50%), radial-gradient(ellipse at 80% 100%, rgba(99,102,241,0.03) 0%, transparent 50%);
  --color-surface: #17161e;
  --color-text: #ebe9f1;
  --color-text-muted: #9590a6;
  --color-primary: #a78bfa;
  --color-primary-hover: #8b5cf6;
  --color-primary-subtle: rgba(167,139,250,0.1);
  --color-primary-glow: rgba(167,139,250,0.2);
  --color-border: #2a2835;
  --color-error: #f87171;
  --color-error-bg: rgba(239,68,68,0.1);
  --color-success: #34d399;
  --color-success-bg: rgba(16,185,129,0.08);
  --color-warning: #fbbf24;
  --color-warning-bg: rgba(251,191,36,0.08);
  --color-surface-alt: #1e1d26;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 4px 24px rgba(0,0,0,0.2), 0 1px 3px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  background-image: var(--color-bg-gradient);
  background-attachment: fixed;
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Animations === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* === Layout === */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.container {
  width: 100%;
  max-width: 420px;
  animation: fadeInUp 0.4s var(--transition) both;
}

.container-wide { max-width: 480px; }

/* === Card === */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  border: 1px solid var(--color-border);
  position: relative;
}

/* === Logo === */
.logo-area { text-align: center; margin-bottom: 28px; }

.logo-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px var(--color-primary-glow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.logo-icon:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px var(--color-primary-glow);
}

.logo-icon svg {
  width: 26px; height: 26px;
  fill: none; stroke: #fff; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}

.client-logo {
  width: 52px; height: 52px; border-radius: 12px;
  display: block; margin: 0 auto 8px;
  box-shadow: var(--shadow-sm);
}

/* === Typography === */
h1 {
  font-family: var(--font-heading);
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subtitle {
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 28px;
}

.powered-by {
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.help {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 8px;
  line-height: 1.5;
}

/* === Forms === */
.field { margin-bottom: 20px; }

label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--color-text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
  height: auto;
  padding: 10px 14px;
  min-height: 44px;
  resize: vertical;
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 0.6;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle), inset 0 1px 2px rgba(0,0,0,0.02);
}

input[readonly] {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  cursor: default;
}

.field-error {
  color: var(--color-error);
  font-size: 0.8125rem;
  margin-top: 4px;
  font-weight: 500;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  color: #fff;
  box-shadow: 0 2px 8px var(--color-primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--color-primary-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-sm {
  height: 34px;
  padding: 0 14px;
  font-size: 0.8125rem;
  border-radius: var(--radius-xs);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,68,68,0.2);
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5,150,105,0.2);
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5,150,105,0.3);
}

.btn-ghost {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  background: var(--color-border);
  border-color: var(--color-text-muted);
}

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

.forgot { text-align: right; margin-bottom: 24px; }
.forgot a { font-size: 0.8125rem; font-weight: 500; }

/* === Divider === */
.divider {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  margin: 24px 0;
  position: relative;
}
.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: var(--color-border);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

/* === Alerts === */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  animation: fadeIn 0.3s ease both;
}
.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: rgba(220,38,38,0.15);
}
.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: rgba(5,150,105,0.15);
}
.alert-info {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  border-color: var(--color-primary-subtle);
}

/* === Theme Toggle === */
.theme-toggle { text-align: center; margin-top: 28px; }

.toggle-btn {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  padding: 8px 18px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}

.toggle-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-subtle);
}

/* === Alt Link === */
.alt-link {
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 20px;
}
.alt-link a { font-weight: 500; }

/* === Status Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-active { background: var(--color-success-bg); color: var(--color-success); }
.badge-pending { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-locked { background: var(--color-error-bg); color: var(--color-error); }

/* === Error Page === */
.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.error-page .card {
  max-width: 520px;
  width: 100%;
  animation: fadeInUp 0.4s var(--transition) both;
}
.error-page h1 {
  font-family: var(--font-heading);
  text-align: left;
  font-size: 1.3rem;
  margin-bottom: 12px;
}
.error-page code {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  background: var(--color-surface-alt);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.8125rem;
  border: 1px solid var(--color-border);
}
.error-page .row { display: flex; align-items: baseline; gap: 8px; margin-top: 12px; }
.error-page .actions { display: flex; gap: 8px; margin-top: 20px; }

/* === Consent Page === */
.scopes { margin: 16px 0; padding: 0; list-style: none; }
.scopes li {
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
  transition: background var(--transition);
}
.scopes li:hover { background: var(--color-primary-subtle); }
.scopes li label { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 0; }

.consent-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.consent-actions .btn { flex: 1; }

/* === Color Swatch === */
.color-swatch {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: 2px solid var(--color-border);
  vertical-align: middle;
  margin-left: 8px;
  transition: border-color var(--transition);
}
.color-swatch:hover { border-color: var(--color-text-muted); }

/* === Muted text (used in admin too) === */
.muted { color: var(--color-text-muted); font-size: 0.8125rem; }

/* === Checkbox styling === */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}
