@import url('brand-tokens.css');

.auth {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--color-green-dark) 0%, var(--color-green-pine) 60%, #183e34 100%);
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 9999;
}

.auth__bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.auth__bg::before,
.auth__bg::after {
  content: '';
  position: absolute;
  border: 2px solid var(--color-green-apple);
  opacity: 0.05;
  animation: float 12s ease-in-out infinite;
}

.auth__bg::before {
  width: 200px;
  height: 200px;
  top: 20%;
  left: 10%;
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  animation-duration: 14s;
}

.auth__bg::after {
  width: 300px;
  height: 300px;
  bottom: 20%;
  right: 10%;
  border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  animation-duration: 16s;
  animation-delay: -4s;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  33% {
    transform: translate(10px, -10px) rotate(120deg);
  }
  66% {
    transform: translate(-10px, 10px) rotate(240deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth__bg::before,
  .auth__bg::after {
    animation: none;
  }
}

.auth__card {
  background: var(--color-white);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  width: 100%;
  max-width: 420px;
  max-height: 100vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 1;
  animation: fadeInScale var(--duration-med) var(--ease-standard);
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.auth__logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-6);
}

.auth__logo img,
.auth__logo svg {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 180px !important;
  object-fit: contain;
}

.auth__title {
  font-family: inherit;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-green-dark);
  text-align: center;
  margin: 0 0 var(--space-2) 0;
  line-height: 1.3;
}

.auth__subtitle {
  font-family: inherit;
  font-size: 1rem;
  color: #6B7280;
  text-align: center;
  margin: 0 0 var(--space-6) 0;
}

.auth__alert {
  background: #FEE2E2;
  border: 1px solid #FECACA;
  color: #991B1B;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
  font-family: inherit;
}

.auth__alert--success {
  background: #D1FAE5;
  border-color: #A7F3D0;
  color: #065F46;
}

.auth__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.auth__field label {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

.auth__field input {
  height: 48px;
  padding: 0 var(--space-4);
  border: 1px solid #E6E8E6;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-green-dark);
  transition: all var(--duration-fast) var(--ease-standard);
  background: var(--color-white);
}

.auth__field input:focus {
  outline: none;
  border-color: var(--color-green-pine);
  box-shadow: 0 0 0 2px rgba(28, 85, 68, 0.2);
}

.auth__field input[aria-invalid="true"] {
  border-color: #D14343;
}

.auth__field--password {
  position: relative;
}

.auth__toggle {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: #6B7280;
  transition: all var(--duration-fast);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth__toggle:hover {
  color: var(--color-green-pine);
}

.auth__toggle svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth__toggle[aria-label="Show password"] svg .eye-open {
  display: block;
}

.auth__toggle[aria-label="Show password"] svg .eye-closed {
  display: none;
}

.auth__toggle[aria-label="Hide password"] svg .eye-open {
  display: none;
}

.auth__toggle[aria-label="Hide password"] svg .eye-closed {
  display: block;
}

.auth__field-error {
  font-family: inherit;
  font-size: 0.75rem;
  color: #D14343;
  margin-top: var(--space-1);
}

.auth__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.auth__submit {
  height: 48px;
  background: var(--color-green-pine);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius-xl);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth__submit:hover:not(:disabled) {
  background: #184a3d;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(28, 85, 68, 0.3);
}

.auth__submit:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(28, 85, 68, 0.3);
}

.auth__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth__link {
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--color-green-pine);
  text-decoration: none;
  text-align: center;
  transition: color var(--duration-fast);
}

.auth__link:hover {
  color: #184a3d;
  text-decoration: underline;
}

.auth__remember {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}

.auth__remember input[type="checkbox"] {
  width: 20px;
  height: 20px;
  border: 1px solid #E6E8E6;
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--color-green-pine);
}

.auth__remember label {
  font-family: inherit;
  font-size: 0.875rem;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

.auth__text-muted {
  text-align: center;
  color: #6B7280;
  font-size: 0.875rem;
  margin: var(--space-4) 0;
}

.auth__hint {
  font-size: 0.75rem;
  color: #6B7280;
  margin: var(--space-2) 0;
}

.auth__actions--spaced {
  margin-top: var(--space-6);
}

.auth__card .auth__version {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid #E5E7EB;
  text-align: center;
  font-size: 0.75rem;
  color: #D1D5DB;
  user-select: none;
  display: flex;
  justify-content: center;
  gap: var(--space-3);
}

.auth__version span {
  color: inherit;
  user-select: all;
}

.auth__version:hover {
  color: #9CA3AF;
}

.auth__version--branch {
  color: transparent !important;
}

@media (max-width: 480px) {
  .auth__card {
    margin: var(--space-4);
    padding: var(--space-6);
  }

  .auth__title {
    font-size: 1.5rem;
  }

  .auth__bg::before {
    width: 150px;
    height: 150px;
  }

  .auth__bg::after {
    width: 200px;
    height: 200px;
  }
}

@media (max-height: 700px) {
  .auth {
    padding: var(--space-4) 0;
  }

  .auth__card {
    margin: var(--space-4);
    padding: var(--space-6);
    max-height: calc(100vh - var(--space-8));
  }

  .auth__title {
    font-size: 1.5rem;
    margin-bottom: var(--space-2);
  }

  .auth__subtitle {
    font-size: 0.875rem;
    margin-bottom: var(--space-4);
  }

  .auth__field {
    gap: var(--space-1);
  }

  .auth__field input {
    height: 44px;
  }

  .auth__submit {
    height: 44px;
  }

  .auth__version {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
  }
}

@media (max-height: 600px) {
  .auth__card {
    padding: var(--space-4);
  }

  .auth__logo {
    margin-bottom: var(--space-4);
  }

  .auth__title {
    font-size: 1.375rem;
  }

  .auth__subtitle {
    font-size: 0.8125rem;
    margin-bottom: var(--space-3);
  }

  .auth__form {
    gap: var(--space-3);
  }

  .auth__actions {
    gap: var(--space-2);
    margin-top: var(--space-1);
  }
}

body.page-login {
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.page-login .wrapper,
.page-login .content-wrapper,
.page-login .main-content,
.page-login .content,
.page-login .login-wrapper {
  all: unset !important;
  display: contents !important;
}