/* -----------------------------------------------------
   Online tools (content/tools-pages, assets/js/cs-tools.js)
   Loaded only on pages whose content contains a .cs-tool block (functions.php).
   Colours come from the light-theme tokens (cs-light.css) with the same values as fallbacks.
   Status colours are AA on their tints: ok #075E55/#E3F6F3, warn #7A4B00/#FFF4E0, bad #A61B1B/#FDECEC.
   ----------------------------------------------------- */

.cs-tool {
  background: var(--cs-card, #FFFFFF);
  border: 1px solid var(--cs-border, #DCE3EE);
  border-radius: var(--cs-radius-lg, 16px);
  padding: clamp(18px, 3vw, 32px);
  color: var(--cs-body, #1E293B);
}

.cs-tool-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 20px;
  align-items: start;
}

.cs-tool-form .cs-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.cs-tool-form .cs-field--wide,
.cs-tool-form .cs-tool-actions,
.cs-tool-form .cs-checks {
  grid-column: 1 / -1;
}

.cs-tool-form label,
.cs-tool-form .cs-field-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--cs-ink, #0F1B33);
}

.cs-tool .cs-tool-form input[type="text"],
.cs-tool .cs-tool-form input[type="number"],
.cs-tool .cs-tool-form select,
.cs-tool .cs-tool-form textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--cs-input-border, #7A8699);
  border-radius: 12px;
  background: #FFFFFF;
  color: var(--cs-ink, #0F1B33);
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
  box-shadow: none;
}

.cs-tool .cs-tool-form textarea {
  min-height: 96px;
  resize: vertical;
}

.cs-tool .cs-tool-form [dir="ltr"] {
  text-align: left;
}

.cs-tool .cs-tool-form input:focus,
.cs-tool .cs-tool-form select:focus,
.cs-tool .cs-tool-form textarea:focus {
  border-color: var(--cs-brand, #1C39BB);
  outline: 2px solid var(--cs-brand, #1C39BB);
  outline-offset: 1px;
}

.cs-tool-form .cs-hint {
  font-size: 13px;
  line-height: 1.8;
  color: var(--cs-muted, #475569);
}

.cs-tool-form .cs-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px 20px;
  margin: 0;
  padding: 0;
  border: 0;
}

.cs-tool-form .cs-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 500;
  font-size: 15px;
  line-height: 1.8;
  cursor: pointer;
}

.cs-tool-form .cs-check input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 4px;
  accent-color: var(--cs-brand, #1C39BB);
}

.cs-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.cs-tool .cs-tool-actions .cs-btn {
  min-height: 48px;
  border: 0;
  cursor: pointer;
}

.cs-tool button[aria-busy="true"] {
  opacity: .7;
  cursor: progress;
}

/* Quick picks (common ports) */
.cs-port-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.cs-tool .cs-port-chips button {
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--cs-border, #DCE3EE);
  border-radius: 999px;
  background: var(--cs-alt, #F1F4F9);
  color: var(--cs-ink, #0F1B33);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.cs-tool .cs-port-chips button:hover {
  border-color: var(--cs-brand, #1C39BB);
  color: var(--cs-brand, #1C39BB);
}

.cs-myip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--cs-band, #EAF1FF);
  color: var(--cs-ink, #0F1B33);
}

.cs-myip strong {
  font-size: 18px;
}

/* Results */
.cs-tool-result {
  display: grid;
  gap: 14px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--cs-border, #DCE3EE);
  min-width: 0;
}

.cs-tool-result[hidden] {
  display: none !important;
}

.cs-tool-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.cs-tool-summary > strong {
  font-size: 19px;
  color: var(--cs-ink, #0F1B33);
}

.cs-tool-subtitle {
  margin: 6px 0 0;
  font-size: 18px;
  color: var(--cs-ink, #0F1B33);
}

.cs-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.7;
  white-space: nowrap;
}

.cs-pill--ok { background: #E3F6F3; border-color: #B7E4DC; color: #075E55; }
.cs-pill--warn { background: #FFF4E0; border-color: #F5D59A; color: #7A4B00; }
.cs-pill--bad { background: #FDECEC; border-color: #F5C2C2; color: #A61B1B; }
.cs-pill--info { background: var(--cs-brand-tint, #E8EDFF); border-color: #C9D4FF; color: var(--cs-brand, #1C39BB); }

.cs-tool-note {
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  border-inline-start: 4px solid var(--cs-brand, #1C39BB);
  background: var(--cs-alt, #F1F4F9);
  color: var(--cs-body, #1E293B);
  font-size: 15px;
  line-height: 1.9;
}

.cs-tool-note--warn { border-color: #F5A524; background: #FFF8EC; }
.cs-tool-note--bad { border-color: #C62828; background: #FDF1F1; }
.cs-tool-note--ok { border-color: #0B7F73; background: #EEF9F7; }

/* The site table has min-width: 560px for plan tables; tool results must fit a phone instead of scrolling. */
.cs-tool .cs-tool-table {
  min-width: 0;
  margin: 0;
}

.cs-tool .cs-dns-table th:first-child,
.cs-tool .cs-dns-table td:first-child,
.cs-tool .cs-dns-table th:last-child,
.cs-tool .cs-dns-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.cs-tool .cs-tool-table .cs-ltr {
  overflow-wrap: anywhere;
}

.cs-tool .cs-tool-table th[scope="row"] {
  width: 38%;
  font-weight: 600;
  vertical-align: top;
}

.cs-tool .cs-tool-table td {
  overflow-wrap: anywhere;
}

.cs-tool-block {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.cs-tool-block > .cs-ltr {
  flex: 1 1 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--cs-alt, #F1F4F9);
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.cs-tool-block > .cs-tool-note {
  flex: 1 1 100%;
}

.cs-ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

.cs-tag {
  display: inline-block;
  margin: 2px 0 2px 6px;
  padding: 1px 8px;
  border-radius: 8px;
  background: var(--cs-alt, #F1F4F9);
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.8;
}

.cs-bin {
  display: inline-block;
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 13.5px;
  letter-spacing: .5px;
  overflow-wrap: anywhere;
  background: none;
  padding: 0;
}

.cs-bin-net { color: var(--cs-brand, #1C39BB); font-weight: 700; }
.cs-bin-host { color: #0B7F73; }

.cs-tool-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-inline-start: 22px;
  line-height: 1.9;
}

.cs-tool .cs-code {
  margin: 0;
  max-height: 540px;
  overflow: auto;
  padding: 16px 18px;
  border-radius: 12px;
  background: #0F1B33;
  color: #E8EDFF;
  direction: ltr;
  text-align: left;
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre;
}

.cs-tool .cs-code code {
  background: none;
  color: inherit;
  padding: 0;
  font: inherit;
}

.cs-tool .cs-copy {
  min-height: 40px;
  padding: 6px 18px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}

.cs-tool-raw summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--cs-brand, #1C39BB);
}

.cs-tool-raw pre {
  max-height: 380px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--cs-alt, #F1F4F9);
  direction: ltr;
  text-align: left;
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 600px) {
  .cs-tool .cs-tool-table th,
  .cs-tool .cs-tool-table td {
    padding: 10px 12px;
    font-size: 14px;
  }

  .cs-tool .cs-tool-table th[scope="row"] {
    width: 45%;
  }

  .cs-tool .cs-tool-actions .cs-btn {
    width: 100%;
    justify-content: center;
  }
}
