/* ==============================
   1. Global styles
============================== */

* {
  box-sizing: border-box;
}

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --text-main: #0f172a;
  --text-secondary: #64748b;
  --border: #cbd5e1;
  --background: #f8f9ff;
  --danger: #e11d48;
  --success: #059669;
}

html {
  min-height: 100%;
}

body.login-page {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--background);
  color: var(--text-main);
  font-family: Inter, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

::selection {
  background: #e0e7ff;
  color: #312e81;
}

/* ==============================
   2. Header and branding
============================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.brand,
.brand-name {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-name {
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-highlight {
  color: var(--primary);
  font-weight: 800;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(45deg, #4f46e5, #6366f1);
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(99, 102, 241, 0.2);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.enterprise-label {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

/* ==============================
   3. Main layout and background
============================== */

.login-main {
  position: relative;
  isolation: isolate;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow: hidden;
}

.background-glow {
  position: absolute;
  z-index: -1;
  width: 384px;
  height: 384px;
  border-radius: 50%;
  filter: blur(48px);
  pointer-events: none;
}

.glow-top {
  top: -160px;
  left: -160px;
  background: rgba(199, 210, 254, 0.4);
}

.glow-bottom {
  right: -160px;
  bottom: -160px;
  background: rgba(219, 234, 254, 0.6);
}

/* ==============================
   4. Login card
============================== */

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: 40px;
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(148, 163, 184, 0.12),
    0 8px 10px -6px rgba(148, 163, 184, 0.1);
}

.fade-step {
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==============================
   5. Headings and step icons
============================== */

.step-heading {
  margin-bottom: 32px;
  text-align: center;
}

.step-heading h1,
.step-heading h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.step-heading p {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.step-icon {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--primary);
  background: #eef2ff;
  border: 1px solid #e0e7ff;
  border-radius: 12px;
}

.step-icon svg {
  width: 24px;
  height: 24px;
}

/* ==============================
   6. Forms and inputs
============================== */

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  min-width: 0;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 14px;
  display: flex;
  align-items: center;
  color: #94a3b8;
  pointer-events: none;
}

.input-icon svg {
  width: 20px;
  height: 20px;
}

#email-input {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 12px 16px 12px 44px;
  font-size: 14px;
  color: var(--text-main);
  background: rgba(248, 250, 252, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s,
    background 0.2s;
}

#email-input::placeholder {
  color: #94a3b8;
}

#email-input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.error-message {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
}

/* ==============================
   7. Primary button
============================== */

.primary-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  color: #fff;
  background: var(--primary);
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 8px rgba(79, 70, 229, 0.2);
  outline: none;
  transition: background 0.2s, box-shadow 0.2s,
    transform 0.15s;
}

.primary-button svg {
  width: 16px;
  height: 16px;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.primary-button:focus-visible {
  box-shadow: 0 0 0 2px #fff,
    0 0 0 4px var(--primary);
}

.primary-button:active:not(:disabled) {
  transform: scale(0.99);
}

/* ==============================
   8. Terms and links
============================== */

.terms-text {
  margin-top: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.7;
}

.terms-text a {
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
}

.terms-text a:hover {
  text-decoration: underline;
}

/* ==============================
   9. OTP step
============================== */

.otp-heading {
  margin-bottom: 24px;
}

.email-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin-top: 8px;
  padding: 4px 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
}

#display-user-email {
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
}

#edit-email-btn {
  padding: 0;
  color: var(--primary);
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 600;
}

#edit-email-btn:hover {
  color: #3730a3;
  text-decoration: underline;
}

.otp-form {
  gap: 24px;
}

.otp-label {
  margin-bottom: 16px !important;
  text-align: center;
}

.otp-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.otp-input {
  width: 48px;
  height: 56px;
  min-width: 0;
  padding: 0;
  color: var(--text-main);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  transition: border-color 0.2s, box-shadow 0.2s,
    background 0.2s;
}

.otp-input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.otp-separator {
  color: #cbd5e1;
  font-weight: 700;
}

.otp-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 12px;
  color: var(--danger);
  text-align: center;
  font-size: 12px;
  font-weight: 500;
}

.otp-error.hidden {
  display: none !important;
}

/* ==============================
   10. Expiry and resend section
============================== */

.expiry-text {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}

.expiry-text svg {
  width: 14px;
  height: 14px;
  color: #94a3b8;
}

.expiry-text strong {
  color: #334155;
  font-weight: 600;
}

.otp-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #f1f5f9;
  color: var(--text-secondary);
  font-size: 12px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 500;
}

.text-button svg {
  width: 14px;
  height: 14px;
}

.back-button {
  color: #475569;
}

.back-button:hover {
  color: var(--text-main);
}

.resend-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.resend-button {
  color: var(--primary);
  font-weight: 600;
}

.resend-button:hover:not(:disabled) {
  color: #3730a3;
  text-decoration: underline;
}

.resend-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.resend-note {
  margin: 12px 0 0;
  color: var(--success);
  text-align: center;
  font-size: 12px;
  font-weight: 500;
}

/* ==============================
   11. Success state
============================== */

.success-step {
  padding: 24px 0;
  text-align: center;
}

.success-icon {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--success);
  background: #d1fae5;
  border-radius: 16px;
}

.success-icon svg {
  width: 32px;
  height: 32px;
}

.success-step h3 {
  margin: 0;
  color: var(--text-main);
  font-size: 20px;
  font-weight: 700;
}

.success-step p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.loading-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==============================
   12. Footer
============================== */

.site-footer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 32px;
  background: rgba(255, 255, 255, 0.5);
  border-top: 1px solid rgba(226, 232, 240, 0.6);
  color: var(--text-secondary);
  font-size: 12px;
}

.footer-brand {
  color: #334155;
  font-weight: 500;
}

.footer-copyright {
  color: #94a3b8;
  text-align: right;
}

/* ==============================
   13. Responsive layout
============================== */

@media (min-width: 1024px) {
  .login-main {
    padding: 32px;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 20px 16px;
  }

  .brand-name {
    gap: 6px;
    font-size: 18px;
  }

  .enterprise-label {
    padding: 3px 6px;
    font-size: 9px;
    letter-spacing: 0.5px;
  }

  .login-main {
    padding: 24px 16px;
  }

  .login-card {
    padding: 32px 24px;
  }

  .site-footer {
    padding: 16px;
    flex-direction: column;
    text-align: center;
  }

  .footer-copyright {
    text-align: center;
  }
}

@media (max-width: 380px) {
  .login-card {
    padding: 28px 16px;
  }

  .otp-container {
    gap: 5px;
  }

  .otp-input {
    width: 0;
    height: 48px;
    flex: 1;
    font-size: 18px;
  }

  .otp-separator {
    font-size: 12px;
  }

  .otp-footer {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .resend-group {
    flex-wrap: wrap;
  }
}