/* ==========================================================================
   ALLAISHOP 2FA Local Authenticator Console (/2fa)
   Aligned with Apple Liquid Glass tokens & strict local-only privacy posture
   ========================================================================== */

.totp-page-main [hidden] {
  display: none !important;
}

.totp-page-main {
  padding-block: clamp(24px, 4vw, 44px) clamp(52px, 7vw, 84px);
}

.totp-shell {
  max-inline-size: 920px;
  margin-inline: auto;
}

/* Authenticator heading */
.totp-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-block-end: clamp(20px, 3vw, 28px);
}

.totp-header-copy h1 {
  color: var(--ink);
  font-size: clamp(1.78rem, 3vw, 2.38rem);
  letter-spacing: -0.032em;
}

/* 2. Primary Verification Workbench Surface (single flat surface, zero nested cards) */
.totp-workbench {
  border-radius: var(--radius-xl);
  padding: clamp(22px, 3.8vw, 38px);
  background: rgba(255, 255, 255, 0.97);
}

/* 3. Form & Auto-growing Textarea */
.totp-form {
  display: grid;
  gap: 14px;
}

.totp-field {
  display: grid;
  gap: 8px;
}

.totp-textarea {
  width: 100%;
  height: auto;
  field-sizing: content;
  min-block-size: 7.2lh;
  max-block-size: 15lh;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(18, 34, 60, 0.16);
  background: #f5f7fb;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.62;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.totp-textarea::placeholder {
  /* Contrast >= 4.9:1 on #f5f7fb */
  color: #566376;
  opacity: 1;
  font-family: var(--font-sans);
}

.totp-textarea:hover {
  border-color: rgba(18, 34, 60, 0.28);
}

.totp-textarea:focus {
  background: #ffffff;
  border-color: #066e5d;
  outline: 2px solid rgba(6, 110, 93, 0.45);
  outline-offset: 1px;
}

.totp-textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fffafa;
}

/* Actions and keyboard shortcut */
.totp-actions-wrap {
  display: grid;
  gap: 6px;
}

.totp-actions-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

.totp-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-block-size: 46px;
  padding: 10px 22px;
  border: 1px solid #05594b;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #077361 0%, #055b4d 100%);
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 720;
  box-shadow:
    0 8px 20px -6px rgba(5, 91, 77, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.26);
  transition: transform 140ms var(--ease-out-quart), background 140ms ease, box-shadow 140ms ease;
}

.totp-submit-btn:hover {
  background: linear-gradient(180deg, #066353 0%, #044d41 100%);
  box-shadow:
    0 12px 24px -6px rgba(5, 91, 77, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.totp-submit-btn:active {
  transform: translateY(1px);
}

.totp-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 88px;
  min-block-size: 46px;
  padding: 10px 18px;
  border: 1px solid rgba(18, 34, 60, 0.14);
  border-radius: var(--radius-sm);
  background: #eef2f7;
  color: var(--ink);
  font-size: 14px;
  font-weight: 660;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.totp-clear-btn:hover {
  background: #e3e9f2;
  border-color: rgba(18, 34, 60, 0.24);
}

.totp-shortcut-row {
  display: flex;
  justify-content: flex-end;
  color: var(--ink-muted);
  font-size: 12px;
}

.totp-error-banner {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(198, 42, 59, 0.26);
  background: #fdf2f3;
  color: #9e1c2b;
  font-size: 13.5px;
  font-weight: 600;
}

.totp-error-banner[hidden] {
  display: none;
}

.totp-error-banner svg {
  flex-shrink: 0;
  margin-block-start: 2px;
}

/* 4. Live OTP Output Stage */
.totp-output-stage {
  margin-block-start: 22px;
  padding-block-start: 22px;
  border-block-start: 1px solid var(--line-strong);
  display: grid;
  gap: 16px;
  animation: totp-stage-reveal 220ms var(--ease-out-quart);
}

.totp-output-stage[hidden] {
  display: none;
}

@keyframes totp-stage-reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.totp-readout-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 20px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: #f4faf8;
  border: 1px solid rgba(8, 122, 104, 0.22);
}

.totp-readout-bar.is-expiring {
  background: #fdf8ef;
  border-color: rgba(171, 95, 6, 0.28);
}

.totp-code-group {
  display: grid;
  gap: 4px;
}

.totp-code-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: #14594d;
  font-size: 12.5px;
  font-weight: 650;
}

.totp-readout-bar.is-expiring .totp-code-meta {
  color: #7c4303;
}

.totp-code-digits {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.1rem, 4.5vw, 2.85rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.04em;
  color: #064e41;
  user-select: all;
}

.totp-readout-bar.is-expiring .totp-code-digits {
  color: #8a4b04;
}

.totp-code-half {
  margin-inline-start: 0.28em;
}

.totp-readout-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Accessible Copy Button + Status Bubble (modern-web-guidance: copy-button) */
.totp-copy-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.totp-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-inline-size: 24px;
  min-block-size: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid #05594b;
  background: #066e5d;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 4px 12px -3px rgba(6, 110, 93, 0.28);
  transition: background-color 140ms ease, border-color 140ms ease;
}

.totp-copy-btn:hover {
  background: #066354;
}

.totp-copy-btn.is-secondary {
  min-block-size: 34px;
  padding: 5px 12px;
  border-color: rgba(18, 34, 60, 0.16);
  background: #ffffff;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  box-shadow: 0 2px 6px rgba(15, 28, 52, 0.05);
}

