/* Kasbman tool kit — the design system the tool pages build their shared UI
   from: the action bar under every result, the two standard forms, their
   modals and the toast.

   The eight tools were authored separately and each grew its own version of
   these. Everything here is a .kb-* class living OUTSIDE .tool-body, so it
   takes its tokens from site-shell.css and looks the same on all of them,
   whatever the tool's own stylesheet does. Load order on a tool page is
   site-shell.css, this, then the tool's own sheet. */

.tool-page { background: var(--background); }
.tool-page #main { padding-block: 1.5rem 3rem; }
@media (min-width: 768px) { .tool-page #main { padding-block: 2.5rem 4rem; } }

/* The tool document paints its own card; centre it in the page. */
.tool-body { width: min(100%, 48rem); margin-inline: auto; }

/* ---- buttons ------------------------------------------------------------ */

.kb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.75rem; padding: .625rem 1.125rem;
  border: 1px solid var(--border); border-radius: .625rem;
  background: #fff; color: var(--foreground);
  font-family: var(--font); font-size: .9375rem; font-weight: 700; line-height: 1.4;
  cursor: pointer; transition: background-color .15s, border-color .15s, box-shadow .15s, transform .15s;
}
.kb-btn:hover { border-color: var(--primary-40); box-shadow: var(--shadow-sm); }
.kb-btn:active { transform: translateY(1px); }
.kb-btn[disabled] { opacity: .6; cursor: default; transform: none; }

.kb-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.kb-btn-primary:hover { background: hsl(216.5 85% 28%); border-color: hsl(216.5 85% 28%); }

.kb-btn-gold { background: var(--gold); border-color: var(--gold); color: var(--primary); font-weight: 900; }
.kb-btn-gold:hover { background: var(--gold-90); border-color: var(--gold-90); }

.kb-btn-ghost { background: transparent; border-color: transparent; color: var(--muted-foreground); font-weight: 500; }
.kb-btn-ghost:hover { background: var(--accent); color: var(--primary); box-shadow: none; }

.kb-btn-block { width: 100%; }
.kb-btn .ti { font-size: 1.125rem; line-height: 1; }

/* ---- the action bar under a result -------------------------------------- */

