/* Login page styles extracted from templates/users/login.html
   Goal: professional, brand-forward, calmer background with accessible reduced-motion support. */

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: relative;
  overflow: hidden;
  color: #1a202c;
  /* Match homepage theme (indigo/purple) */
  background: #667eea;
}

/* =========================
   Background (calmed down)
   ========================= */

.animated-bg {
  position: fixed;
  inset: 0;
  z-index: 0;

  /* restrained palette, aligned to homepage */
  background:
    radial-gradient(1200px 800px at 20% 20%, rgba(102, 126, 234, 0.42), transparent 60%),
    radial-gradient(1000px 700px at 85% 70%, rgba(118, 75, 162, 0.34), transparent 55%),
    radial-gradient(900px 650px at 55% 25%, rgba(6, 182, 212, 0.12), transparent 55%),
    linear-gradient(135deg, #667eea 0%, #764ba2 55%, #667eea 100%);
  background-size: 100% 100%;
}

/* subtle texture + vignette */
.animated-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;

  /* ultra-light noise via layered gradients (no external asset) */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 3px 3px, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    radial-gradient(900px 600px at 50% 40%, rgba(255, 255, 255, 0.05), transparent 65%),
    radial-gradient(1100px 800px at 50% 110%, rgba(0, 0, 0, 0.45), transparent 55%);
  background-size: 24px 24px, 32px 32px, 100% 100%, 100% 100%;
  mix-blend-mode: overlay;
  opacity: 0.65;
}

/* optional gentle drift to keep it alive without being loud */
.animated-bg::after {
  content: "";
  position: absolute;
  inset: -10%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(800px 600px at 25% 25%, rgba(102, 126, 234, 0.18), transparent 60%),
    radial-gradient(700px 500px at 80% 75%, rgba(118, 75, 162, 0.16), transparent 55%);
  animation: bgDrift 28s ease-in-out infinite;
  filter: blur(10px);
  opacity: 0.9;
}

@keyframes bgDrift {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(-2%, 1.5%, 0) scale(1.03);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* Keep these classes defined (HTML previously rendered them); but we now hide them for a cleaner look */
.waves,
.particles,
.glow-orb {
  display: none;
}

.login-container {
  min-height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  overflow: hidden;
}

/* Full Screen Container for Documents and Login Form */
.illustration-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  transform-style: preserve-3d;
}

/* 3D Floating Document Icons */
.document-icon {
  position: absolute;
  width: 160px;
  height: 200px;
  transform-style: preserve-3d;
  pointer-events: none; /* Disable hover on container */
  opacity: 0;
}

/* Staggered appearance animation */
@keyframes documentAppear {
  from {
    opacity: 0;
    transform: scale(0.5) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.document-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), filter 0.35s ease;
  pointer-events: auto; /* Enable hover only on card */
  cursor: pointer;
  /* Keep clean: no outer glow/shadow */
  filter: none;
}

.document-icon:hover .document-card,
.document-card:hover {
  transform: scale(1.12) translateZ(18px);
}

.document-icon:hover {
  z-index: 10;
}

/* Document Type Labels on Hover */
.document-icon::after {
  content: attr(data-label);
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(0, 0, 0, 0.82);
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  letter-spacing: 0.4px;
}

/* Show label above document for Driving License (doc-3) and CRC Record (doc-6) */
.document-icon.doc-3::after,
.document-icon.doc-6::after {
  bottom: auto;
  top: -40px;
  transform: translateX(-50%) translateY(-10px);
}

.document-icon:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.document-front {
  position: absolute;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  border-radius: 8px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transform: translateZ(5px);
  overflow: hidden;
  backdrop-filter: blur(3px);
}

/* Make flying documents feel like background texture (subtle) */
.document-icon {
  opacity: 0;
}

.document-icon.doc-1,
.document-icon.doc-2,
.document-icon.doc-3,
.document-icon.doc-4,
.document-icon.doc-5,
.document-icon.doc-6 {
  /* will be animated to this opacity by documentAppear; keep it low */
}

.document-icon .document-card {
  opacity: 0.7;
  filter: saturate(0.92) contrast(0.95);
}

.document-icon .document-front {
  opacity: 0.85;
  filter: blur(0.3px);
}

.document-icon:hover .document-card,
.document-card:hover {
  transform: scale(1.06) translateZ(12px);
}

