/* ═══════════════════════════════════════════════════════════════
   Host Tools — Frontend Styles
   
   Minimalistic SaaS-style design. No external dependencies.
   All classes prefixed with `ht-` to avoid theme conflicts.
   ═══════════════════════════════════════════════════════════════ */

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --ht-primary: #2563eb;
  --ht-primary-hover: #1d4ed8;
  --ht-primary-bg: #eff6ff;
  --ht-white: #ffffff;
  --ht-off-white: #f8fafc;
  --ht-text: #1e293b;
  --ht-text-muted: #64748b;
  --ht-text-dim: #94a3b8;
  --ht-heading: #0f172a;
  --ht-border: #e2e8f0;
  --ht-border-light: #f1f5f9;
  --ht-border-subtle: #e8ecf1;
  --ht-border-hover: #cbd5e1;
  --ht-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --ht-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06);
  --ht-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --ht-radius-sm: 0.375rem;
  --ht-radius: 0.5rem;
  --ht-radius-lg: 0.75rem;
  --ht-radius-xl: 1rem;
  --ht-transition: 0.15s ease;
  --ht-transition-slow: 0.25s ease;
  --ht-line-height: 1.6;
  --ht-line-height-relaxed: 1.7;
  --ht-mono: "SF Mono", "Fira Code", "Consolas", monospace;
  --ht-green: #22c55e;
  --ht-green-bg: #f0fdf4;
  --ht-green-border: #bbf7d0;
  --ht-green-text: #166534;
  --ht-amber: #f59e0b;
  --ht-amber-bg: #fffbeb;
  --ht-amber-border: #fde68a;
  --ht-amber-text: #92400e;
  --ht-red: #ef4444;
  --ht-red-bg: #fef2f2;
  --ht-red-border: #fecaca;
  --ht-red-text: #991b1b;
  --ht-blue: #3b82f6;
}

/* ─── Tool Container ────────────────────────────────────────── */
.ht-tool {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  max-width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ht-text);
  line-height: var(--ht-line-height);
}

.ht-tool *,
.ht-tool *::before,
.ht-tool *::after {
  box-sizing: border-box;
}

/* ─── Form Area ─────────────────────────────────────────────── */
.ht-tool-form-area {
  min-width: 0;
}

.ht-tool-form {
  margin-bottom: 1.5rem;
}

.ht-form-label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ht-heading);
  margin-bottom: 0.5rem;
}

.ht-input-group {
  display: flex;
  gap: 0.5rem;
}

.ht-form-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--ht-text);
  background: var(--ht-white);
  outline: none;
  transition: border-color var(--ht-transition), box-shadow var(--ht-transition);
}

.ht-form-input:focus {
  border-color: var(--ht-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ht-form-input::placeholder {
  color: var(--ht-text-dim);
}

.ht-form-hint {
  font-size: 0.8125rem;
  color: var(--ht-text-muted);
  margin: 0.5rem 0 0;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.ht-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--ht-radius-lg);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--ht-transition);
  white-space: nowrap;
}

.ht-btn-primary {
  background: var(--ht-primary);
  color: var(--ht-white);
}

.ht-btn-primary:hover {
  background: var(--ht-primary-hover);
}

.ht-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ht-btn-sm {
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  border-radius: var(--ht-radius);
}

/* ─── Pre-test Area (Before Result) ─────────────────────────── */
.ht-pretest-area {
  transition: opacity 0.4s ease, max-height 0.5s ease, transform 0.4s ease;
  opacity: 1;
  max-height: 800px;
  overflow: hidden;
}

.ht-pretest-area.ht-pretest-hidden {
  opacity: 0;
  max-height: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

/* ─── Quick Test Links ──────────────────────────────────────── */
.ht-quick-test {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--ht-text-dim);
  line-height: 1.5;
}

.ht-quick-test-label {
  color: var(--ht-text-dim);
}

