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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f9fafb;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 420px;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  animation: slideIn 0.3s ease;
}

.toast.hidden {
  display: none;
}

.toast.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.toast.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast.success .toast-icon {
  color: #22c55e;
}

.toast.error .toast-icon {
  color: #ef4444;
}

.toast-message {
  font-size: 14px;
  font-weight: 500;
}

.toast.success .toast-message {
  color: #166534;
}

.toast.error .toast-message {
  color: #991b1b;
}

/* Help Text */
.help-text {
  margin-bottom: 16px;
}

.help-label {
  display: block;
  font-size: 14px;
  color: #3b4fe6;
}

/* Back Button */
.back-btn {
  display: block;
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 500;
  color: white;
  background: #6b7280;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.2s;
}

.back-btn:hover {
  background: #4b5563;
}

.back-btn.hidden {
  display: none;
}

/* Loading State */
#btn-loading {
  display: none;
}

.submit-btn.loading #btn-text {
  display: none;
}

.submit-btn.loading #btn-loading {
  display: inline;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  body {
    background: #111827;
  }

  .help-label {
    color: #818cf8;
  }

  .bypass-btn {
    background: #374151;
  }

  .bypass-btn:hover {
    background: #4b5563;
  }

  .bypass-dropdown {
    background: #1f2937;
    border-color: #374151;
  }

  .demo-user {
    color: #d1d5db;
  }

  .demo-user:hover {
    background: #374151;
  }

  .otp-input {
    background: #374151;
    border-color: #4f46e5;
    color: #f9fafb;
  }

  .otp-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  }

  .back-btn {
    background: #4b5563;
  }

  .back-btn:hover {
    background: #6b7280;
  }

  .resend-btn:not(:disabled) {
    background: #4f46e5;
  }

  .resend-btn:not(:disabled):hover {
    background: #4338ca;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* OAuth Buttons */
/* Generic hide helper — applied via JS to swap between the sign-in button
   and the auth-loading state. */
.hidden {
  display: none !important;
}

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 12px;
}

.oauth-btn:hover {
  border-color: #d1d5db;
  background: #f9fafb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

.oauth-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Shown only during the OAuth callback while Supabase exchanges the code
   and we redirect. Replaces the sign-in button so the user doesn't think
   the click didn't register. Animated step list staggers in sequence on
   mount to give a sense of progress through real auth phases. */
.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 16px;
  animation: auth-fade-in 0.4s ease-out;
}

.auth-loading.hidden {
  display: none;
}

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

.auth-orb {
  position: relative;
  width: 56px;
  height: 56px;
}

.auth-orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #4285f4;
  border-right-color: #a855f7;
  animation: auth-orb-spin 1.2s linear infinite;
}

.auth-orb-core {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #a855f7);
  animation: auth-orb-pulse 1.8s ease-in-out infinite;
}

@keyframes auth-orb-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes auth-orb-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(0.85);
    opacity: 1;
  }
}

.auth-loading-title {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, #4285f4, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

.auth-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #6b7280;
  opacity: 0;
  transform: translateX(-6px);
  animation: auth-step-in 0.4s ease-out forwards;
}

.auth-step[data-step='1'] {
  animation-delay: 0.05s;
}

.auth-step[data-step='2'] {
  animation-delay: 0.45s;
}

.auth-step[data-step='3'] {
  animation-delay: 0.9s;
}

@keyframes auth-step-in {
  to {
    opacity: 1;
    transform: translateX(0);
    color: #111827;
  }
}

.auth-step-bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #a855f7);
  box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.6);
  animation: auth-bullet-glow 1.6s ease-in-out infinite;
}

.auth-step[data-step='1'] .auth-step-bullet {
  animation-delay: 0s;
}

.auth-step[data-step='2'] .auth-step-bullet {
  animation-delay: 0.5s;
}

.auth-step[data-step='3'] .auth-step-bullet {
  animation-delay: 1s;
}

@keyframes auth-bullet-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(168, 85, 247, 0);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(168, 85, 247, 0);
    transform: scale(1.15);
  }
}

.auth-progress {
  width: 100%;
  max-width: 280px;
  height: 3px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.auth-progress-fill {
  height: 100%;
  width: 30%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4285f4, #a855f7);
  animation: auth-progress-slide 1.8s ease-in-out infinite;
}

@keyframes auth-progress-slide {
  0% {
    margin-left: -30%;
  }
  100% {
    margin-left: 100%;
  }
}

@media (prefers-color-scheme: dark) {
  .auth-step {
    color: #6b7280;
  }
  @keyframes auth-step-in {
    to {
      opacity: 1;
      transform: translateX(0);
      color: #e5e7eb;
    }
  }
  .auth-progress {
    background: #374151;
  }
}

.oauth-icon {
  flex-shrink: 0;
}

/* Google Button Specific */
.google-btn:hover {
  border-color: #fbbc05;
  background: #fef8e7;
}

.google-btn:active {
  background: #fef3c7;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  body {
    background: #111827;
  }

  .login-title {
    background: #1f2937;
  }

  .oauth-btn {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }

  .oauth-btn:hover {
    border-color: #6b7280;
    background: #4b5563;
  }

  .google-btn:hover {
    border-color: #f59e0b;
    background: #451a03;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Non-admin modal — appears in place of the silent redirect when a signed-in
   user fails the is_admin check. Echoes the auth-loading state (same gradient
   accents, 12px radius, fade-in) so it feels of-a-piece. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1100;
  animation: modal-fade-in 0.18s ease-out;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 12px;
  padding: 28px 24px 20px;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: modal-pop-in 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: white;
  background: linear-gradient(135deg, #4285f4, #a855f7);
  box-shadow: 0 10px 25px -8px rgba(168, 85, 247, 0.5);
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}

.modal-body {
  font-size: 14px;
  line-height: 1.5;
  color: #4b5563;
  margin-bottom: 20px;
}

.modal-host {
  font-weight: 600;
  color: #4f46e5;
  word-break: break-all;
}

.modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.modal-btn {
  flex: 1;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.modal-btn:active {
  transform: translateY(1px);
}

.modal-btn-primary {
  color: white;
  background: linear-gradient(135deg, #4285f4, #a855f7);
}

.modal-btn-primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 14px -4px rgba(168, 85, 247, 0.5);
}

.modal-btn-secondary {
  color: #374151;
  background: white;
  border-color: #e5e7eb;
}

.modal-btn-secondary:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-pop-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@media (prefers-color-scheme: dark) {
  .modal-card {
    background: #1f2937;
    box-shadow:
      0 25px 50px -12px rgba(0, 0, 0, 0.6),
      0 0 0 1px rgba(255, 255, 255, 0.06);
  }

  .modal-title {
    color: #f9fafb;
  }

  .modal-body {
    color: #d1d5db;
  }

  .modal-host {
    color: #a5b4fc;
  }

  .modal-btn-secondary {
    background: #374151;
    color: #f9fafb;
    border-color: #4b5563;
  }

  .modal-btn-secondary:hover {
    background: #4b5563;
    border-color: #6b7280;
  }
}
