/* Backoffice login — design tokens mirror design-system/DESIGN_GUIDE.md §2.
   Self-contained because backoffice runs standalone (no css/styles.css). */

:root {
  --bg-app: #FAFAFA;
  --bg-surface: #FFFFFF;
  --bg-muted: #F2F2F3;
  --bg-hover: rgba(66, 133, 244, .08);
  --text-primary: #202124;
  --text-secondary: #5F6368;
  --text-tertiary: #9AA0A6;
  --border: #DADCE0;
  --accent-blue: #4285F4;
  --accent-purple: #7C4DFF;
  --success: #34A853;
  --warning: #FBBC05;
  --danger: #EA4335;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-sm: .75rem;
  --font-base: .875rem;
  --font-md: 1rem;
  --font-lg: 1.125rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .12);
  --shadow-focus: 0 0 0 4px rgba(66, 133, 244, .15);

  --transition-fast: 200ms cubic-bezier(.2, 0, 0, 1);
}

[data-theme="dark"] {
  --bg-app: #1A1A2E;
  --bg-surface: #1E1E32;
  --bg-muted: #2A2A42;
  --bg-hover: rgba(138, 180, 248, .1);
  --text-primary: #E8E8ED;
  --text-secondary: #A0A0B8;
  --text-tertiary: #6C6C88;
  --border: #3C3C58;
  --accent-blue: #8AB4F8;
  --accent-purple: #B388FF;
  --success: #81C995;
  --warning: #FDD633;
  --danger: #F28B82;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
  --shadow-focus: 0 0 0 4px rgba(138, 180, 248, .2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--text-primary);
  background: var(--bg-app);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  -webkit-font-smoothing: antialiased;
}

/* Focus: 2px ring, independent of hover. */
:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
  box-shadow: var(--shadow-focus);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Theme toggle ─────────────────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: var(--space-4);
  inset-inline-start: var(--space-4);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: var(--font-md);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.theme-toggle:hover {
  background: var(--bg-hover);
}

/* ── Login card ───────────────────────────────────────────── */
.login-card {
  width: 100%;
  max-width: 384px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-8) var(--space-6) var(--space-6);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.login-brand h1 {
  margin: 0;
  font-size: var(--font-lg);
  font-weight: 600;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: #fff;
  font-size: var(--font-md);
  font-weight: 700;
}

.login-subtitle {
  margin: 0 0 var(--space-6);
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

/* ── Alert banner (server errors) ─────────────────────────── */
.form-alert {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease;
}
.form-alert[hidden] {
  display: none;
}
.form-alert--visible {
  opacity: 1;
  transform: none;
}
.form-alert--danger {
  background: rgba(234, 67, 53, .1);
  border: 1px solid rgba(234, 67, 53, .3);
  color: var(--danger);
}
[data-theme="dark"] .form-alert--danger {
  background: rgba(242, 139, 130, .12);
  border-color: rgba(242, 139, 130, .35);
}

/* ── Fields ───────────────────────────────────────────────── */
.field {
  margin-bottom: var(--space-4);
}
.field label {
  display: block;
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}
.field input {
  width: 100%;
  padding: var(--space-3);
  font-size: var(--font-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 150ms ease;
}
.field input:hover {
  border-color: var(--text-tertiary);
}
.field input.field-invalid {
  border-color: var(--danger);
}
.field-error {
  display: block;
  min-height: 1.2em;
  margin-top: var(--space-1);
  font-size: var(--font-sm);
  color: var(--danger);
  opacity: 0;
  transition: opacity 150ms ease;
}
.field-error:not(:empty) {
  opacity: 1;
}

/* ── Buttons & spinner ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-base);
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}
.btn--primary {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
}
.btn--primary:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn--ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Footer links ─────────────────────────────────────────── */
.form-footer {
  display: flex;
  justify-content: center;
  margin-top: var(--space-6);
}
.link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: var(--font-sm);
  color: var(--accent-blue);
  cursor: pointer;
  text-decoration: none;
}
.link:hover {
  text-decoration: underline;
}
.forgot-hint {
  margin: var(--space-3) 0 0;
  padding: var(--space-3);
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

/* ── Admin shell (placeholder after login) ────────────────── */
.admin-shell {
  width: 100%;
  max-width: 640px;
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.admin-header h1 {
  margin: 0;
  font-size: var(--font-xl, 1.375rem);
  font-weight: 600;
}
.admin-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}
.admin-card p {
  margin: 0 0 var(--space-3);
}
.admin-card p:last-child {
  margin-bottom: 0;
}
.admin-pending {
  color: var(--text-secondary);
  font-size: var(--font-sm);
}