.document-side {
  position: absolute;
  width: 8px;
  height: 100%;
  background: transparent;
  right: -8px;
  transform-origin: left center;
  transform: rotateY(90deg);
  border-radius: 0 3px 3px 0;
}

.document-top {
  position: absolute;
  width: 100%;
  height: 8px;
  background: transparent;
  top: -8px;
  transform-origin: center bottom;
  transform: rotateX(90deg);
  border-radius: 3px 3px 0 0;
}

/* Document positions - 3 on left side, 3 on right side */
/* Login card is ~460px wide (230px radius) and ~600px tall (300px radius) */
/* Documents are 160px wide (80px radius) and 200px tall (100px radius) */
/* Safe distance: 450px horizontal from center to avoid overlap */

/* Left Side Documents */
.doc-1 {
  top: calc(50vh - 280px);
  left: calc(50vw - 450px);
  margin-left: -80px;
  animation: documentAppear 0.8s ease-out 0.2s forwards, document3DFloat 22s 2s infinite ease-in-out;
}

.doc-1 .document-card {
  animation: docRotate1 14s infinite ease-in-out;
}

.doc-2 {
  top: 50vh;
  left: calc(50vw - 450px);
  margin-left: -80px;
  margin-top: -100px;
  animation: documentAppear 0.8s ease-out 0.4s forwards, document3DFloat 22s 4s infinite ease-in-out;
}

.doc-2 .document-card {
  animation: docRotate2 16s infinite ease-in-out;
}

.doc-3 {
  top: calc(50vh + 280px);
  left: calc(50vw - 450px);
  margin-left: -80px;
  animation: documentAppear 0.8s ease-out 0.6s forwards, document3DFloat 22s 6s infinite ease-in-out;
}

.doc-3 .document-card {
  animation: docRotate3 18s infinite ease-in-out;
}

/* Right Side Documents */
.doc-4 {
  top: calc(50vh - 280px);
  left: calc(50vw + 450px);
  margin-left: -80px;
  animation: documentAppear 0.8s ease-out 0.8s forwards, document3DFloat 22s 8s infinite ease-in-out;
}

.doc-4 .document-card {
  animation: docRotate4 15s infinite ease-in-out;
}

.doc-5 {
  top: 50vh;
  left: calc(50vw + 450px);
  margin-left: -80px;
  margin-top: -100px;
  animation: documentAppear 0.8s ease-out 1s forwards, document3DFloat 22s 10s infinite ease-in-out;
}

.doc-5 .document-card {
  animation: docRotate5 17s infinite ease-in-out;
}

.doc-6 {
  top: calc(50vh + 280px);
  left: calc(50vw + 450px);
  margin-left: -80px;
  animation: documentAppear 0.8s ease-out 1.2s forwards, document3DFloat 22s 12s infinite ease-in-out;
}

.doc-6 .document-card {
  animation: docRotate6 16s infinite ease-in-out;
}

@keyframes document3DFloat {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotateY(0deg);
    opacity: 0.72;
  }
  25% {
    transform: translate3d(12px, -16px, 12px) rotateY(12deg);
    opacity: 0.92;
  }
  50% {
    transform: translate3d(-12px, 16px, -10px) rotateY(-16deg);
    opacity: 0.82;
  }
  75% {
    transform: translate3d(16px, 12px, 14px) rotateY(9deg);
    opacity: 0.88;
  }
}

@keyframes docRotate1 {
  0%,
  100% {
    transform: rotateY(0deg) rotateX(5deg) rotateZ(-5deg);
  }
  33% {
    transform: rotateY(20deg) rotateX(-5deg) rotateZ(7deg);
  }
  66% {
    transform: rotateY(-16deg) rotateX(8deg) rotateZ(-8deg);
  }
}

@keyframes docRotate2 {
  0%,
  100% {
    transform: rotateY(-10deg) rotateX(-8deg) rotateZ(5deg);
  }
  33% {
    transform: rotateY(12deg) rotateX(5deg) rotateZ(-7deg);
  }
  66% {
    transform: rotateY(-18deg) rotateX(-5deg) rotateZ(10deg);
  }
}

@keyframes docRotate3 {
  0%,
  100% {
    transform: rotateY(15deg) rotateX(10deg) rotateZ(-8deg);
  }
  33% {
    transform: rotateY(-12deg) rotateX(-5deg) rotateZ(9deg);
  }
  66% {
    transform: rotateY(16deg) rotateX(8deg) rotateZ(-5deg);
  }
}

