/* Shared components: buttons, fields, cards, spinners, step bars. */

.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:9px;
  font-family:var(--font-display);font-weight:800;font-size:15px;
  border:none;border-radius:11px;padding:14px 20px;cursor:pointer;
  background:var(--gold);color:var(--ink);letter-spacing:-.01em;
  transition:background .15s ease,opacity .15s ease;
}
.btn:hover:not(:disabled){background:#f2b95c}
.btn.btn-block{width:100%}
.btn.btn-dark{background:var(--green);color:var(--ink-on-dark);font-family:var(--font-body);font-weight:700}
.btn.btn-dark:hover:not(:disabled){background:#1a4a3d}
.btn.btn-outline{background:transparent;border:1.5px solid var(--border);color:var(--body)}
.btn.btn-outline:hover:not(:disabled){background:rgba(20,58,48,.04)}
/* Second CTA style alongside the plain gold .btn - green like .btn-dark, but
   with gold text instead of cream, for a lower-emphasis-than-primary action
   that still deserves more weight than a plain .btn-outline (e.g. "download
   key as a text file" next to the copy button). */
.btn.btn-secondary{background:var(--green);color:var(--gold);font-family:var(--font-body);font-weight:700}
.btn.btn-secondary:hover:not(:disabled){background:#1a4a3d}

/* Signature loader: two counter-rotating rings (gold outer, ink inner by
   default) rather than a generic single-ring browser-spinner look - carries
   the brand into a piece of UI most apps leave generic. One class now (was
   briefly also duplicated as .address-field-spinner - unified, see the
   templates). Sizes are literal per-tier overrides (.spinner-lg), not a
   single scaled --size multiplier - proportional scaling kept the exact same
   border:box ratio at every size, which reads as too thin at small sizes and
   too thick at large ones; hand-picking each tier's border-width instead
   (same approach as the reference this is based on) is what actually looks
   right at each size. --loader-color-1/2 get overridden per background
   wherever the default gold/ink pair would lose contrast - see .btn.btn-dark,
   the plain-gold .btn rule, and .confirm-row .btn-yes in client.css. */
.spinner{
  --loader-color-1:var(--gold);--loader-color-2:var(--ink);
  width:16px;height:16px;border-radius:50%;
  border:2px solid var(--loader-color-1);border-style:solid solid dotted dotted;
  display:none;position:relative;box-sizing:border-box;flex:none;
  animation:kd-loader-spin 2s linear infinite;
}
.spinner::after{
  content:'';box-sizing:border-box;position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;
  width:8px;height:8px;border-radius:50%;
  border:1px solid var(--loader-color-2);border-style:solid solid dotted;
  animation:kd-loader-spin-back 1s linear infinite;transform-origin:center center;
}
@keyframes kd-loader-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
@keyframes kd-loader-spin-back{from{transform:rotate(0deg)}to{transform:rotate(-360deg)}}

/* Larger tier - the "setting up your mailbox" processing wait (see
   .processing-spinner) is the one spot wanting a bigger, more prominent
   loader than every other (button-sized) use. */
.spinner.spinner-lg{width:28px;height:28px;border-width:3px}
.spinner.spinner-lg::after{width:14px;height:14px;border-width:2px}

.btn.btn-dark .spinner,.btn.btn-secondary .spinner{--loader-color-1:var(--gold);--loader-color-2:var(--cream)}
/* Plain gold .btn (the most common button style - Sign in, Continue, Save
   card...) is the one case the default gold-outer-ring reads *worse* than
   the old single ring did: gold-on-gold is nearly invisible. .btn-outline is
   excluded - its background is transparent/light, so the default colors
   (tuned for light backgrounds) are already right there. */
.btn:not(.btn-dark):not(.btn-outline):not(.btn-secondary) .spinner{--loader-color-1:var(--ink);--loader-color-2:#fff}
.htmx-request .spinner,.btn.is-loading .spinner{display:inline-block}
/* Standalone loaders that aren't gated behind .htmx-request/.is-loading (the
   processing-step wait, the post-submit success checkmark) show plainly via
   their own container class instead - see .processing-spinner and
   .detail-success-loader (client.css). */
.processing-spinner{display:flex;justify-content:center;padding:20px 0}
.processing-spinner .spinner{display:inline-block}
.htmx-request .btn-label,.btn.is-loading .btn-label{visibility:hidden;position:relative;flex:1}
.htmx-request .btn-label::after,.btn.is-loading .btn-label::after{content:attr(data-loading);visibility:visible;position:absolute;inset:0;display:flex;align-items:center;justify-content:center;white-space:nowrap}

label{display:block;font-weight:700;font-size:13px;margin-bottom:7px;color:var(--ink)}
label .req{color:var(--danger-btn)}
label .opt{font-weight:600;color:var(--muted);font-family:var(--font-mono);font-size:11px;letter-spacing:.04em}

/* Label + trailing counter/hint on one line (add-prepaid-code-modal.html's
   n/18) - the row carries the usual label-to-input gap so the label itself
   doesn't need its own margin. */
.field-label-row{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px}
.field-label-row label{margin-bottom:0}
.field-counter{font-family:var(--font-mono);font-size:11px;color:var(--muted);letter-spacing:.02em}

.field{margin-bottom:16px}
/* The password/confirm pair in .grid-2 (signup, add-mailbox) each carry the
   generic .field bottom margin as grid items, which pads out the grid row's
   own rendered height - invisible in devtools box-model since it's the
   fields' own margin, not something on .grid-2 itself. The strength meter
   sitting right after .grid-2 already provides its own top/bottom spacing,
   so this becomes a redundant extra gap - zero it here instead. Only
   matches .grid-2, not other unrelated field pairs (e.g. profile-modal's
   .locked-field grid uses a different class entirely). */
.grid-2 .field{margin-bottom:0}
input[type=text],input[type=email],input[type=password],input[type=tel],textarea{
  width:100%;border:1.5px solid var(--border);border-radius:10px;padding:13px 14px;
  font-size:15px;font-family:var(--font-body);background:#fff;color:var(--ink);
}
textarea{resize:vertical;min-height:80px}

/* Shared by every short-code entry field (login 2FA, email recovery code,
   recovery-2FA backup code) - centered, spaced-out, and a step bolder than a
   plain text field, same idea as .address-field's own bold-mono treatment
   but at a more modest size since these are short codes, not a full address. */
/* Qualified with the element type (input.code-field, not just .code-field)
   so its specificity actually ties the base input[type=text] rule above -
   a bare .code-field class alone loses that tie-break (a class beats a bare
   element selector, but input[type=text]'s extra attribute selector puts it
   ahead of a plain class), so font-family silently fell back to --font-body
   regardless of source order. Only the textarea variant (no attribute
   selector on its base rule) wasn't affected. */
input.code-field,textarea.code-field{
  font-family:var(--font-mono);font-weight:700;font-size:16px;
  letter-spacing:3px;text-align:center;
}
/* All 18 characters in (prepaid-code-field.js toggles this) - the same
   "you're done" signal the n/18 counter gives numerically. Plain rule, not
   !important, so .field-error's own !important border still wins if a
   full-length code turns out to be wrong on submit. */
input.code-field.is-complete{border-color:var(--success);box-shadow:0 0 0 3px rgba(47,122,79,.14)}
/* Its own dashed-bordered zone - the address field, its availability
   feedback, and the "can't be changed later" note all belong together as one
   unit, so they get one visibly-marked container instead of the note reading
   as an orphaned line floating under everything else. Slightly different
   background (--client-bg vs the modal card's --paper, and vs the idle
   availability-row's own --cream nested inside it) is what makes the zone
   readable at a glance, not just the dashed border. */
.field.address-group{
  margin-bottom:20px;padding:16px 16px 14px;
  border:1px dashed var(--border-fill);border-radius:14px;background:var(--client-bg);
}
.field.address-group label{margin-bottom:10px}
.field.address-group .hint{margin:10px 0 0;color:var(--muted-dim)}

.address-field{
  display:flex;align-items:stretch;border:1.5px solid var(--border-soft);border-radius:11px;
  overflow:hidden;background:#fff;
}
.address-field:focus-within{border-color:var(--gold)}
/* Mirrored here (and onto .availability-row below) from the JSON response's
   own valid flag - see public/js/modules/wizard-checks.js. Idle/checking
   need no override; they use this rule's own base border-soft color. */
.address-field.available{border-color:#a9d4b8}
.address-field.invalid{border-color:var(--danger-border)}
.address-field input{
  flex:1;border:none;background:transparent;padding:15px 16px;min-width:0;
  font-family:var(--font-mono);font-weight:700;font-size:18px;color:var(--ink);outline:none;
}
.address-field .suffix{
  display:flex;align-items:center;padding:0 17px;background:var(--input-fill);border-left:1.5px solid var(--border-fill);
  color:var(--body);font-family:var(--font-mono);font-weight:600;font-size:16px;white-space:nowrap;
}
/* .checking (not .htmx-request) - this field's live check is a plain
   jQuery $.ajax call now (core/api-client.js), not an htmx request, so
   wizard-checks.js toggles this class itself around the call. */
.checking.address-field{opacity:.7}

/* Availability result: a real feedback box, not a thin caption line - same
   idle/available/invalid state mirroring as .address-field above. */
.availability-row{
  display:flex;align-items:center;gap:10px;margin-top:10px;padding:11px 14px;
  border-radius:10px;border:1.5px solid var(--border-soft);background:var(--cream);
  color:var(--body);font-size:13.5px;font-weight:600;min-height:16px;
}
.availability-row.available{background:#eaf4ee;border-color:#a9d4b8;color:var(--success)}
.availability-row.invalid{background:var(--danger-bg);border-color:var(--danger-border);color:var(--danger-btn)}
/* flex:1 + min-width:0 on both this and .availability below just lets the
   box shrink to the row's actual width (a flex item's default min-width is
   auto, i.e. never shrinks below its content) - the text itself wraps onto
   a second line instead of being cut off, see .availability-text below. */
#availability-result{flex:1;min-width:0}

.address-field.checking ~ .availability-row .spinner{display:inline-block}
.address-field.checking ~ .availability-row #availability-result{visibility:hidden}

/* Shown next to the spinner while a check is in flight - the spinner alone
   didn't say what it was doing, just that something was happening. */
.availability-checking-label{display:none}
.address-field.checking ~ .availability-row .availability-checking-label{display:inline}

.password-field{
  display:flex;align-items:stretch;border:1.5px solid var(--border);border-radius:10px;
  overflow:hidden;background:#fff;
}
.password-field:focus-within{border-color:var(--gold)}
.password-field input{flex:1;border:none;background:transparent;padding:13px 14px;font-size:15px;font-family:inherit;color:var(--ink);min-width:0;outline:none}
.password-field .eye{flex:none;display:flex;align-items:center;background:transparent;border:none;cursor:pointer;color:var(--muted);padding:0 12px}
.password-field .eye:hover{color:var(--body)}

.hint{font-size:12px;color:var(--body);min-height:15px;margin:6px 0 0}
.hint.error{color:var(--danger-btn)}

.password-strength{margin-top:10px;margin-bottom:16px}
.password-strength .alert{margin:10px 0 0}
.password-strength-grid{display:flex;border-radius:10px;overflow:hidden}
.password-strength-cell{
  flex:1;display:flex;flex-direction:column;align-items:center;gap:4px;
  padding:9px 4px;background:var(--border-soft);color:var(--muted);
  transition:background-color .15s ease,color .15s ease;
}
.password-strength-cell i{font-size:12px}
.password-strength-cell span{font-size:10.5px;font-weight:600;text-align:center;line-height:1.2}
.password-strength-cell.met{background:var(--success);color:#fff}

/* Text color/size/weight come from .availability-row's own state styling
   above (inherited) - this is just the layout for the optional checkmark.
   flex-start (not center) so the checkmark sits against the first line once
   a long message wraps, instead of floating oddly centered between lines. */
.availability{display:flex;align-items:flex-start;gap:8px;min-width:0}
.availability-check{
  flex:none;width:19px;height:19px;border-radius:50%;background:var(--success);color:#fff;
  display:inline-flex;align-items:center;justify-content:center;font-size:10px;font-weight:800;
}
/* Wraps onto additional lines instead of truncating with an ellipsis - the
   row's own height simply grows to fit (min-height above is a floor, not a
   cap), rather than hiding part of the message. */
.availability-text{min-width:0}

/* Inline alerts - a dedicated icon compartment (its own background tint) plus
   a text compartment, rather than an inline glyph sharing the same flat
   background as the message - the old .error-banner/.notice-banner read as
   "invisible/lightweight" precisely because nothing set the icon apart from
   the text. Two real child elements (.alert-icon/.alert-text), not a
   ::before pseudo-element - a flex container's own raw text content becomes
   an anonymous box that can't be targeted with flex:1, so the text needs a
   real wrapping element to fill the remaining width correctly. */
.alert{display:flex;align-items:stretch;border-radius:10px;overflow:hidden;margin-bottom:16px;font-size:13.5px;line-height:1.5}

/* Generic JS-driven show/hide - CLAUDE.md's ".show class, not inline styles"
   convention, but as a "hide" modifier instead: elements that are visible by
   default in their own CSS just need this added/removed, whatever their
   normal display value is - !important so it always wins regardless of
   stylesheet order (e.g. .alert{display:flex} above). */
.hidden{display:none!important}
.alert-icon{flex:none;width:38px;display:flex;align-items:center;justify-content:center;font-size:15px}
.alert-text{flex:1;min-width:0;padding:11px 14px}

.alert-error{background:var(--danger-bg);color:var(--danger-text);border:1px solid rgba(192,74,53,.35)}
.alert-error .alert-icon{background:rgba(192,74,53,.16);color:var(--danger-btn)}

.alert-warning{background:rgba(227,166,58,.12);color:var(--gold-deep);border:1px solid rgba(227,166,58,.4)}
.alert-warning .alert-icon{background:rgba(227,166,58,.26);color:var(--gold-deep)}

.alert-success{background:rgba(47,122,79,.1);color:var(--success);border:1px solid rgba(47,122,79,.35)}
.alert-success .alert-icon{background:rgba(47,122,79,.22);color:var(--success)}

.alert-info{background:var(--input-fill);color:var(--body-dim);border:1px solid var(--border-fill)}
.alert-info .alert-icon{background:var(--border-fill);color:var(--body)}

.alert-dismiss{background:none;border:none;cursor:pointer;color:inherit;opacity:.6;font-size:18px;line-height:1;padding:0 14px}
.alert-dismiss:hover{opacity:1}

#recover-totp-field .alert{margin-top:10px}

.totp-qr{display:flex;justify-content:center;margin:4px 0}
.totp-qr svg{max-width:180px;height:auto;border:1px solid var(--border);border-radius:9px;padding:10px;background:#fff}

.card{
  background:var(--paper);border-radius:20px;padding:32px;width:100%;
  box-shadow:0 40px 90px rgba(0,0,0,.16);animation:kd-fade .3s ease;
}

/* modals — shared by the landing page's signup and the dashboard */
.modal-backdrop{position:fixed;inset:0;z-index:150;background:rgba(11,32,26,.62);backdrop-filter:blur(4px);display:none;align-items:center;justify-content:center;padding:24px}
.modal-backdrop.open{display:flex}
.modal-backdrop .card{max-width:460px;max-height:90vh;overflow:auto;position:relative}
/* Narrower than the 460px modal default - login only. */
.modal-backdrop .card.auth-card-sm{max-width:400px}
.modal-close{position:absolute;top:20px;right:20px;background:transparent;border:none;color:var(--muted);cursor:pointer;font-size:18px;line-height:1;padding:4px}
.modal-close:hover{color:var(--body)}

/* Every modal card's .step-bar sits next to a .modal-close × button and
   needs room for it - scoped here instead of repeating the same inline
   margin on every wizard (signup, add-mailbox). */
.modal-backdrop .step-bar{margin-right:26px}

/* Full-screen modals on mobile - a 90vh card floating with margin on every
   side reads as a cramped popup, not a page. Several modal cards set their
   own inline max-width (e.g. update-card-modal.html's 420px) which always
   beats an external stylesheet rule regardless of selector specificity, so
   max-width needs !important here to actually win on mobile. */
@media (max-width:640px){
  .modal-backdrop{padding:0}
  .modal-backdrop .card{
    max-width:none !important;width:100%;height:100%;max-height:none;
    border-radius:0;
    padding-top:calc(32px + env(safe-area-inset-top));
    padding-bottom:calc(32px + env(safe-area-inset-bottom));
  }
  .modal-close{top:calc(20px + env(safe-area-inset-top))}
}

.card-element-mount{border:1.5px solid var(--border);border-radius:10px;padding:13px 14px;background:#fff}
.card-element-mount.StripeElement--focus{border-color:var(--gold)}
.card-element-mount.StripeElement--invalid{border-color:var(--danger-btn)}

.step-bar{display:flex;align-items:center;gap:8px;margin-bottom:16px}
.step-bar span{flex:1;height:4px;border-radius:2px;background:var(--border-soft)}
.step-bar span.done,.step-bar span.active{background:var(--gold)}
.step-label{font-family:var(--font-mono);font-size:11px;letter-spacing:.16em;text-transform:uppercase;color:var(--gold-deep);margin-bottom:16px}

.step{display:none;overflow:hidden}
.step.active{display:block}
.step.active.dir-forward{animation:kd-step-in-forward .3s ease}
.step.active.dir-back{animation:kd-step-in-back .3s ease}
@keyframes kd-step-in-forward{
  from{opacity:0;transform:translateX(28px)}
  to{opacity:1;transform:translateX(0)}
}
@keyframes kd-step-in-back{
  from{opacity:0;transform:translateX(-28px)}
  to{opacity:1;transform:translateX(0)}
}

.step-actions{display:flex;gap:10px;margin-top:36px}
.step-actions .btn-outline{flex:none}
.step-actions .btn:last-child{flex:1}
/* A lone full-width Continue (step 1, no Back button yet) sits right under
   a .hint paragraph and reads as cramped without the extra gap a paired
   Back+Continue row already gets from its own two different-width buttons. */
.step-actions .btn-block{margin-top:16px}

/* Modal/step header - h2 title + descriptive subtitle, identical markup
   shape whether it's a single-view card (login) or one step of a wizard
   (signup, add-mailbox, recovery). */
.modal-title{font-size:22px;margin-bottom:6px}
.modal-subtitle{color:var(--body);font-size:14px;line-height:1.5;margin:0 0 22px}
/* Used when the element right below already carries its own visual
   separation (a summary card, a recovery-key box) and the full 22px would
   just be extra dead space. */
.modal-subtitle--tight{margin-bottom:18px}

.hint-centered{text-align:center;margin-bottom:4px}

/* The dynamically-filled address shown in a wizard's recovery-key reveal
   step (e.g. "ahmed@kurd.im if the password is forgotten"). */
.recovery-address{font-family:var(--font-mono);color:var(--ink)}

.recovery-key-download{margin:12px 0 18px}

.field.field-error input,
.field.field-error .address-field,
.field.field-error .password-field{
  border-color:var(--danger-btn) !important;
  box-shadow:0 0 0 3px rgba(192,74,53,.14) !important;
}
.field.field-error{animation:field-shake .4s ease}
@keyframes field-shake{
  10%,90%{transform:translateX(-1px)}
  20%,80%{transform:translateX(2px)}
  30%,50%,70%{transform:translateX(-4px)}
  40%,60%{transform:translateX(4px)}
}

/* Toast - reads ?success=/?notice=/?error= off the URL on load
   (client.js/admin.js), shows one of these, then strips the param from the
   URL either way. Success auto-dismisses (doesn't need to stick around);
   error stays until manually closed, since it's often something that still
   needs acting on - same reasoning .alert-error has always had, just floating
   instead of pinned to the top of a possibly-scrolled page. */
.toast-container{position:fixed;top:20px;right:20px;z-index:200;display:flex;flex-direction:column;gap:10px;max-width:360px}
.toast{display:flex;align-items:stretch;border-radius:10px;overflow:hidden;background:var(--paper);box-shadow:0 14px 34px rgba(11,32,26,.22);animation:kd-toast-in .25s ease}
.toast.closing{animation:kd-toast-out .2s ease forwards}
.toast-success{border:1px solid rgba(47,122,79,.35)}
.toast-success .toast-icon{background:rgba(47,122,79,.18);color:var(--success)}
.toast-error{border:1px solid rgba(192,74,53,.35)}
.toast-error .toast-icon{background:rgba(192,74,53,.16);color:var(--danger-btn)}
.toast-icon{flex:none;width:38px;display:flex;align-items:center;justify-content:center;font-size:15px}
.toast-text{flex:1;min-width:0;padding:12px 14px;font-size:13.5px;color:var(--ink);line-height:1.45}
.toast-close{flex:none;background:none;border:none;color:var(--muted);cursor:pointer;padding:10px 12px;font-size:14px;align-self:flex-start}
.toast-close:hover{color:var(--body)}
@keyframes kd-toast-in{from{opacity:0;transform:translateX(24px)}to{opacity:1;transform:translateX(0)}}
@keyframes kd-toast-out{to{opacity:0;transform:translateX(24px)}}
@media (max-width:600px){
  .toast-container{left:12px;right:12px;top:12px;max-width:none}
}
