/* ============================================================
   Microsoft 365 – faithful login page styles
   ============================================================ */

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

:root {
  --ms-blue: #0078d4;
  --ms-blue-h: #006cbe;
  /* hover */
  --ms-blue-a: #005ba1;
  /* active */
  --ms-err: #a4262c;
  --ms-text: #1b1b1b;
  --ms-muted: #605e5c;
  --ms-border: #8a8886;
  --ms-border-f: #0078d4;
  --ms-bg: #f2f2f2;
  --ms-box-bg: #ffffff;
  --ms-radius: 0px;
  /* Microsoft uses sharp corners */
}

html,
body {
  height: 100%;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  background: var(--ms-bg);
  color: var(--ms-text);
  -webkit-font-smoothing: antialiased;
}

/* ── Outer layout ──────────────────────────────────────────── */
.ms-outer {
  display: flex;
  min-height: 100vh;
}

/* Left decorative panel (hidden on small screens) */
.ms-left-panel {
  flex: 1;
  display: none;
  position: relative;
  overflow: hidden;
}

@media (min-width: 900px) {
  .ms-left-panel {
    display: block;
  }
}

.ms-left-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, #0078d4 0%, #003a70 60%, #001232 100%);
}

/* Subtle geometric shapes on the left panel */
.ms-left-bg::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .04);
  top: -120px;
  left: -160px;
}

.ms-left-bg::after {
  content: '';
  position: absolute;
  width: 350px;
  height: 350px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
  bottom: 60px;
  right: -80px;
}

/* Right panel */
.ms-right-panel {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 40px 24px 24px;
  background: var(--ms-box-bg);
  min-height: 100vh;
}

@media (min-width: 900px) {
  .ms-right-panel {
    width: 500px;
    flex-shrink: 0;
  }
}

/* ── Login box ─────────────────────────────────────────────── */
.ms-box {
  width: 100%;
  max-width: 440px;
  padding: 44px 44px 36px;
  background: var(--ms-box-bg);
  /* Microsoft uses a subtle box on grey bg but full-white panel on wide */
}

@media (max-width: 540px) {
  .ms-box {
    padding: 32px 24px 28px;
  }
}

/* ── Brand ─────────────────────────────────────────────────── */
.ms-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.ms-brand-logo {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.ms-brand-name {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ms-text);
  letter-spacing: -.01em;
}

/* ── Step visibility ───────────────────────────────────────── */
.ms-step {
  display: none;
}

.ms-step.active {
  display: block;
}

/* ── Title & subtitle ──────────────────────────────────────── */
.ms-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ms-text);
  margin-bottom: 16px;
  line-height: 1.3;
}

.ms-subtitle {
  font-size: .875rem;
  color: var(--ms-muted);
  margin-bottom: 20px;
}

/* ── Float-label input field ───────────────────────────────── */
.ms-field-wrap {
  margin-bottom: 12px;
}

.ms-field {
  position: relative;
  margin-bottom: 4px;
}

.ms-pw-container {
  position: relative;
}

.ms-input {
  width: 100%;
  height: 40px;
  padding: 18px 8px 4px 8px;
  border: none;
  border-bottom: 1px solid var(--ms-border);
  border-radius: 2px 2px 0 0;
  background: #faf9f8;
  font-size: .9375rem;
  line-height: 1.2;
  font-family: inherit;
  color: var(--ms-text);
  outline: none;
  transition: background .15s;
  -webkit-appearance: none;
}

.ms-input:focus {
  background: #fff;
}

/* Autofill detection */
@keyframes onAutoFillStart {
  from {}

  to {}
}

.ms-input:-webkit-autofill {
  animation-name: onAutoFillStart;
}

/* Floating label */
.ms-label {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .9375rem;
  color: var(--ms-muted);
  pointer-events: none;
  transition: top .12s ease, transform .12s ease, font-size .12s ease, color .12s ease;
  transform-origin: left center;
}

/* Float up when input has value OR is focused */
.ms-input:focus~.ms-label,
.ms-input:not(:placeholder-shown)~.ms-label {
  top: 5px;
  transform: translateY(0) scale(.74);
  font-size: .9375rem;
  color: var(--ms-muted);
}

.ms-input:focus~.ms-label {
  color: var(--ms-blue);
}

/* Password eye button positioning */
.ms-pw-container .ms-input {
  padding-right: 40px;
}

.ms-pw-container .ms-label {
  /* same float as regular label but inside .ms-pw-container */
}

.ms-pw-container .ms-input:focus~.ms-label,
.ms-pw-container .ms-input:not(:placeholder-shown)~.ms-label {
  top: 5px;
  transform: translateY(0) scale(.74);
  color: var(--ms-muted);
}

.ms-pw-container .ms-input:focus~.ms-label {
  color: var(--ms-blue);
}

/* Animated underline */
.ms-field-line {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--ms-blue);
  transition: width .2s ease;
}

.ms-field:focus-within .ms-field-line {
  width: 100%;
}