@keyframes docRotate4 {
  0%,
  100% {
    transform: rotateY(-5deg) rotateX(-10deg) rotateZ(8deg);
  }
  33% {
    transform: rotateY(16deg) rotateX(5deg) rotateZ(-10deg);
  }
  66% {
    transform: rotateY(-12deg) rotateX(-8deg) rotateZ(5deg);
  }
}

@keyframes docRotate5 {
  0%,
  100% {
    transform: rotateY(5deg) rotateX(-8deg) rotateZ(-10deg);
  }
  33% {
    transform: rotateY(-14deg) rotateX(12deg) rotateZ(7deg);
  }
  66% {
    transform: rotateY(10deg) rotateX(-5deg) rotateZ(-12deg);
  }
}

@keyframes docRotate6 {
  0%,
  100% {
    transform: rotateY(-8deg) rotateX(10deg) rotateZ(8deg);
  }
  33% {
    transform: rotateY(12deg) rotateX(-5deg) rotateZ(-10deg);
  }
  66% {
    transform: rotateY(-10deg) rotateX(8deg) rotateZ(9deg);
  }
}

/* (Security rings removed) */

/* Login Card - Centered in the middle */
.login-card {
  background: #ffffff;
  border-radius: 28px;
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow:
    0 25px 80px rgba(0, 0, 0, 0.14),
    0 10px 30px rgba(79, 172, 254, 0.10),
    0 0 0 1px rgba(255, 255, 255, 0.55) inset;
  padding: 3.5rem 2.75rem;
  width: 100%;
  max-width: 460px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  overflow: hidden;
  transition: box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-card:hover {
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.18),
    0 15px 40px rgba(79, 172, 254, 0.16),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  transform: translate(-50%, -50%) translateY(-6px);
}

.login-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(79, 172, 254, 0.06) 50%,
    transparent 70%
  );
  animation: shimmer 10s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.login-card > * {
  position: relative;
  z-index: 1;
}

@keyframes shimmer {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  50% {
    transform: translate(-50%, -50%) rotate(180deg);
  }
}

@media (max-width: 992px) {
  .illustration-container {
    width: 100vw;
    height: 100vh;
  }

  .login-card {
    max-width: 90%;
    padding: 2rem;
  }

  /* Hide documents on mobile for better UX */
  .document-icon {
    display: none;
  }
}

.logo-content {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1.25rem;
}

.logo-section img {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  height: 70px;
  flex-shrink: 0;
}

.logo-text-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
}

.logo-section h2 {
  font-weight: 800;
  margin: 0;
  font-size: 42px;
  letter-spacing: -1px;
  line-height: 1.1;
  height: 50px;
  display: flex;
  align-items: center;
}

.logo-section .brand-name {
  color: #1a202c;
  font-weight: 800;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.logo-section .brand-extension {
  color: #667eea;
  font-weight: 800;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.brand-link {
  text-decoration: none;
  transition: all 0.3s ease;
  display: inline-block;
}

.brand-link:hover {
  opacity: 0.85;
}

.brand-link:hover .brand-name {
  color: #0f172a;
}

.brand-link:hover .brand-extension {
  color: #4facfe;
}

.logo-section .tagline {
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 1rem;
  text-align: center;
  width: 100%;
  letter-spacing: 0.4px;
}

.form-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: #1e293b;
  margin-bottom: 0.75rem;
  letter-spacing: 0.1px;
  display: block;
}

.form-control {
  border-radius: 14px;
  border: 2px solid #e2e8f0;
  padding: 16px 18px;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: #f8fafc;
  color: #1e293b;
  font-weight: 400;
  line-height: 1.5;
}

.form-control:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.12), 0 4px 12px rgba(102, 126, 234, 0.15);
  outline: none;
  background: #ffffff;
  transform: translateY(-2px);
}

.form-control:hover:not(:focus) {
  border-color: #cbd5e1;
  background: #ffffff;
}

.form-control::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.input-group-text {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-right: none;
  border-radius: 14px 0 0 14px;
  color: #64748b;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 16px 14px;
  font-size: 1.1rem;
}

