/*
 * IP-camera bandwidth calculator: /after-sales/bandwidth-calculator (views/bandwidth-calc.php, inc/bandwidth-calc.php).
 * The calculator (.kdt-bw: form on the start side, the sticky result panel on the end side from 1000px), the "how it
 * is calculated" section, the project band and the print sheet. Axis tokens, fields (.ax-field / .ax-input) and buttons
 * (.ax-btn) only; the hero and "more services" come from services.css (.axs-page). Logical properties only (fa / ar
 * right-to-left, en / zh left-to-right); numbers + units are left-to-right islands (.kdt-bw__n). No animation.
 */
.kdt-bw-page .kdt-bw-tool { padding-block: 64px 80px; }

/* what needs the script is shown only when it runs (the class is set by an inline script at the top of .kdt-bw) */
.kdt-bw:not(.is-js) [data-bw-js],
.kdt-bw.is-js [data-bw-nojs],
.kdt-bw [hidden] { display: none !important; }

.kdt-bw { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; color: var(--ax-gray-700); }
.kdt-bw *,
.kdt-bw *::before,
.kdt-bw *::after { box-sizing: border-box; }
.kdt-bw__form { min-width: 0; margin: 0; }
.kdt-bw__h { margin: 0 0 12px; font-size: 22px; line-height: 1.35; font-weight: 700; color: var(--ax-ink); }
.kdt-bw__form .kdt-bw__h ~ .kdt-bw__h { margin-top: 36px; }
.kdt-bw__h3 { margin: 26px 0 10px; font-size: 17px; line-height: 1.4; font-weight: 700; color: var(--ax-ink); }
.kdt-bw__hint { margin: 0; font-size: 13px; line-height: 1.6; color: var(--ax-gray-500); }
p.kdt-bw__hint { margin: -4px 0 14px; }
.kdt-bw__n { unicode-bidi: isolate; white-space: nowrap; }

/* ---------------------------------------------------------------- camera groups */
.kdt-bw__groups { display: grid; gap: 16px; container-type: inline-size; }
.kdt-bw__group {
  position: relative; min-width: 0; margin: 0; padding: 16px 18px 18px;
  border: 1px solid var(--ax-gray-200); border-top: 3px solid var(--ax-accent); border-radius: var(--ax-radius-card);
  background: #fff; box-shadow: var(--ax-shadow-card);
}
/* float = a plain block (no legend notch in the border), full width so it follows the text direction */
.kdt-bw__legend {
  float: left; width: 100%; margin: 0 0 12px; padding: 0; padding-inline-end: 96px;
  font-size: 16px; line-height: 1.5; font-weight: 700; color: var(--ax-ink);
}
.kdt-bw__remove {
  position: absolute; top: 10px; inset-inline-end: 12px; min-height: 36px; padding: 5px 14px;
  border: 1px solid var(--ax-gray-300); border-radius: 1000px; background: #fff; color: var(--ax-ink);
  font: inherit; font-size: 14px; line-height: 1.4; cursor: pointer;
}
.kdt-bw__remove:hover { border-color: #b3261e; color: #b3261e; }
.kdt-bw__remove:focus-visible { outline: 2px solid var(--ax-accent); outline-offset: 2px; }
.kdt-bw__fields { clear: both; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px 16px; }
.kdt-bw__pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; min-width: 0; }
@container (min-width: 440px) {
  .kdt-bw__fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kdt-bw__pair { grid-column: 1 / -1; }
}
@container (min-width: 720px) {
  .kdt-bw__fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kdt-bw__pair { grid-column: span 2; }
}

