/* =========================================================
   eiFAM Login — premium split layout, marine blue theme
   ========================================================= */

.login-body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow-x: hidden;
  transition: background 0.4s ease;
}

/* Ambient marine glows behind the card */
.login-body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 14% 16%, rgba(47, 155, 216, 0.14) 0%, transparent 42%),
    radial-gradient(circle at 88% 84%, rgba(47, 155, 216, 0.10) 0%, transparent 42%),
    radial-gradient(circle at 80% 6%, rgba(122, 189, 226, 0.08) 0%, transparent 35%);
}

:root[data-theme="light"] .login-body::before {
  background:
    radial-gradient(circle at 14% 16%, rgba(11, 111, 168, 0.10) 0%, transparent 42%),
    radial-gradient(circle at 88% 84%, rgba(11, 111, 168, 0.08) 0%, transparent 42%),
    radial-gradient(circle at 80% 6%, rgba(11, 111, 168, 0.06) 0%, transparent 35%);
}

/* ---- Theme switch (top right) ---- */
.login-theme-switch {
  position: fixed;
  top: 22px;
  right: 26px;
  z-index: 100;
}

.theme-toggle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.theme-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-1px);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
.theme-toggle.is-light .icon-sun { display: block; }
.theme-toggle.is-light .icon-moon { display: none; }

/* ---- Main card ---- */
.login-card {
  display: flex;
  width: 1040px;
  max-width: 100%;
  min-height: 600px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: var(--shadow-pop);
  position: relative;
  z-index: 1;
  animation: loginCardIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  transition: background 0.3s ease, border 0.3s ease, box-shadow 0.3s ease;
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================================
   Left: form section
   ========================================================= */
.login-form-section {
  width: 48%;
  padding: 44px 48px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 2;
  color: var(--color-text);
  transition: color 0.3s ease;
}

.login-form-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 12% 6%, rgba(47, 155, 216, 0.10) 0%, transparent 48%),
    radial-gradient(circle at 96% 96%, rgba(47, 155, 216, 0.07) 0%, transparent 46%);
  z-index: -1;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, black 86%, transparent 100%);
  mask-image: linear-gradient(to right, black 86%, transparent 100%);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 26px;
  animation: loginFadeUp 0.5s ease forwards 0.05s;
  opacity: 0;
}

.login-brand img {
  height: 54px;
  max-width: 220px;
  object-fit: contain;
}

.login-title {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0 0 8px;
  color: var(--color-heading);
  animation: loginFadeUp 0.5s ease forwards 0.12s;
  opacity: 0;
}

/* ---- Account chooser ---- */
.login-accounts {
  margin-bottom: 22px;
  animation: loginFadeUp 0.5s ease forwards 0.06s;
  opacity: 0;
}

.login-accounts-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.login-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--color-border, rgba(128, 128, 128, 0.2));
  border-radius: 10px;
}

.login-account:hover {
  background: var(--color-hover, rgba(128, 128, 128, 0.08));
}

.login-account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary-strong), var(--color-primary));
}

.login-account-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  text-align: left;
}

.login-account-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.login-account-username {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.login-account-switch {
  border: 1px solid var(--color-primary);
  background: transparent;
  color: var(--color-primary);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.login-account-switch:hover {
  background: var(--color-primary);
  color: #fff;
}

.login-account-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 4px;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.login-account-divider::before,
.login-account-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border, rgba(128, 128, 128, 0.2));
}

.login-subtitle {
  color: var(--color-text-muted);
  font-size: 0.98rem;
  margin: 0 0 32px;
  animation: loginFadeUp 0.5s ease forwards 0.18s;
  opacity: 0;
}

/* ---- Fields ---- */
.login-form {
  position: relative;
  z-index: 5;
}

.login-field {
  margin-bottom: 18px;
}

.login-field-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: 7px;
  animation: loginFadeUp 0.5s ease forwards;
  opacity: 0;
}

.login-field:nth-of-type(1) .login-field-label,
.login-field:nth-of-type(1) .login-input-wrap { animation-delay: 0.24s; }

.login-field:nth-of-type(2) .login-field-label,
.login-field:nth-of-type(2) .login-input-wrap { animation-delay: 0.30s; }

.login-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 14px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
  animation: loginFadeUp 0.5s ease forwards;
  opacity: 0;
}

.login-input-wrap:hover {
  border-color: var(--color-border-strong);
}

.login-input-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.login-input-icon {
  color: var(--color-text-muted);
  flex-shrink: 0;
  display: flex;
  transition: color 0.25s ease;
}

.login-input-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.login-input-wrap:focus-within .login-input-icon {
  color: var(--color-primary);
}

.login-input-wrap input,
.login-input-wrap select {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text);
  font-size: 1rem;
  font-family: inherit;
  height: 100%;
}

.login-input-wrap select {
  width: 100%;
  appearance: none;
}

.login-input-wrap select option {
  background: var(--color-surface);
  color: var(--color-text);
}

.login-notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 12px;
  background: var(--color-success-soft);
  color: var(--color-success);
  font-size: 0.86rem;
}

.login-input-wrap input::placeholder {
  color: var(--color-text-muted);
}

.login-input-wrap input:-webkit-autofill,
.login-input-wrap input:-webkit-autofill:hover,
.login-input-wrap input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--color-text);
  caret-color: var(--color-text);
  transition: background-color 5000s ease-in-out 0s;
}