.ht-quick-link {
  color: var(--ht-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--ht-transition);
  cursor: pointer;
}

.ht-quick-link:hover {
  color: var(--ht-primary-hover);
  text-decoration: underline;
}

/* ─── Why Use Cards ─────────────────────────────────────────── */
.ht-why-use {
  margin-top: 2.5rem;
}

.ht-why-use-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ht-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
}

.ht-why-use-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.ht-why-use-card {
  background: var(--ht-off-white);
  border: 1px solid var(--ht-border-subtle);
  border-radius: var(--ht-radius-lg);
  padding: 1.25rem 1rem;
  text-align: center;
  transition: all var(--ht-transition-slow);
}

.ht-why-use-card:hover {
  border-color: var(--ht-border-hover);
  box-shadow: var(--ht-shadow-sm);
  transform: translateY(-1px);
  background: var(--ht-white);
}

.ht-why-use-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 0.75rem;
  background: var(--ht-primary-bg);
  border-radius: var(--ht-radius-lg);
  color: var(--ht-primary);
}

.ht-why-use-card-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ht-heading);
  margin-bottom: 0.375rem;
}

.ht-why-use-card-desc {
  font-size: 0.8125rem;
  color: var(--ht-text-muted);
  line-height: var(--ht-line-height-relaxed);
  margin: 0;
}

/* ─── Result Container ──────────────────────────────────────── */
.ht-result {
  margin-top: 2rem;
  animation: htFadeIn 0.25s ease;
}

@keyframes htFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Loading Spinner ───────────────────────────────────────── */
.ht-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem;
  font-size: 0.9375rem;
  color: var(--ht-text-muted);
}

.ht-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ht-border);
  border-top-color: var(--ht-primary);
  border-radius: 50%;
  animation: htSpin 0.6s linear infinite;
}

@keyframes htSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Error Message ─────────────────────────────────────────── */
.ht-error-msg {
  background: var(--ht-red-bg);
  border: 1px solid var(--ht-red-border);
  color: var(--ht-red-text);
  padding: 1rem 1.25rem;
  border-radius: var(--ht-radius);
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

/* ─── Status Banner ─────────────────────────────────────────── */
.st-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-radius: var(--ht-radius-lg);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  border: 1px solid var(--ht-border);
}

.st-banner-ok {
  background: var(--ht-green-bg);
  border-color: var(--ht-green-border);
}

.st-banner-redirect {
  background: var(--ht-amber-bg);
  border-color: var(--ht-amber-border);
}

.st-banner-error {
  background: var(--ht-red-bg);
  border-color: var(--ht-red-border);
}

.st-banner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.st-banner-ok .st-banner-dot { background: var(--ht-green); }
.st-banner-redirect .st-banner-dot { background: var(--ht-amber); }
.st-banner-error .st-banner-dot { background: var(--ht-red); }

.st-banner-label {
  font-weight: 600;
  font-size: 0.875rem;
}

.st-banner-ok .st-banner-label { color: var(--ht-green-text); }
.st-banner-redirect .st-banner-label { color: var(--ht-amber-text); }
.st-banner-error .st-banner-label { color: var(--ht-red-text); }

.st-banner-url {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.st-banner-host {
  font-family: var(--ht-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ht-text);
}

.st-banner-ip {
  font-family: var(--ht-mono);
  font-size: 0.75rem;
  color: var(--ht-text-muted);
}

/* ─── Diagnostics Grid ──────────────────────────────────────── */
.st-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.st-card {
  background: var(--ht-white);
  border: 1px solid var(--ht-border);
  border-radius: 0.625rem;
  padding: 1.125rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.st-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.st-excellent::before { background: var(--ht-green); }
.st-good::before { background: var(--ht-blue); }
.st-slow::before { background: var(--ht-amber); }
.st-poor::before { background: var(--ht-red); }
.st-neutral::before { background: var(--ht-border); }

.st-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.st-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ht-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.st-card-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.1875rem 0.5rem;
  border-radius: 9999px;
  background: var(--ht-off-white);
  color: var(--ht-text-muted);
}

.st-excellent .st-card-badge { background: var(--ht-green-bg); color: var(--ht-green-text); }
.st-good .st-card-badge { background: var(--ht-primary-bg); color: var(--ht-primary); }
.st-slow .st-card-badge { background: var(--ht-amber-bg); color: var(--ht-amber-text); }
.st-poor .st-card-badge { background: var(--ht-red-bg); color: var(--ht-red-text); }

.st-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ht-heading);
  line-height: 1.1;
}