.totp-copy-btn.is-secondary:hover {
  background: #f1f5f9;
}

.totp-copy-btn .icon-check {
  display: none;
}

.totp-copy-btn[data-copied] .icon-copy {
  display: none;
}

.totp-copy-btn[data-copied] .icon-check {
  display: inline-flex;
}

.totp-copy-btn[data-copied].is-secondary {
  border-color: rgba(8, 122, 104, 0.36);
  color: #07594b;
  background: #ecf9f6;
}

.totp-copy-tip {
  position: absolute;
  inset-block-end: calc(100% + 7px);
  inset-inline-end: 0;
  padding: 4px 9px;
  border-radius: 7px;
  background: #141923;
  color: #ffffff;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 150ms ease, transform 150ms ease;
  box-shadow: 0 6px 16px rgba(15, 28, 52, 0.18);
}

.totp-copy-btn[data-copied] + .totp-copy-tip,
.totp-copy-btn[data-failed] + .totp-copy-tip {
  opacity: 1;
  transform: translateY(0);
}

.totp-copy-btn[data-failed] + .totp-copy-tip {
  background: #9e1c2b;
}

/* Countdown Progress Track */
.totp-timer-strip {
  display: grid;
  gap: 7px;
}

.totp-timer-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-secondary);
}

.totp-next-preview {
  color: #07594b;
  font-weight: 650;
}

.totp-next-preview[hidden] {
  display: none;
}

.totp-progress-track {
  inline-size: 100%;
  block-size: 6px;
  border-radius: var(--radius-pill);
  background: rgba(18, 34, 60, 0.09);
  overflow: hidden;
}

.totp-progress-fill {
  block-size: 100%;
  inline-size: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #087a68 0%, #10a37f 100%);
  transform-origin: left center;
  transform: scaleX(1);
  transition: background 200ms ease;
}

.totp-progress-fill.is-expiring {
  background: linear-gradient(90deg, #c26a07 0%, #e08214 100%);
}

/* Parsed Multi-Field Card Companion Rows (Account / Password / Backup Email) */
.totp-companion-box {
  display: grid;
  gap: 8px;
  padding-block-start: 12px;
  border-block-start: 1px dashed rgba(18, 34, 60, 0.13);
}

.totp-companion-box[hidden] {
  display: none;
}

.totp-companion-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.totp-companion-list {
  display: grid;
  gap: 8px;
}

.totp-companion-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  background: #f7f9fc;
  border: 1px solid var(--line);
}

.totp-companion-field {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-inline-size: 0;
  flex: 1 1 220px;
}

.totp-companion-label {
  color: var(--ink-muted);
  font-size: 12.5px;
  font-weight: 650;
  flex-shrink: 0;
}

.totp-companion-val {
  color: var(--ink);
  font-size: 13px;
  word-break: break-all;
}

.totp-pwd-readonly {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  min-inline-size: 12ch;
  max-inline-size: 100%;
  outline: none;
}

.totp-companion-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.totp-reference-links {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .totp-actions-row {
    grid-template-columns: 1fr;
  }

  .totp-shortcut-row {
    display: none;
  }

  .totp-readout-bar {
    padding: 15px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .totp-output-stage {
    animation: none;
  }

  .totp-copy-tip {
    transform: none;
    transition: opacity 120ms linear;
  }
}

/* Apple Authenticator Workbench */
body {
  background: #f5f5f7;
}

.totp-page-main {
  padding-block: clamp(34px, 5vw, 72px) clamp(60px, 8vw, 112px);
}

.totp-shell {
  max-inline-size: none;
  display: grid;
  grid-template-columns: minmax(0, 0.74fr) minmax(0, 1.26fr);
  align-items: start;
  gap: clamp(28px, 4.5vw, 76px);
}

.totp-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  padding-top: 6px;
  margin: 0;
}

.totp-header-copy {
  container-type: inline-size;
}

.totp-header-copy h1 {
  margin: 0;
  font-size: clamp(26px, 11cqi, 48px);
  line-height: 1.1;
  font-weight: 760;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.totp-local-detail {
  margin: 0;
  max-width: 24em;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--ink-secondary);
}

.totp-reference-links a {
  color: var(--brand);
  font-weight: 620;
  text-underline-offset: 4px;
}

.totp-workbench {
  border-radius: 24px;
  background: #ffffff;
  padding: clamp(22px, 3vw, 38px);
}

#totp-workbench-heading {
  margin: 0;
  font-size: clamp(20px, 1.8vw, 24px);
  letter-spacing: -0.025em;
}

#totp-format-hint {
  margin: 0 0 4px;
  color: var(--ink-secondary);
  font-size: 13.5px;
  line-height: 1.6;
}

.totp-textarea {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #f5f5f7;
}

.totp-submit-btn {
  border: 0;
  border-radius: var(--radius-pill);
  color: #ffffff;
  background: #0071e3;
  box-shadow: 0 4px 14px -4px rgba(0, 113, 227, 0.34);
}

.totp-submit-btn:hover {
  background: #0077ed;
}

.totp-clear-btn {
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: var(--radius-pill);
  background: #ffffff;
}

@media (max-width: 800px) {
  .totp-page-main {
    padding-block-start: 24px;
  }

  .totp-shell {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .totp-header {
    gap: 8px;
  }

  .totp-local-detail {
    font-size: 14px;
  }

  .totp-workbench {
    padding: 20px 16px;
    border-radius: 18px;
  }
}

@media (max-width: 600px) {
  .totp-actions-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}