.kb-actions { display: grid; gap: .75rem; margin-top: 1.5rem; align-items: start; }
@media (min-width: 480px) { .kb-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kb-actions .kb-btn { width: 100%; white-space: normal; text-align: center; line-height: 1.6; }
.kb-action-main { display: flex; flex-direction: column; gap: .375rem; }
.kb-action-note { font-size: .8125rem; line-height: 1.8; color: var(--muted-foreground); text-align: center; }

.kb-back { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }

/* ---- fields ------------------------------------------------------------- */

.kb-field { display: grid; gap: .375rem; }
.kb-label { font-size: .875rem; font-weight: 700; color: var(--foreground); }
.kb-label span { font-weight: 500; color: var(--muted-foreground); }

.kb-input, .kb-textarea, .kb-select {
  width: 100%; padding: .625rem .75rem;
  border: 1px solid var(--border); border-radius: .5rem;
  background: #fff; color: var(--foreground);
  font-family: var(--font); font-size: .9375rem; line-height: 1.6;
}
.kb-input:focus, .kb-textarea:focus, .kb-select:focus {
  outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px var(--primary-10);
}
.kb-input[aria-invalid="true"] { border-color: hsl(0 65% 48%); }
.kb-textarea { min-height: 6rem; resize: vertical; }
.kb-input[dir="ltr"] { text-align: left; }

.kb-grid-2 { display: grid; gap: .875rem; }
@media (min-width: 560px) { .kb-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.kb-error { font-size: .8125rem; font-weight: 500; color: hsl(0 65% 40%); }
.kb-error:empty { display: none; }

.kb-note { font-size: .8125rem; line-height: 1.9; color: var(--muted-foreground); }

/* The honeypot: present for a bot, invisible and unreachable for a person. */
.kb-honeypot { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- modal -------------------------------------------------------------- */

/* The modals and the toast must clear every layer a tool draws. Several
   tools open their result as a fixed full-screen page (b2b-sales at 1000,
   others up to 3200); at the old 100 the modals opened behind it and the
   buttons looked dead. */
.kb-modal {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 1rem; background: rgb(11 31 51 / .55);
}
@media (min-width: 560px) { .kb-modal { align-items: center; } }
.kb-modal[hidden] { display: none; }

.kb-modal-card {
  width: min(100%, 30rem); max-height: calc(100dvh - 2rem); overflow-y: auto;
  background: #fff; border-radius: 1rem; box-shadow: var(--shadow-xl);
  padding: 1.25rem;
}
@media (min-width: 560px) { .kb-modal-card { padding: 1.5rem; } }

.kb-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .25rem; }
.kb-modal-title { font-size: 1.0625rem; font-weight: 900; line-height: 1.6; color: var(--foreground); }
.kb-modal-sub { margin-top: .375rem; font-size: .8125rem; line-height: 1.9; color: var(--muted-foreground); }
.kb-modal-close {
  flex: 0 0 auto; width: 2rem; height: 2rem; border: 0; border-radius: .5rem;
  background: var(--muted); color: var(--muted-foreground); font-size: 1.125rem; line-height: 1; cursor: pointer;
}
.kb-modal-close:hover { background: var(--accent); color: var(--primary); }
.kb-modal-body { display: grid; gap: .875rem; margin-top: 1.125rem; }
.kb-modal-actions { display: grid; gap: .625rem; margin-top: 1.25rem; }
@media (min-width: 560px) { .kb-modal-actions { grid-template-columns: 1fr auto; } }

/* ---- toast -------------------------------------------------------------- */

.kb-toast-host {
  position: fixed; inset-block-end: 1rem; inset-inline: 1rem; z-index: 10100;
  display: grid; gap: .5rem; justify-items: center; pointer-events: none;
}
.kb-toast {
  max-width: 28rem; padding: .75rem 1.125rem;
  border-radius: .75rem; box-shadow: var(--shadow-lg);
  background: var(--primary); color: #fff;
  font-family: var(--font); font-size: .875rem; font-weight: 700; line-height: 1.7; text-align: center;
  opacity: 0; transform: translateY(.5rem); transition: opacity .2s, transform .2s;
}
.kb-toast.is-visible { opacity: 1; transform: none; }
.kb-toast-ok { background: hsl(145 55% 26%); }
.kb-toast-error { background: hsl(0 60% 38%); }
@media (prefers-reduced-motion: reduce) { .kb-toast { transition: none; } }

/* ---- question forms (see decorateForms in tool-kit.js) ----
   Every second answer is tinted so a long list does not read as one block;
   a chosen answer keeps the tool's own highlight. The durability tool draws
   its answer on a label after a hidden radio, so its tint goes there.
   The badge is scoped to .tool-body to outweigh each tool's own reset. */
.tool-body .kb-alt:not(.selected):not(.choice) { background-color: #F3F8FD; }
.tool-body .choice.kb-alt input:not(:checked) + label { background-color: #F3F8FD; }
.tool-body .kb-qnum {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.5rem; height: 1.5rem; padding: 0 .375rem; margin-inline-end: .5rem;
  border-radius: 999px; background: var(--primary); color: #fff;
  font-size: .75rem; font-weight: 800; line-height: 1; vertical-align: .1em;
}

.kb-modal-footnote { margin-top: .875rem; padding-top: .75rem; border-top: 1px solid var(--border); font-size: .75rem; }

/* ---- «توضیح بیشتر» explanation popups (openInfo in tool-kit.js) ----------
   The link sits inside each tool's own markup, so it is scoped to .tool-body
   to outweigh the tool's button reset. The popup itself is a .kb-modal. */
.tool-body .kb-info-link {
  display: inline-flex; align-items: center; gap: .25rem;
  margin: 0; padding: .125rem .25rem; border: 0; border-radius: .375rem;
  background: none; color: var(--secondary);
  font: inherit; font-size: .8125rem; font-weight: 700; line-height: 1.6;
  text-decoration: underline dashed; text-underline-offset: 4px;
  cursor: pointer; white-space: nowrap; vertical-align: baseline;
  -webkit-tap-highlight-color: transparent;
}
.tool-body .kb-info-link::before { content: "؟"; display: inline-grid; place-items: center; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: var(--primary-10); font-size: .6875rem; text-decoration: none; }
.tool-body .kb-info-link:hover { color: var(--primary); }
.tool-body .kb-info-link:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
.tool-body .kb-info-hint { display: block; margin-top: .375rem; font-size: .8125rem; line-height: 1.9; color: var(--muted-foreground); }

.kb-info-modal .kb-modal-card { width: min(100%, 32rem); }
.kb-info-body { margin-top: .875rem; font-size: .9375rem; line-height: 2.05; color: var(--foreground); }
.kb-info-body p + p, .kb-info-body p + ul, .kb-info-body ul + p { margin-top: .625rem; }
.kb-info-body .kb-info-label { margin-top: .875rem; margin-bottom: -.375rem; font-weight: 900; color: var(--primary); }
.kb-info-body .kb-info-label:first-child { margin-top: 0; }
.kb-info-body .kb-info-example, .kb-info-body .kb-info-tip { padding: .625rem .75rem; border-radius: .625rem; background: var(--accent); font-size: .875rem; }
.kb-info-body ul { padding-inline-start: 1.25rem; list-style: disc; }
.kb-info-ok { margin-top: 1.125rem; }

/* ---- the privacy line on every question step (addPrivacyLines) ---------- */
.tool-body .kb-privacy {
  display: flex; align-items: flex-start; gap: .5rem;
  margin: 0 0 1rem; padding: .625rem .875rem;
  border: 1px solid hsl(145 40% 80%); border-radius: .625rem;
  background: hsl(145 45% 96%); color: hsl(145 50% 22%);
  font-size: .8125rem; font-weight: 700; line-height: 1.9; text-align: start;
}
.tool-body .kb-privacy .ti { flex: 0 0 auto; font-size: 1.125rem; line-height: 1.6; }