.st-card-value-sm {
  font-size: 1.25rem;
}

.st-card-value-suffix {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ht-text-muted);
  margin-left: 0.25rem;
}

.st-card-desc {
  font-size: 0.75rem;
  color: var(--ht-text-dim);
}

/* ─── Details Panel ─────────────────────────────────────────── */
.st-panel {
  background: var(--ht-white);
  border: 1px solid var(--ht-border);
  border-radius: 0.625rem;
  margin-bottom: 1rem;
  overflow: hidden;
}

.st-panel-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1.25rem;
  background: var(--ht-off-white);
  border-bottom: 1px solid var(--ht-border-light);
}

.st-panel-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--ht-text-muted);
}

.st-panel-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ht-heading);
}

.st-panel-body {
  padding: 1rem 1.25rem;
}

.st-kv {
  display: grid;
  gap: 0.625rem;
}

.st-kv-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--ht-border-light);
}

.st-kv-item:last-child {
  border-bottom: none;
}

.st-kv-label {
  font-size: 0.8125rem;
  color: var(--ht-text-muted);
  flex-shrink: 0;
}

.st-kv-value {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ht-text);
  text-align: right;
  word-break: break-all;
}

.st-kv-value.mono {
  font-family: var(--ht-mono);
  font-size: 0.75rem;
}

.code-success { color: var(--ht-green); }
.code-error { color: var(--ht-red); }

/* ─── SAN Tags ──────────────────────────────────────────────── */
.st-san-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.st-san-tag {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  background: var(--ht-primary-bg);
  color: var(--ht-primary);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-family: var(--ht-mono);
  font-weight: 500;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.ht-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ht-sidebar-card {
  background: var(--ht-white);
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--ht-shadow-card);
}

.ht-sidebar-card h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ht-heading);
  margin: 0 0 0.5rem;
}

.ht-sidebar-card p {
  font-size: 0.8125rem;
  color: var(--ht-text-muted);
  margin: 0 0 0.75rem;
  line-height: var(--ht-line-height-relaxed);
}

.ht-feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ht-feature-list li {
  padding: 0.25rem 0;
  font-size: 0.8125rem;
  color: var(--ht-text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Badges ────────────────────────────────────────────────── */
.ht-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 700;
  white-space: nowrap;
}

.ht-badge-ok { background: var(--ht-green-bg); color: var(--ht-green-text); }
.ht-badge-warn { background: var(--ht-amber-bg); color: var(--ht-amber-text); }
.ht-badge-fail { background: var(--ht-red-bg); color: var(--ht-red-text); }
.ht-badge-good { background: var(--ht-primary-bg); color: var(--ht-primary); }

/* ─── Generic Error ─────────────────────────────────────────── */
.ht-error {
  color: var(--ht-red);
  font-size: 0.9375rem;
  padding: 1rem;
  background: var(--ht-red-bg);
  border: 1px solid var(--ht-red-border);
  border-radius: var(--ht-radius);
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ht-tool {
    grid-template-columns: 1fr;
  }

  .ht-input-group {
    flex-direction: column;
  }

  .st-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ht-why-use-grid {
    grid-template-columns: 1fr;
  }

  .st-banner-url {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .st-grid {
    grid-template-columns: 1fr;
  }

  .st-card-value {
    font-size: 1.5rem;
  }
}