/* Error state */
.ms-field.has-error .ms-input {
  border-bottom-color: var(--ms-err);
}

.ms-field.has-error .ms-field-line {
  background: var(--ms-err);
  width: 100%;
}

.ms-field.has-error .ms-label {
  color: var(--ms-err) !important;
}

.ms-field-error {
  font-size: .8125rem;
  color: var(--ms-err);
  margin-top: 4px;
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ms-field-error:not(:empty)::before {
  content: '⚠';
  font-size: .85rem;
}

/* ── Password toggle ───────────────────────────────────────── */
.ms-pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ms-muted);
  padding: 6px;
  display: flex;
  align-items: center;
  transition: color .15s;
}

.ms-pw-toggle:hover {
  color: var(--ms-blue);
}

.ms-pw-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ── Links ─────────────────────────────────────────────────── */
.ms-no-account,
.ms-info-line {
  font-size: .875rem;
  color: var(--ms-muted);
  margin-bottom: 14px;
}

.ms-no-account a,
.ms-info-line a {
  color: var(--ms-blue);
  text-decoration: none;
}

.ms-no-account a:hover,
.ms-info-line a:hover {
  text-decoration: underline;
}

/* ── Primary Next / Sign in button ────────────────────────── */
.ms-btn-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

.ms-btn-next {
  min-width: 108px;
  padding: 0 20px;
  height: 36px;
  background: var(--ms-blue);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 2px;
  font-size: .9375rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
  user-select: none;
}

.ms-btn-next:hover {
  background: var(--ms-blue-h);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

.ms-btn-next:active {
  background: var(--ms-blue-a);
  box-shadow: none;
}

.ms-btn-next:focus-visible {
  outline: 2px solid var(--ms-blue);
  outline-offset: 2px;
}

/* ── Divider ───────────────────────────────────────────────── */
.ms-divider {
  position: relative;
  text-align: center;
  margin: 24px 0 16px;
  color: var(--ms-muted);
  font-size: .8125rem;
}

.ms-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #edebe9;
}

.ms-divider span {
  position: relative;
  background: var(--ms-box-bg);
  padding: 0 10px;
}

/* ── Sign-in options (Windows Hello etc.) ──────────────────── */
.ms-signin-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ms-option-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #edebe9;
  border-radius: 2px;
  background: #fff;
  font-size: .875rem;
  font-family: inherit;
  color: var(--ms-text);
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
}

.ms-option-btn:hover {
  background: #f3f2f1;
  border-color: #c8c6c4;
}

.ms-option-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── Back button (step 2) ──────────────────────────────────── */
.ms-back-row {
  margin-bottom: 12px;
}

.ms-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ms-blue);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 2px;
  transition: background .15s;
}

.ms-back-btn:hover {
  background: #f3f2f1;
}

.ms-back-btn svg {
  width: 18px;
  height: 18px;
}

/* ── User chip ─────────────────────────────────────────────── */
.ms-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #edebe9;
  border-radius: 16px;
  margin-bottom: 20px;
  font-size: .875rem;
  color: var(--ms-text);
}

.ms-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ms-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ms-avatar svg {
  width: 16px;
  height: 16px;
}

.ms-user-display {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Keep me signed in ─────────────────────────────────────── */
.ms-keep-signed {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: .9375rem;
}

.ms-keep-signed input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--ms-blue);
  cursor: pointer;
}

.ms-keep-signed label {
  cursor: pointer;
}

.ms-kmsi-note {
  font-size: .8125rem;
  color: var(--ms-muted);
  margin-top: 6px;
  line-height: 1.5;
}

.ms-kmsi-note a {
  color: var(--ms-blue);
  text-decoration: none;
}

.ms-kmsi-note a:hover {
  text-decoration: underline;
}

/* ── Loading step ──────────────────────────────────────────── */
.ms-loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  gap: 24px;
}

.ms-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #edebe9;
  border-top-color: var(--ms-blue);
  border-radius: 50%;
  animation: ms-spin .7s linear infinite;
}

@keyframes ms-spin {
  to {
    transform: rotate(360deg);
  }
}

.ms-loading-text {
  font-size: .9375rem;
  color: var(--ms-muted);
}

/* ── Footer ────────────────────────────────────────────────── */
.ms-footer {
  width: 100%;
  max-width: 440px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding-top: 16px;
  font-size: .75rem;
  line-height: 1.45;
  color: var(--ms-muted);
}

.ms-footer-copy {
  color: var(--ms-muted);
}

.ms-footer a {
  color: var(--ms-muted);
  text-decoration: none;
}

.ms-footer a:hover {
  text-decoration: underline;
  color: var(--ms-blue);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ms-right-panel {
    padding: 24px 16px 16px;
  }

  .ms-box {
    padding: 24px 20px;
  }

  .ms-btn-row {
    margin-top: 22px;
  }

  .ms-divider {
    margin: 22px 0 14px;
  }

  .ms-footer {
    padding: 16px 6px 0;
  }
}