@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

:root {
  --login-primary-light: #9d68f7;
  --login-primary: #7c3aed;
  --login-primary-dark: #6d28d9;
  --login-gradient-start: #7c3aed;
  --login-gradient-mid: #6d28d9;
  --login-gradient-end: #4c1d95;
}

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

html {
  min-height: 100%;
}

body {
  position: relative;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1rem;
  background: linear-gradient(
    135deg,
    var(--login-gradient-start) 0%,
    var(--login-gradient-mid) 50%,
    var(--login-gradient-end) 100%
  );
  color: #1f2937;
  font-family:
    "Poppins",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

body::before,
body::after {
  position: absolute;
  width: 18.75rem;
  height: 18.75rem;
  border-radius: 50%;
  content: "";
  filter: blur(60px);
  opacity: 0.1;
  pointer-events: none;
}

body::before {
  top: -6.25rem;
  left: -6.25rem;
  background: #9d68f7;
}

body::after {
  right: -6.25rem;
  bottom: -6.25rem;
  background: #4338ca;
}

.login-theme-toggle {
  position: fixed;
  z-index: 100;
  top: 1rem;
  right: 1rem;
  display: flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  font-size: 1.125rem;
  transition:
    background-color 220ms ease,
    border-color 220ms ease,
    color 220ms ease,
    transform 220ms ease,
    box-shadow 220ms ease;
}

.login-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.16);
  transform: translateY(-1px);
}

.login-theme-toggle:active {
  transform: translateY(0);
}

.login-theme-toggle:focus-visible,
.login-button:focus-visible,
.password-toggle:focus-visible,
.forgot-password:focus-visible {
  outline: 3px solid rgba(196, 181, 253, 0.8);
  outline-offset: 3px;
}

.login-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 23.75rem;
  margin: 1rem;
  overflow: hidden;
  padding: 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 1.5rem;
  animation: login-fade-in 600ms ease-in-out;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow:
    0 15px 35px rgba(0, 0, 0, 0.2),
    0 5px 15px rgba(0, 0, 0, 0.05);
  text-align: center;
}

.login-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--login-primary-light),
    var(--login-primary),
    var(--login-primary-dark)
  );
  content: "";
}

.brand-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.brand-icon {
  display: flex;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  border-radius: 0.5rem;
  background: linear-gradient(
    120deg,
    var(--login-primary) 0%,
    var(--login-primary-dark) 100%
  );
  box-shadow: 0 4px 10px rgba(109, 40, 217, 0.25);
  color: #fff;
  font-size: 1.25rem;
}

.brand-copy {
  text-align: left;
}

.brand-title {
  margin: 0;
  color: #1f2937;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
}

.brand-subtitle {
  margin: 0;
  color: #6b7280;
  font-size: 0.75rem;
}

.error-message {
  max-height: 0;
  margin: 0 auto 1rem;
  overflow: hidden;
  border-left: 4px solid #ef4444;
  border-radius: 0.375rem;
  background-color: #fee2e2;
  color: #b91c1c;
  opacity: 0;
  padding: 0 0.75rem;
  text-align: left;
  transition:
    max-height 350ms ease,
    margin 350ms ease,
    opacity 350ms ease,
    padding 350ms ease;
}

.error-message.visible {
  max-height: 6rem;
  margin-bottom: 1.25rem;
  opacity: 1;
  padding-block: 0.75rem;
}

.error-content {
  display: flex;
  align-items: center;
}

.error-icon {
  margin-right: 0.5rem;
  color: #ef4444;
}

.error-text {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
}

.form-group {
  position: relative;
  margin-bottom: 1.25rem;
  text-align: left;
}

.field-label {
  display: block;
  margin-bottom: 0.5rem;
  color: #4b5563;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 250ms ease;
}

.input-shell {
  position: relative;
}

.form-input {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 0.75rem 0.75rem 2.5rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 0.75rem;
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(5px);
  color: #1f2937;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  transition:
    background-color 250ms ease,
    border-color 250ms ease,
    box-shadow 250ms ease,
    color 250ms ease;
}

.form-input::placeholder {
  color: #9ca3af;
}

