/* ─── CSS custom properties ──────────────────────────────────────────────────── */
:root {
  --primary:       #7c3aed;
  --primary-hover: #6d28d9;
  --panel-bg:      #0f172a;
  --radius:        12px;
}

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

body {
  min-height: 100vh;
  display: flex;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1e293b;
  background: #f8fafc;
}

/* ─── Split layout ───────────────────────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* ─── Left: brand panel ──────────────────────────────────────────────────────── */
.login-panel-brand {
  position: relative;
  flex: 1;
  background: var(--panel-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 3rem;
}

.brand-shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.shape {
  position: absolute;
  border-radius: 50%;
  opacity: .12;
  background: var(--primary);
}

.shape-1 {
  width: 420px;
  height: 420px;
  top: -120px;
  left: -100px;
}

.shape-2 {
  width: 280px;
  height: 280px;
  bottom: -60px;
  right: -80px;
  opacity: .08;
}

.shape-3 {
  width: 160px;
  height: 160px;
  bottom: 30%;
  left: 15%;
  opacity: .06;
  background: #e2e8f0;
}

.brand-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #fff;
  max-width: 360px;
}

.brand-content img {
  height: 56px;
  width: auto;
  object-fit: contain;
  margin-bottom: 1.5rem;
  filter: brightness(0) invert(1);
}

#brand-name {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: #f8fafc;
  margin-bottom: .75rem;
}

.brand-tagline {
  font-size: 1rem;
  color: #94a3b8;
  line-height: 1.6;
}

/* ─── Right: form panel ──────────────────────────────────────────────────────── */
.login-panel-form {
  flex: 0 0 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 2rem;
  background: #fff;
  box-shadow: -8px 0 40px rgba(0,0,0,.06);
}

.login-card {
  width: 100%;
  max-width: 360px;
}

/* ─── Card brand (small, top of form) ───────────────────────────────────────── */
.login-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 2rem;
}

.login-brand img {
  height: 28px;
  width: auto;
  object-fit: contain;
}

#app-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

/* ─── Titles ─────────────────────────────────────────────────────────────────── */
.login-title {
  font-size: 1.625rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -.02em;
  margin-bottom: .375rem;
}

.login-subtitle {
  font-size: .9375rem;
  color: #64748b;
  margin-bottom: 2rem;
}

/* ─── Form fields ────────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 1.125rem;
}

.field label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .4rem;
  color: #475569;
}

.field input {
  width: 100%;
  padding: .6875rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: calc(var(--radius) - 2px);
  font-size: .9375rem;
  color: #0f172a;
  background: #f8fafc;
  transition: border-color .15s, background .15s, box-shadow .15s;
  outline: none;
}

.field input::placeholder {
  color: #cbd5e1;
}

.field input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

.field input.is-invalid {
  border-color: #f43f5e;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, .12);
}

/* ─── Password toggle ────────────────────────────────────────────────────────── */
.password-wrapper {
  position: relative;
}

.password-wrapper input {
  padding-right: 2.75rem;
}

.toggle-password {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: .25rem;
  line-height: 0;
  transition: color .15s;
}

.toggle-password:hover { color: #475569; }

.eye-icon {
  width: 1.125rem;
  height: 1.125rem;
}

/* ─── Error ──────────────────────────────────────────────────────────────────── */
.error-message {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #e11d48;
  border-radius: calc(var(--radius) - 2px);
  padding: .625rem 1rem;
  font-size: .875rem;
  margin-bottom: 1rem;
}

/* ─── Submit button ──────────────────────────────────────────────────────────── */
.btn-login {
  width: 100%;
  padding: .8125rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-size: .9375rem;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: 1.75rem;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--primary) 35%, transparent);
}

.btn-login:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 18px color-mix(in srgb, var(--primary) 45%, transparent);
}

.btn-login:active:not(:disabled) {
  transform: translateY(0);
}

.btn-login:disabled {
  cursor: not-allowed;
}

.btn-login.is-loading {
  opacity: .8;
  background-size: 200% 100%;
  background-image: linear-gradient(
    90deg,
    var(--primary) 0%,
    var(--primary-hover) 50%,
    var(--primary) 100%
  );
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ─── TOTP stap ──────────────────────────────────────────────────────────────── */
.otp-info {
  font-size: .9375rem;
  color: #475569;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.otp-info strong {
  color: #0f172a;
}

#totp-code,
#totp-setup-code {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-align: center;
  caret-color: transparent;
}

.qr-wrapper {
  display: flex;
  justify-content: center;
  margin: 0 0 1.25rem;
}

.qr-code {
  width: 192px;
  height: 192px;
  border: 1.5px solid #e2e8f0;
  border-radius: calc(var(--radius) - 2px);
  padding: 10px;
  background: #fff;
}

.totp-manual {
  margin: -.25rem 0 1.25rem;
  font-size: .875rem;
  color: #64748b;
  text-align: center;
}

.totp-manual summary {
  cursor: pointer;
  color: var(--primary);
  margin-bottom: .5rem;
  list-style: none;
}

.totp-manual summary::-webkit-details-marker { display: none; }

.totp-manual code {
  display: block;
  font-family: monospace;
  font-size: .9375rem;
  letter-spacing: .15em;
  color: #0f172a;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: calc(var(--radius) - 2px);
  padding: .5rem;
  user-select: all;
  word-break: break-all;
}

.btn-back {
  display: block;
  width: 100%;
  margin-top: .75rem;
  padding: .5rem;
  background: none;
  border: none;
  color: #64748b;
  font-size: .875rem;
  cursor: pointer;
  text-align: center;
  transition: color .15s;
}

.btn-back:hover { color: #0f172a; }

.btn-forgot {
  display: block;
  width: 100%;
  margin-top: .625rem;
  padding: .375rem;
  background: none;
  border: none;
  color: var(--primary);
  font-size: .875rem;
  cursor: pointer;
  text-align: center;
  transition: color .15s;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.btn-resend {
  display: block;
  width: 100%;
  margin-top: .5rem;
  padding: .375rem;
  background: none;
  border: none;
  color: var(--primary);
  font-size: .875rem;
  cursor: pointer;
  text-align: center;
  transition: color .15s;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-resend:hover:not(:disabled) { color: var(--primary-hover); }
.btn-resend:disabled { color: #94a3b8; cursor: not-allowed; text-decoration: none; }

.success-message {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  border-radius: calc(var(--radius) - 2px);
  padding: .625rem 1rem;
  font-size: .875rem;
  margin-bottom: 1rem;
}

.reset-done-message {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  border-radius: calc(var(--radius) - 2px);
  padding: .625rem 1rem;
  font-size: .875rem;
  margin-bottom: 1.25rem;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .login-wrapper {
    flex-direction: column;
  }

  .login-panel-brand {
    flex: none;
    padding: 2.5rem 2rem;
    min-height: 220px;
  }

  #brand-name { font-size: 1.5rem; }
  .brand-tagline { font-size: .875rem; }

  .shape-1 { width: 280px; height: 280px; top: -80px; left: -60px; }
  .shape-2 { width: 180px; height: 180px; }

  .login-panel-form {
    flex: 1;
    box-shadow: none;
    padding: 2rem 1.5rem 3rem;
  }
}

@media (max-width: 480px) {
  .login-panel-form {
    padding: 1.75rem 1.25rem 2.5rem;
  }
}