.login-password-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.login-password-toggle:hover {
  color: var(--color-primary);
}

.login-password-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

.login-password-toggle .icon-eye-open { display: block; }
.login-password-toggle .icon-eye-close { display: none; }
.login-password-toggle.is-visible .icon-eye-open { display: none; }
.login-password-toggle.is-visible .icon-eye-close { display: block; }

.field-validation-error {
  color: var(--color-danger);
  font-size: 0.82rem;
  margin-top: 4px;
  display: block;
}

/* ---- Options ---- */
.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0 0;
  animation: loginFadeUp 0.5s ease forwards 0.34s;
  opacity: 0;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  user-select: none;
  position: relative;
}

.login-remember input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.login-checkmark {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  position: relative;
  transition: all 0.2s ease;
}

.login-remember:hover input ~ .login-checkmark {
  border-color: var(--color-border-strong);
}

.login-remember input:checked ~ .login-checkmark {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.login-checkmark::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s ease;
}

.login-remember input:checked ~ .login-checkmark::after {
  transform: rotate(45deg) scale(1);
}

.login-remember-text {
  line-height: 1;
}

/* ---- Submit button ---- */
.login-btn {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--color-primary-strong) 0%, var(--color-primary) 100%);
  color: var(--color-on-primary);
  font-size: 1.02rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(11, 111, 168, 0.55);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  margin-top: 22px;
  animation: loginFadeUp 0.5s ease forwards 0.38s;
  opacity: 0;
}

.login-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transition: left 0.5s ease;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px -8px rgba(11, 111, 168, 0.65);
}

.login-btn:hover::before { left: 100%; }

.login-btn:active {
  transform: translateY(0) scale(0.985);
}

.login-btn.loading {
  pointer-events: none;
}

.login-btn.loading .btn-text {
  padding-left: 34px;
}

.login-btn.loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -66px;
  margin-top: -11px;
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.5);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: loginSpin 0.7s linear infinite;
}

@keyframes loginSpin { to { transform: rotate(360deg); } }

/* ---- Footer ---- */
.login-footer {
  margin-top: auto;
  padding-top: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  animation: loginFadeUp 0.5s ease forwards 0.44s;
  opacity: 0;
}

.login-footer p { margin: 0; }

.login-footer a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}

.login-footer a:hover { text-decoration: underline; }

.login-footer .version {
  font-size: 0.74rem;
  padding: 4px 12px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-radius: 999px;
  white-space: nowrap;
}

/* ---- Error box & validation summary ---- */
.error-box,
.validation-summary-errors {
  background: var(--color-danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--color-danger);
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  animation: loginSlideDown 0.3s ease-out;
}

:root[data-theme="light"] .error-box,
:root[data-theme="light"] .validation-summary-errors {
  border-color: rgba(220, 38, 38, 0.35);
}

.validation-summary-errors ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.validation-summary-errors li { margin: 0; }

/* =========================================================
   Right: visual panel with orbiting programs
   ========================================================= */
.login-visual {
  width: 52%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(165deg, #0f5c8c 0%, #08345b 52%, #07263c 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 40px;
}

.login-visual::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 24%, rgba(70, 176, 234, 0.35) 0%, transparent 46%),
    radial-gradient(circle at 82% 82%, rgba(47, 155, 216, 0.30) 0%, transparent 44%),
    radial-gradient(circle at 74% 12%, rgba(255, 255, 255, 0.08) 0%, transparent 32%);
  pointer-events: none;
}

.login-visual::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: radial-gradient(circle at 50% 46%, black 28%, transparent 74%);
  mask-image: radial-gradient(circle at 50% 46%, black 28%, transparent 74%);
  pointer-events: none;
}

/* ---- Official art ---- */
.login-art {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 460px;
  height: auto;
  object-fit: contain;
  margin-bottom: 20px;
  border-radius: 18px;
  filter: drop-shadow(0 24px 48px rgba(0, 0, 0, 0.45));
  animation: loginArtIn 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 0.2s;
  opacity: 0;
}

@keyframes loginArtIn {
  from { opacity: 0; transform: translateY(18px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Visual caption ---- */
.login-visual-caption {
  position: relative;
  z-index: 2;
}

.login-visual-caption h2 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin: 0 0 10px;
  color: #ffffff;
}

.login-visual-caption p {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.95rem;
  max-width: 320px;
  margin: 0 auto;
}

/* =========================================================
   Animations
   ========================================================= */
@keyframes loginFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes loginSlideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 920px) {
  .login-card {
    flex-direction: column-reverse;
    width: 100%;
    max-width: 460px;
    min-height: auto;
  }

  .login-form-section {
    width: 100%;
    padding: 34px 28px 24px;
  }

  .login-form-section::before {
    -webkit-mask-image: none;
    mask-image: none;
  }

  .login-visual {
    width: 100%;
    padding: 30px 24px 26px;
  }

  .login-art {
    max-width: 300px;
    margin-bottom: 14px;
  }

  .login-visual-caption h2 {
    font-size: 1.25rem;
  }

  .login-theme-switch {
    top: 14px;
    right: 14px;
  }
}

@media (max-width: 480px) {
  .login-body { padding: 10px; }
  .login-form-section { padding: 28px 22px 22px; }
  .login-title { font-size: 1.55rem; }
  .login-footer { flex-direction: column; gap: 8px; text-align: center; }
}