.input-group:focus-within .input-group-text {
  border-color: #667eea;
  background: linear-gradient(135deg, #f1f5f9 0%, #e0e7ff 100%);
  color: #667eea;
}

.input-group .form-control {
  border-left: none;
  border-right: 2px solid #e2e8f0;
  border-radius: 0;
}

.input-group:focus-within .form-control {
  border-left: 2px solid #667eea;
  border-right: 2px solid #667eea;
}

.input-group:has(.btn-password-toggle) .form-control {
  border-right: none;
}

/* For input-groups without a trailing button (e.g., Login ID), restore the right radius */
.input-group:not(:has(.btn-password-toggle)) .form-control {
  border-radius: 0 14px 14px 0;
}

.input-group:hover:not(:focus-within) .input-group-text {
  border-color: #cbd5e1;
  background: #ffffff;
}

/* Password Toggle Button */
.btn-password-toggle {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-left: none;
  border-radius: 0 14px 14px 0;
  color: #64748b;
  padding: 16px 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  margin-left: 0;
}

.btn-password-toggle:hover {
  background: #f1f5f9;
  color: #667eea;
  border-color: #cbd5e1;
}

.btn-password-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.12);
}

.input-group:focus-within .btn-password-toggle {
  border-color: #667eea;
  background: #f1f5f9;
  color: #667eea;
}

.btn-password-toggle .material-icons {
  font-size: 20px;
}

.input-group:focus-within .btn-password-toggle {
  border-left: 2px solid #667eea;
}

.btn-primary {
  /* Match homepage CTA gradient */
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 14px;
  padding: 16px 28px;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.4px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35), 0 2px 6px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  color: #ffffff;
  text-transform: none;
}

.btn-primary::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transition: left 0.6s ease;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.45), 0 6px 12px rgba(0, 0, 0, 0.15);
  background: linear-gradient(135deg, #7c8df0 0%, #8b5cf6 100%);
}

.btn-primary:active {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35), 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn-primary i {
  transition: transform 0.3s ease;
}

.btn-primary:hover i {
  transform: translateX(3px);
}

.turnstile-container {
  margin: 2rem 0;
  padding: 1.25rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) inset;
  display: flex;
  justify-content: center;
  align-items: center;
}

.turnstile-container .cf-turnstile {
  width: 100%;
  display: flex;
  justify-content: center;
}

.error-message {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Enhanced Alert Messages */
.alert {
  border-radius: 12px;
  border: none;
  padding: 1rem 1.25rem;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.alert-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
  color: #065f46;
  border-left: 4px solid #10b981;
}

.alert-danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.1) 100%);
  color: #991b1b;
  border-left: 4px solid #ef4444;
}

.alert-warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(217, 119, 6, 0.1) 100%);
  color: #92400e;
  border-left: 4px solid #f59e0b;
}

.alert-info {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(37, 99, 235, 0.1) 100%);
  color: #1e40af;
  border-left: 4px solid #3b82f6;
}

/* Forgot Password Link */
.text-end a {
  color: #667eea;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.text-end a:hover {
  color: #4facfe;
  text-decoration: underline;
}

/* Support Link */
.text-muted {
  color: #64748b !important;
}

.text-muted a {
  color: #667eea;
  font-weight: 600;
  transition: all 0.2s ease;
  text-decoration: none;
}

.text-muted a:hover {
  color: #4facfe;
  text-decoration: underline;
}

/* Logo Section Spacing */
.logo-section {
  margin-bottom: 2.5rem;
  text-align: left;
}

/* Form Section Spacing */
.mb-3 {
  margin-bottom: 1.5rem !important;
}

/* Loading Spinner */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
}

.btn-loading .btn-text,
.btn-loading .btn-icon {
  opacity: 0;
}

.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.btn-loading .spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Button content wrapper */
.btn-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: opacity 0.3s ease;
}

.btn-primary .btn-content {
  position: relative;
}

/* Disabled button styles */
.btn-primary:disabled {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
  box-shadow: 0 2px 8px rgba(148, 163, 184, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:disabled:hover {
  transform: none;
  box-shadow: 0 2px 8px rgba(148, 163, 184, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}

.btn-primary:disabled .btn-icon,
.btn-primary:disabled .btn-text {
  opacity: 0.7;
}

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

  .animated-bg::after {
    animation: none !important;
  }

  .document-icon,
  .document-card {
    animation: none !important;
    transition: none !important;
  }
}


