/* First-run setup wizard (templates/setupwizard/*), loaded through {% block extra_css %}.
   Builds on app.css: colours and spacing come from its variables, so dark mode works too. */

/* ---------- page frame ---------- */
.wizard-top-inner { max-width: 920px; margin: 0 auto; padding: 1.1rem 1.25rem .2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.wizard-brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.wizard-brand img { flex: none; display: block; }
.wizard-brand .brand-name { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.wizard-brand .brand-sub { color: var(--muted); opacity: 1; font-size: .78rem; }
.wizard-top-right { display: flex; align-items: center; gap: .75rem; }
.wizard-badge { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--primary); background: var(--primary-soft); padding: .28rem .7rem; border-radius: 999px; white-space: nowrap; }
.wizard-user { display: flex; align-items: center; gap: .45rem; font-size: .88rem; color: var(--text-2); }
.wizard-user .avatar { width: 28px; height: 28px; font-size: .8rem; }
.wizard-main { padding: 1rem 1.25rem 2rem; }
.wizard-main > .flash-stack, .wizard-shell { max-width: 880px; margin-left: auto; margin-right: auto; }
.wizard-main > .flash-stack { margin-bottom: 1rem; }
.wizard-footer { max-width: 880px; margin: 0 auto; padding: 0 1.25rem 1.75rem; }

/* ---------- stepper ---------- */
.wizard-progress { margin: .6rem 0 1.25rem; }
.wizard-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.wizard-step { position: relative; text-align: center; }
/* the line that joins a step to the one before it */
.wizard-step::before { content: ""; position: absolute; z-index: 0; top: 15px; right: 50%; width: 100%; height: 2px; background: var(--border-strong); }
.wizard-step:first-child::before { display: none; }
.wizard-step.is-done::before, .wizard-step.is-current::before, .wizard-step.is-skipped::before { background: var(--ok); }
.wizard-step-link { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: .4rem; color: var(--muted); font-size: .8rem; font-weight: 600; line-height: 1.25; padding: 0 .15rem; border-radius: var(--radius-sm); }
a.wizard-step-link:hover { text-decoration: none; color: var(--primary); }
a.wizard-step-link:hover .wizard-dot { border-color: var(--primary); }
.wizard-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border-strong); color: var(--muted); font-weight: 700; font-size: .88rem; transition: border-color .15s; }
.wizard-dot svg { display: block; width: 16px; height: 16px; }
.is-done .wizard-step-link { color: var(--text-2); }
.is-done .wizard-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.is-skipped .wizard-dot { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.is-current .wizard-step-link { color: var(--text); font-weight: 700; }
.is-current .wizard-dot { background: var(--primary); border-color: var(--primary); color: var(--primary-text); box-shadow: 0 0 0 4px var(--primary-soft); }

/* ---------- card ---------- */
.wizard-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.wizard-card-head { padding: 1.75rem 2rem 0; }
.wizard-card-head .eyebrow { color: var(--primary); }
.wizard-card-head h1 { font-size: 1.5rem; margin-bottom: .45rem; }
.wizard-lead { color: var(--text-2); font-size: 1rem; max-width: 70ch; margin: 0; }
.wizard-card-body { padding: 1.5rem 2rem 1.75rem; }
.wizard-card-body > .alert:first-child { margin-top: 0; }
.wizard-h2 { font-size: 1.12rem; margin-bottom: .3rem; }
.wizard-h3 { font-size: 1.04rem; margin-bottom: .35rem; }
.wizard-h4 { font-size: .97rem; margin-bottom: .45rem; }
.wizard-card-body .alert { margin-bottom: 1rem; }
.wizard-eyebrow-setup { display: none; }

/* bottom row: Back on the left, the main button on the right */
.wizard-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.wizard-actions-right { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-left: auto; }
.wizard-actions-back { border-top: 0; padding-top: 0; margin-top: 1rem; }
.wizard-default-submit { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

.wizard-note { display: flex; gap: .6rem; align-items: flex-start; font-size: .88rem; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .65rem .85rem; margin: .5rem 0 0; }
.wizard-note-icon { flex: none; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--info); color: #fff; font: italic 700 .8rem/1 Georgia, "Times New Roman", serif; display: grid; place-items: center; margin-top: .05rem; }

/* ---------- step 1: welcome ---------- */
.wizard-split { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 2rem; align-items: start; }
.wizard-split-side { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.wizard-needs { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .8rem; font-size: .9rem; color: var(--text-2); }
.wizard-needs li { display: flex; gap: .65rem; align-items: flex-start; }
.wizard-needs strong { color: var(--text); }
.wizard-need-icon { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .78rem; display: grid; place-items: center; }
.field input.setup-code-input { font-family: var(--mono); font-size: 1.35rem; letter-spacing: .14em; text-transform: uppercase; text-align: center; padding: .7rem .9rem; max-width: 380px; }
.field input.setup-code-input::placeholder { color: var(--border-strong); }
.wizard-code-form .field { max-width: 380px; }
.wizard-code-form .wizard-actions { border-top: 0; padding-top: 0; margin-top: 1rem; justify-content: flex-start; }
.wizard-code-form .wizard-actions > span:empty { display: none; }
.wizard-hint { margin-top: 1.4rem; font-size: .92rem; }
.wizard-hint summary, .wizard-advanced summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.wizard-hint[open] summary { margin-bottom: .5rem; }
.wizard-command { display: flex; align-items: center; gap: .75rem; background: #0e1621; border-radius: var(--radius-sm); padding: .55rem .55rem .55rem 1rem; margin: .6rem 0 0; }
.wizard-command code { flex: 1; min-width: 0; font-size: .95rem; color: #e6edf5; white-space: nowrap; }
.wizard-command code::before { content: "$ "; color: #7f8ea3; }

/* ---------- step 3: two-factor ---------- */
.wizard-substeps { list-style: none; counter-reset: wizard-substep; margin: 0; padding: 0; }
.wizard-substeps > li { counter-increment: wizard-substep; position: relative; padding: 0 0 1.4rem 2.85rem; }
.wizard-substeps > li + li { border-top: 1px solid var(--border); padding-top: 1.25rem; }
.wizard-substeps > li:last-child { padding-bottom: 0; }
.wizard-substeps > li::before {
  content: counter(wizard-substep); position: absolute; left: 0; top: -.15rem; width: 1.95rem; height: 1.95rem;
  border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700;
}
.wizard-substeps > li + li::before { top: 1.1rem; }
.wizard-qr { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.wizard-qr-manual { flex: 1; min-width: 220px; }
.wizard-key { font-family: var(--mono); font-size: 1rem; letter-spacing: .04em; }
.wizard-totp-form { max-width: 340px; }
.wizard-totp-form .field { margin-bottom: .9rem; }
.wizard-done-box { display: flex; gap: 1rem; align-items: flex-start; background: var(--ok-soft); border-radius: var(--radius); padding: 1rem 1.2rem; }
.wizard-done-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; }
.wizard-done-icon svg { display: block; }

/* recovery codes */
.wizard-codes-box { border: 1px solid var(--border); border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius); padding: 1rem 1.25rem; }
.wizard-codes.codebox { max-width: 560px; background: var(--surface); margin: .6rem 0 .75rem; padding: 1rem 1.25rem; font-size: 1.05rem; letter-spacing: .03em; word-break: normal; }
.wizard-codes span { white-space: nowrap; }
.wizard-codes-tools { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }

/* ---------- step 4: company ---------- */
.wizard-company .field, .wizard-preview { max-width: 600px; }
.wizard-preview { margin: .25rem 0 0; }
.wizard-preview-label { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .35rem; }
.wizard-preview-bar { display: flex; align-items: center; gap: .6rem; background: var(--topbar); color: var(--topbar-text); border-radius: var(--radius-sm); padding: .65rem .9rem; }
.wizard-preview-bar img { flex: none; display: block; }
.wizard-preview-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.wizard-preview-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wizard-preview-sub { font-size: .75rem; opacity: .75; }

/* ---------- step 5: ICEGATE and email ---------- */
.wizard-section { padding-top: 1.35rem; margin-top: 1.35rem; border-top: 1px solid var(--border); }
.wizard-section-first { padding-top: 0; margin-top: 0; border-top: 0; }
.wizard-section-title { display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; margin-bottom: 1rem; }
.wizard-section-num { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--primary); color: var(--primary-text); display: grid; place-items: center; font-size: .85rem; font-weight: 700; }
.wizard-saved { display: flex; align-items: center; gap: .45rem; font-size: .86rem; font-weight: 600; color: var(--ok); margin: -.55rem 0 1rem; }
.wizard-saved-icon { flex: none; width: 1.15rem; height: 1.15rem; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: .7rem; font-weight: 800; }
.wizard-help-box { background: var(--info-soft); border-left: 4px solid var(--info); border-radius: var(--radius-sm); padding: .9rem 1.1rem; margin: .25rem 0 1rem; }
.wizard-help-steps { margin: 0 0 .55rem; padding-left: 1.25rem; font-size: .92rem; }
.wizard-help-steps li + li { margin-top: .25rem; }
.wizard-help-box a { font-weight: 600; overflow-wrap: anywhere; }
.wizard-advanced { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .65rem .9rem; margin-bottom: 1rem; font-size: .95rem; }
.wizard-advanced[open] summary { margin-bottom: .85rem; }
.wizard-advanced-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: 0 1rem; }
.wizard-advanced-grid .field { margin-bottom: .6rem; }
.wizard-test .alert { margin-bottom: .8rem; }
.wizard-test-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.wizard-confirm-field { max-width: 380px; }

/* ---------- step 6: documents ---------- */
.wizard-table-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wizard-doc-table th:first-child, .wizard-doc-table td:first-child { padding-left: 1.1rem; }
.wizard-doc-table th:last-child, .wizard-doc-table td:last-child { padding-right: 1.1rem; }
.wizard-doc-desc { display: block; font-size: .84rem; color: var(--muted); }
.wizard-filename { font-family: var(--mono); font-size: .86rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: .1rem .4rem; white-space: nowrap; color: var(--text); }
.wizard-doc-table tr.is-off td { color: var(--muted); }
.wizard-doc-table tr.is-off .wizard-filename, .wizard-doc-table tr.is-off code { opacity: .65; }
.wizard-doc-note { text-align: right; }
.wizard-doc-table th { white-space: nowrap; }
.wizard-shared-list { list-style: none; margin: 0 0 .75rem; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.wizard-shared { display: flex; justify-content: space-between; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; background: var(--surface-2); }
.wizard-shared-info { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; min-width: 0; }
.wizard-shared-status { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.wizard-upload { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.wizard-upload input[type=file] { font: inherit; font-size: .85rem; color: var(--text-2); max-width: 270px; }
.wizard-upload input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; padding: .32rem .7rem; margin-right: .6rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
}

/* ---------- step 7: invite and finish ---------- */
.wizard-copy-row { display: flex; gap: .6rem; align-items: stretch; flex-wrap: wrap; }
.wizard-link { flex: 1 1 280px; min-width: 0; display: flex; align-items: center; font-family: var(--mono); font-size: .95rem; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .55rem .85rem; overflow-wrap: anywhere; }
.wizard-message { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1.1rem; font-size: .92rem; line-height: 1.55; overflow-wrap: anywhere; }
.wizard-copy-actions { margin-top: .6rem; }
.wizard-next { margin: 0; padding-left: 1.3rem; color: var(--text-2); }
.wizard-next li + li { margin-top: .4rem; }
.wizard-summary li { border-bottom: 1px solid var(--border); padding: .55rem 0; }
.wizard-summary li:last-child { border-bottom: 0; }
.wizard-finish-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.6rem; }
.wizard-option { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; background: var(--surface-2); }
.wizard-option:first-child { border-color: var(--primary); background: var(--primary-soft); }
.wizard-option.is-disabled { border-color: var(--border); background: var(--surface-2); }
.wizard-option p { flex: 1; }
.wizard-option .wizard-h4 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.wizard-option .btn-block { white-space: normal; text-align: center; }

/* Off-screen helper for copying text without the clipboard API (setupwizard-wizard.js). */
.wizard-copy-helper { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  .wizard-split { grid-template-columns: 1fr; gap: 1.25rem; }
  .wizard-finish-options { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .wizard-top-inner { padding: .85rem 1rem .1rem; flex-wrap: nowrap; }
  .wizard-brand .brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wizard-brand > div { min-width: 0; }
  .wizard-user-name, .wizard-badge { display: none; }
  .wizard-eyebrow-setup { display: inline; }
  .wizard-main { padding: .75rem 1rem 1.5rem; }
  .wizard-footer { padding: 0 1rem 1.5rem; }
  .wizard-progress { margin: .4rem 0 1rem; }
  .wizard-step-title { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
  .wizard-step::before { top: 13px; }
  .wizard-dot { width: 28px; height: 28px; font-size: .8rem; }
  .is-current .wizard-dot { box-shadow: 0 0 0 3px var(--primary-soft); }
  .wizard-card { border-radius: 12px; }
  .wizard-card-head { padding: 1.25rem 1.1rem 0; }
  .wizard-card-head h1 { font-size: 1.3rem; }
  .wizard-lead { font-size: .95rem; }
  .wizard-card-body { padding: 1.15rem 1.1rem 1.35rem; }
  .wizard-actions { flex-direction: column-reverse; align-items: stretch; }
  .wizard-actions > span:empty { display: none; }
  .wizard-actions .btn, .wizard-actions-right { width: 100%; }
  .wizard-actions-right { flex-direction: column-reverse; align-items: stretch; margin-left: 0; }
  .wizard-code-form .wizard-actions .btn { width: 100%; }
  .wizard-substeps > li { padding-left: 2.4rem; }
  .wizard-qr .qr svg { width: 180px; height: 180px; }
  .wizard-advanced-grid { grid-template-columns: 1fr; }
  .wizard-command { flex-wrap: wrap; padding-left: .8rem; }
  .wizard-command code { font-size: .86rem; }
  .wizard-test-row .btn { width: 100%; }
  .wizard-copy-row .btn { width: 100%; }

  /* documents table: one block per document */
  .wizard-doc-table thead { display: none; }
  .wizard-doc-table, .wizard-doc-table tbody, .wizard-doc-table tr { display: block; width: 100%; }
  .wizard-doc-table tr { padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
  .wizard-doc-table tbody tr:last-child { border-bottom: 0; }
  .wizard-doc-table td, .wizard-doc-table td:first-child, .wizard-doc-table td:last-child { display: flex; gap: .75rem; align-items: baseline; padding: .15rem 0; border: 0; text-align: left; }
  .wizard-doc-table td:first-child { display: block; padding-bottom: .3rem; }
  .wizard-doc-table td[data-label]::before { content: attr(data-label); flex: 0 0 5.6rem; font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
  .wizard-doc-table td:first-child::before { display: none; }
  .wizard-doc-table td.wizard-doc-note:empty { display: none; }
  .wizard-doc-table .wizard-filename { white-space: normal; overflow-wrap: anywhere; }
  .wizard-upload, .wizard-upload input[type=file] { width: 100%; max-width: none; }
}

@media (max-width: 480px) {
  /* Two columns of recovery codes do not fit next to each other on a phone. */
  .wizard-codes.code-grid { grid-template-columns: 1fr; padding: .8rem 1rem; font-size: 1rem; }
  .wizard-codes-box { padding: .9rem 1rem; }
}

/* ---------- printing the recovery codes ---------- */
@media print {
  .wizard-top, .wizard-progress, .wizard-actions, .wizard-codes-tools, .flash-stack, .footer, .auth-footer, .skip-link { display: none !important; }
  .auth-page { background: #fff; }
  .wizard-card { box-shadow: none; border: 0; }
  .wizard-codes-box { background: #fff; border: 1px solid #999; }
}