/* ---------------------------------------------------------------- fields (Axis .ax-field / .ax-input) */
.kdt-bw .ax-field.kdt-bw__field { min-width: 0; margin: 0; }
.kdt-bw__lbl { font-size: 14px; line-height: 1.4; font-weight: 600; color: var(--ax-ink); }
.kdt-bw .kdt-bw__input { height: 46px; text-overflow: ellipsis; }
.kdt-bw .kdt-bw__input:invalid { border-color: #b3261e; }
/* fields that only matter for one choice (no script needed; without :has() they simply stay visible) */
.kdt-bw__group:not(:has([data-bw="r"] option[value="c"]:checked)) .kdt-bw__custom,
.kdt-bw__group:not(:has([data-bw="rec"] option[value="m"]:checked)) .kdt-bw__activity,
.kdt-bw__group:not(:has([data-bw="bm"] option[value="m"]:checked)) .kdt-bw__kbps { display: none; }

.kdt-bw__add { margin: 16px 0 0; }
.kdt-bw [data-bw-add]:disabled { opacity: .5; cursor: not-allowed; }
.kdt-bw__proj { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px 16px; container-type: inline-size; }
.kdt-bw__proj-hint { grid-column: 1 / -1; }
@media (min-width: 600px) {
  .kdt-bw__proj { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.kdt-bw__submit { margin: 24px 0 0; }

/* ---------------------------------------------------------------- result */
.kdt-bw__results { min-width: 0; padding: 20px 16px; border-radius: var(--ax-radius-card); background: var(--ax-bg-soft); }
.kdt-bw__status { margin: 0 0 16px; font-size: 15px; line-height: 1.75; color: var(--ax-gray-700); }
.kdt-bw__kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.kdt-bw__kpi { min-width: 0; margin: 0; padding: 14px 16px; border-radius: var(--ax-radius-card); background: #fff; }
.kdt-bw__kpi--main,
.kdt-bw__kpi--wide { grid-column: 1 / -1; }
.kdt-bw__kpi--main { border-top: 4px solid var(--ax-accent); }
.kdt-bw__kpi dt { font-size: 13px; line-height: 1.5; font-weight: 600; color: var(--ax-gray-500); }
.kdt-bw__kpi dd { margin: 4px 0 0; font-size: clamp(19px, 5.4vw, 22px); line-height: 1.3; font-weight: 700; color: var(--ax-ink); }
.kdt-bw__kpi--main dd > .kdt-bw__n { font-size: clamp(26px, 8vw, 34px); line-height: 1.2; }
.kdt-bw__sub { display: block; margin-top: 4px; font-size: 13px; line-height: 1.6; font-weight: 400; color: var(--ax-gray-500); }
.kdt-bw__sub.kdt-bw__advice { font-weight: 600; color: var(--ax-accent-text); }

.kdt-bw__glist { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.kdt-bw__gres { min-width: 0; padding: 12px 14px; border-radius: var(--ax-radius-card); background: #fff; }
.kdt-bw__gname { margin: 0 0 8px; font-size: 14px; line-height: 1.6; color: var(--ax-gray-700); }
.kdt-bw__gname strong { margin-inline-end: 6px; color: var(--ax-ink); }
/* a number stays with its unit ("25 fps", "8 × 4 MP", "30 days"): a group description breaks only between its items */
.kdt-bw__gname bdi, .kdt-bw__cnt { white-space: nowrap; }
.kdt-bw__gvals { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px 12px; margin: 0; }
.kdt-bw__gvals dt { font-size: 12px; line-height: 1.5; color: var(--ax-gray-500); }
.kdt-bw__gvals dd { margin: 2px 0 0; font-size: 15px; line-height: 1.4; font-weight: 700; color: var(--ax-ink); }

.kdt-bw__line { margin: 0 0 12px; font-size: 14px; line-height: 1.7; color: var(--ax-gray-700); }
.kdt-bw__tablewrap { max-width: 100%; overflow-x: auto; }
.kdt-bw__table { width: 100%; border-collapse: collapse; border-radius: var(--ax-radius-card); background: #fff; font-size: 14px; }
.kdt-bw__table caption { padding: 0 0 8px; caption-side: top; text-align: start; font-size: 13px; line-height: 1.5; color: var(--ax-gray-500); }
.kdt-bw__table th,
.kdt-bw__table td { padding: 9px 12px; border-bottom: 1px solid var(--ax-gray-200); text-align: start; }
.kdt-bw__table thead th { font-size: 12px; font-weight: 600; color: var(--ax-gray-500); }
.kdt-bw__table tbody th { font-weight: 600; color: var(--ax-ink); }
.kdt-bw__table tbody tr:last-child > * { border-bottom: 0; }
.kdt-bw__more { margin: 10px 0 0; }

.kdt-bw__nvrs { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.kdt-bw__nvr {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px;
  padding: 10px 14px; border-radius: var(--ax-radius-card); background: #fff; color: var(--ax-ink); text-decoration: none;
  border-inline-start: 3px solid var(--ax-accent);
}
.kdt-bw__nvr:hover .kdt-bw__nvr-m { color: var(--ax-accent-text); text-decoration: underline; }
.kdt-bw__nvr:focus-visible { outline: 2px solid var(--ax-accent); outline-offset: 2px; }
.kdt-bw__nvr-m { font-size: 15px; font-weight: 700; unicode-bidi: isolate; }
.kdt-bw__nvr-s,
.kdt-bw__nvr-d { font-size: 13px; line-height: 1.6; color: var(--ax-gray-500); }
/* the drive bays + largest drive, and the drives for this project (parent inc/cam-storage.php kdt_cam_nvr_items_html()) */
.kdt-bw__nvr-d,
.kdt-bw__nvr-l { flex-basis: 100%; }
.kdt-bw__nvr-l { font-size: 14px; line-height: 1.6; font-weight: 600; color: var(--ax-ink); }
.kdt-bw__split { padding: 10px 12px; border-inline-start: 3px solid #b3261e; background: #fff; color: var(--ax-gray-700); }
.kdt-bw__split a { color: var(--ax-accent-text); font-weight: 600; }
.kdt-bw__note { margin: 10px 0 0; font-size: 13px; line-height: 1.7; color: var(--ax-gray-500); }
.kdt-bw__est { margin: 20px 0 0; padding: 10px 12px; border-inline-start: 3px solid var(--ax-accent); background: #fff; font-size: 13px; line-height: 1.75; color: var(--ax-gray-700); }
.kdt-bw__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; }
.kdt-bw__msg { flex-basis: 100%; min-height: 1.6em; margin: 0; font-size: 13px; line-height: 1.6; font-weight: 600; color: var(--ax-accent-text); }

/* desktop: inputs on the start side, the result card on the end side, sticky under the header (scrolls inside when taller) */
@media (min-width: 1000px) {
  .kdt-bw { grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); gap: 48px; align-items: start; }
  .kdt-bw__results { padding: 28px; }
}
@media (min-width: 1000px) and (min-height: 620px) {
  .kdt-bw__results {
    position: sticky; top: calc(var(--ax-sticky-top) + 20px);
    max-height: calc(100vh - var(--ax-sticky-top) - 40px); overflow-y: auto; overscroll-behavior: contain;
  }
}
@media (max-width: 380px) {
  .kdt-bw__kpis { grid-template-columns: minmax(0, 1fr); }
  .kdt-bw__group { padding-inline: 14px; }
}

/* ---------------------------------------------------------------- how it is calculated (+ tips in a card) */
.kdt-bw-notes__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 64px; align-items: start; }
.kdt-bw-notes__intro { margin-bottom: 40px; }
.kdt-bw-notes__intro p { margin: 0 0 1.1em; }
.kdt-bw-notes .kdt-bw-notes__title { font-size: 32px; }
.kdt-bw-notes__aside { position: sticky; top: calc(var(--ax-sticky-top) + 24px); }
.kdt-bw-notes__card {
  padding: 28px 26px; background: #fff; border-radius: var(--ax-radius-card);
  box-shadow: var(--ax-shadow-card); border-top: 4px solid var(--ax-accent);
}
.kdt-bw-notes__icon {
  display: inline-flex; flex: none; align-items: center; justify-content: center; width: 56px; height: 56px; margin-bottom: 14px;
  border-radius: 50%; background: var(--ax-accent-soft); color: var(--ax-accent-text);
}
.kdt-bw-notes__icon svg { width: 28px; height: 28px; }
.kdt-bw-notes__cardtitle { margin: 0 0 14px; font-size: 20px; line-height: 1.4; font-weight: 700; color: var(--ax-ink); }
.kdt-bw-model__intro { margin: 0 0 12px; }
.kdt-bw-model__formula { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--ax-radius-card); background: #fff; font-size: 15px; font-weight: 600; color: var(--ax-ink); overflow-x: auto; }
.kdt-bw-model__factors { margin: 0 0 28px; }
.kdt-bw-model__factors > div {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; padding: 12px 0;
  border-bottom: 1px solid var(--ax-gray-200);
}
.kdt-bw-model__factors dt { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ax-gray-500); }
.kdt-bw-model__factors dd { margin: 0; font-size: 15px; line-height: 1.75; color: var(--ax-ink); }
.kdt-bw-model__note { display: block; margin-top: 4px; font-size: 13px; line-height: 1.6; color: var(--ax-gray-500); }
.kdt-bw-model__ref { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
.kdt-bw-model__ref caption { padding: 0 0 10px; caption-side: top; text-align: start; font-size: 15px; line-height: 1.5; font-weight: 700; color: var(--ax-ink); }
.kdt-bw-model__ref th,
.kdt-bw-model__ref td { padding: 8px 12px; border-bottom: 1px solid var(--ax-gray-200); text-align: start; }
.kdt-bw-model__ref thead th { font-size: 13px; font-weight: 600; color: var(--ax-gray-500); }
.kdt-bw-model__ref tbody th { font-weight: 600; color: var(--ax-ink); }
.kdt-bw-tips { margin: 0; padding-inline-start: 20px; }
.kdt-bw-tips li { margin: 0 0 10px; line-height: 1.75; }

/* planning a project? (turquoise band) */
.kdt-bw-cta__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px 48px; }
.kdt-bw-cta__text { flex: 1 1 480px; min-width: 0; max-width: 760px; }
.kdt-bw-cta .ax-section__title { margin: 0 0 8px; }
.kdt-bw-cta .ax-section__lead { color: var(--ax-ink); }

@media (max-width: 992px) {
  .kdt-bw-page .kdt-bw-tool { padding-block: 40px 56px; }
  .kdt-bw-notes__grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .kdt-bw-notes__aside { position: static; }
}
@media (max-width: 600px) {
  .kdt-bw-notes .kdt-bw-notes__title { font-size: 26px; }
  .kdt-bw-notes__card { padding: 22px 18px; }
  .kdt-bw-cta__actions .ax-btn { flex: 1 1 auto; }
  .kdt-bw-model__factors > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* ---------------------------------------------------------------- print / save as PDF: the inputs + the result */
@media print {
  header,
  footer,
  nav,
  .ax-header,
  .ax-footer,
  .ax-hero__art,
  .ax-hero__lead,
  .kdt-bw__actions,
  .kdt-bw__add,
  .kdt-bw__remove,
  .kdt-bw__submit,
  .kdt-bw__hint,
  .kdt-bw__more,
  .kdt-bw-notes,
  .kdt-bw-cta,
  .axs-others,
  #kdt-assistant,
  .kdt-chat { display: none !important; }
  .kdt-bw-page .kdt-bw-tool { padding: 0; }
  .kdt-bw { display: block; color: #000; }
  .kdt-bw__results { position: static; max-height: none; overflow: visible; margin-top: 16px; padding: 0; background: none; }
  .kdt-bw__group,
  .kdt-bw__kpi,
  .kdt-bw__gres,
  .kdt-bw__nvr { box-shadow: none; border: 1px solid #bbb; break-inside: avoid; }
  .kdt-bw .kdt-bw__input { height: auto; min-height: 0; padding: 2px 6px; border: 0; background-image: none; }
  .kdt-bw__fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kdt-bw__pair { grid-column: span 2; }
  .ax-hero { min-height: 0 !important; padding: 0 0 12px !important; background: none !important; }
  .ax-hero,
  .ax-hero * { color: #000 !important; }
  a[href]::after { content: none !important; }
}
