html {
  scroll-behavior: smooth;
}

:root {
  --brand-blue: 47 107 255;
  --brand-purple: 124 58 237;
  --brand-green: 34 197 94;
  --brand-gold: 234 179 8;
  --bg-dark: 18 18 18;
  --bg-panel: 28 28 28;
  --text-primary: 241 245 249;
  --text-secondary: 148 163 184;
  --text-muted: 100 116 139;
  --border-subtle: 255 255 255 / 0.08;
  --border-normal: 255 255 255 / 0.12;
  --shadow-premium: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
  --curve-out: cubic-bezier(0.2, 0, 0, 1);
}

body {
  position: relative;
  background-color: rgb(var(--bg-dark));
  color: rgb(var(--text-primary));
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(circle at 0% 0%, rgba(var(--brand-blue), 0.15), transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(var(--brand-purple), 0.1), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(var(--brand-blue), 0.05), transparent 50%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.03;
  background-image: radial-gradient(circle, #fff 1px, transparent 1px);
  background-size: 40px 40px;
}

:focus-visible {
  outline: 2px solid rgb(var(--brand-blue));
  outline-offset: 3px;
  border-radius: 6px;
}

.img-square {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

img[alt*="QR"] {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media print {
  nav, footer, .no-print {
    display: none !important;
  }
  body {
    background: white;
  }
  body::before,
  body::after {
    display: none;
  }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-up {
  animation: fadeUp 0.4s var(--curve-out) forwards;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
.animate-slide-in-right {
  animation: slideInRight 0.4s var(--curve-out) forwards;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.animate-shake {
  animation: shake 0.4s ease-in-out;
}

.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: "";
  position: absolute;
  width: 1.25rem;
  height: 1.25rem;
  top: 50%;
  left: 50%;
  margin: -0.625rem 0 0 -0.625rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.text-success { color: rgb(var(--brand-green)); }
.text-error { color: #ef4444; }
.error-field { border-color: #ef4444 !important; }
.error-message { font-size: 0.75rem; font-weight: 700; color: #ef4444; margin-top: 0.25rem; margin-left: 0.25rem; }

/* Premium UI Components */
.premium-panel {
  background-color: rgb(var(--bg-panel));
  border: 1px solid var(--border-subtle);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-premium);
}

.premium-card {
  background-color: rgb(var(--bg-panel));
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  transition: all 0.2s var(--curve-out);
}

.premium-card:hover {
  border-color: rgba(var(--brand-blue), 0.3);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.4);
}

.btn-primary {
  background-color: rgb(var(--brand-blue));
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  transition: all 0.2s var(--curve-out);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px rgba(var(--brand-blue), 0.4);
}

/* Page Animations */
.reveal {
  opacity: 0;
  animation: fadeUp 0.6s var(--curve-out) forwards;
}

.reveal-delay-1 { animation-delay: 0.1s; }
.reveal-delay-2 { animation-delay: 0.2s; }
.reveal-delay-3 { animation-delay: 0.3s; }

/* Legacy Overrides Fix */
.bg-white { background-color: rgb(var(--bg-panel)) !important; }
.bg-slate-50, .bg-slate-100 { background-color: rgb(var(--bg-dark)) !important; }
.text-slate-900 { color: rgb(var(--text-primary)) !important; }
.text-slate-700, .text-slate-600 { color: rgb(var(--text-secondary)) !important; }
.border-slate-200, .border-slate-100 { border-color: var(--border-subtle) !important; }

input, textarea, select {
  background-color: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 0.75rem !important;
  color: rgb(var(--text-primary)) !important;
  padding: 0.625rem 1rem !important;
  transition: border-color 0.2s var(--curve-out);
}

input:focus, textarea:focus {
  border-color: rgb(var(--brand-blue)) !important;
  box-shadow: 0 0 0 4px rgba(var(--brand-blue), 0.18);
  outline: none;
}

select:focus {
  border-color: rgb(var(--brand-blue)) !important;
  box-shadow: 0 0 0 4px rgba(var(--brand-blue), 0.18);
  outline: none;
}

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

select option {
  background-color: rgb(var(--bg-panel));
  color: rgb(var(--text-primary));
}

.surface-light {
  color-scheme: light;
}

.surface-light .bg-white {
  background-color: #ffffff !important;
}

.surface-light .bg-slate-50,
.surface-light .bg-slate-100 {
  background-color: #f8fafc !important;
}

.surface-light .text-slate-900 {
  color: #0f172a !important;
}

.surface-light .text-slate-700,
.surface-light .text-slate-600 {
  color: #475569 !important;
}

.surface-light .border-slate-200,
.surface-light .border-slate-100 {
  border-color: #e2e8f0 !important;
}

.surface-light input,
.surface-light textarea,
.surface-light select {
  background-color: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

.surface-light input:focus,
.surface-light textarea:focus,
.surface-light select:focus {
  background-color: #ffffff !important;
  border-color: rgb(var(--brand-blue)) !important;
  box-shadow: 0 0 0 4px rgba(var(--brand-blue), 0.1);
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  color: rgb(var(--text-muted));
  pointer-events: none;
  transition: color 0.2s var(--curve-out);
}

.auth-input-wrap:focus-within .auth-input-icon {
  color: rgb(var(--brand-blue));
}

.auth-input-wrap.auth-input-wrap-purple:focus-within .auth-input-icon {
  color: rgb(var(--brand-purple));
}

.auth-input {
  width: 100%;
  min-height: 3.625rem;
  padding-left: 3.5rem !important;
  padding-right: 1.25rem !important;
  line-height: 1.25rem;
}

.auth-input.auth-input-username {
  padding-left: 2.75rem !important;
}

.surface-light input::placeholder,
.surface-light textarea::placeholder {
  color: #94a3b8 !important;
}

.surface-light select option {
  background-color: #ffffff;
  color: #0f172a;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