.form-input:focus {
  border-color: var(--login-primary);
  outline: none;
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.form-input.error {
  border-color: #ef4444;
}

.form-input.error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.password-input {
  padding-right: 3rem;
}

.input-icon {
  position: absolute;
  top: 50%;
  left: 0.875rem;
  color: #9ca3af;
  pointer-events: none;
  transform: translateY(-50%);
  transition: color 250ms ease;
}

.form-input:focus + .input-icon,
.form-input:not(:placeholder-shown) + .input-icon {
  color: var(--login-primary);
}

.form-input.error + .input-icon {
  color: #ef4444;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  display: flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  transform: translateY(-50%);
  transition:
    background-color 200ms ease,
    color 200ms ease;
}

.password-toggle:hover {
  background: rgba(124, 58, 237, 0.08);
  color: var(--login-primary);
}

.forgot-row {
  margin-top: 0.5rem;
  text-align: right;
}

.forgot-password {
  border: 0;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  text-decoration: none;
  transition: color 200ms ease;
}

.forgot-password:hover {
  color: var(--login-primary);
}

.login-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  margin-top: 1.5rem;
  padding: 0.875rem 0.75rem;
  border: 0;
  border-radius: 0.75rem;
  background-image: linear-gradient(
    to right,
    var(--login-primary),
    var(--login-primary-dark)
  );
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  transition:
    background-image 250ms ease,
    box-shadow 250ms ease,
    transform 250ms ease;
}

.login-button:hover {
  background-image: linear-gradient(
    to right,
    var(--login-primary-dark),
    var(--login-gradient-end)
  );
  box-shadow: 0 6px 15px rgba(124, 58, 237, 0.35);
  transform: translateY(-2px);
}

.login-button:active {
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
  transform: translateY(0);
}

.login-button-icon {
  margin-right: 0.5rem;
}

.login-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #f3f4f6;
  text-align: center;
}

.login-footer-text {
  color: #9ca3af;
  font-size: 0.75rem;
}

.shake {
  animation: login-shake 600ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes login-fade-in {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes login-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-5px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(5px);
  }
}

.dark body {
  background: linear-gradient(135deg, #1e1b4b 0%, #1f2937 50%, #111827 100%);
}

.dark .login-card {
  border-color: rgba(148, 163, 184, 0.14);
  background-color: rgba(31, 41, 55, 0.95);
}

.dark .brand-title {
  color: #e5e7eb;
}

.dark .brand-subtitle,
.dark .field-label,
.dark .forgot-password,
.dark .login-footer-text {
  color: #9ca3af;
}

.dark .form-input {
  border-color: #4b5563;
  background-color: #374151;
  color: #e5e7eb;
}

.dark .form-input:focus {
  border-color: #8b5cf6;
  background-color: #1f2937;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.dark .form-input::placeholder {
  color: #94a3b8;
}

.dark .input-icon,
.dark .password-toggle {
  color: #94a3b8;
}

.dark .password-toggle:hover {
  background: rgba(139, 92, 246, 0.14);
  color: #c4b5fd;
}

.dark .forgot-password:hover {
  color: #c4b5fd;
}

.dark .login-button {
  background-image: linear-gradient(to right, #7c3aed, #5b21b6);
}

.dark .login-button:hover {
  background-image: linear-gradient(to right, #6d28d9, #4c1d95);
}

.dark .login-card::before {
  background: linear-gradient(90deg, #8b5cf6, #6d28d9, #5b21b6);
}

.dark .brand-icon {
  background: linear-gradient(120deg, #7c3aed, #5b21b6);
}

.dark .login-theme-toggle {
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(31, 41, 55, 0.5);
  color: #e5e7eb;
}

.dark .login-theme-toggle:hover {
  background: rgba(31, 41, 55, 0.8);
}

.dark .error-message {
  border-left-color: #ef4444;
  background-color: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.dark .error-icon {
  color: #fca5a5;
}

.dark .login-footer {
  border-top-color: #374151;
}

.theme-transition body,
.theme-transition .login-card,
.theme-transition .brand-title,
.theme-transition .brand-subtitle,
.theme-transition .field-label,
.theme-transition .form-input,
.theme-transition .input-icon,
.theme-transition .password-toggle,
.theme-transition .forgot-password,
.theme-transition .login-button,
.theme-transition .login-footer,
.theme-transition .login-footer-text,
.theme-transition .login-theme-toggle,
.theme-transition .error-message {
  transition-duration: 520ms;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-width: 480px) {
  .login-card {
    max-width: 90%;
    margin: 1rem;
    padding: 2rem 1.5rem;
  }

  .form-input {
    padding-left: 2.25rem;
  }

  .input-icon {
    left: 0.75rem;
  }
}

@media (max-width: 360px) {
  .login-card {
    margin: 0.5rem;
    padding: 1.5rem 1.25rem;
  }

  .brand-container {
    margin-bottom: 1rem;
  }

  .brand-icon {
    width: 2rem;
    height: 2rem;
    margin-right: 0.5rem;
  }

  .brand-title {
    font-size: 1.25rem;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .login-card {
    max-width: 26rem;
    padding: 2.25rem 2rem;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body {
    align-items: flex-start;
    padding-top: 0.5rem;
    overflow-y: auto;
  }

  .login-card {
    margin: 0.5rem;
    padding: 1.5rem 2rem;
  }

  .brand-container {
    margin-bottom: 1rem;
  }
}

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