/* ===========================
   Mail Header Analyzer (mh-)
   =========================== */

:root {
  --mh-primary: #6366f1;
  --mh-primary-light: #e0e7ff;
  --mh-primary-dark: #4f46e5;
  --mh-success: #16a34a;
  --mh-success-light: #dcfce7;
  --mh-warn: #f59e0b;
  --mh-warn-light: #fef3c7;
  --mh-error: #dc2626;
  --mh-error-light: #fee2e2;
  --mh-border: #e2e8f0;
  --mh-bg-card: #f8fafc;
  --mh-text: #1e293b;
  --mh-text-muted: #64748b;
  --mh-text-faint: #94a3b8;
  --mh-radius: 12px;
  --mh-radius-sm: 6px;
  --mh-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --mh-shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --mh-transition: .2s ease;
}

/* ── Anchor Navigation ── */
.mh-anchor-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.mh-anchor-link {
  padding: 6px 14px;
  border-radius: var(--mh-radius-sm);
  background: var(--mh-primary-light);
  color: var(--mh-primary);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--mh-transition);
}
.mh-anchor-link:hover {
  background: var(--mh-primary);
  color: #fff;
}

/* ── Input Area ── */
.mh-textarea-wrap {
  position: relative;
}
.mh-textarea {
  width: 100%;
  min-height: 200px;
  padding: 16px;
  border: 2px solid var(--mh-border);
  border-radius: var(--mh-radius);
  font-family: 'Courier New', Consolas, monospace;
  font-size: .82rem;
  line-height: 1.6;
  resize: vertical;
  transition: var(--mh-transition);
  background: #fff;
  color: var(--mh-text);
  box-sizing: border-box;
}
.mh-textarea:focus {
  outline: none;
  border-color: var(--mh-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.mh-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.mh-toolbar-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Buttons ── */
.mh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--mh-radius-sm);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--mh-transition);
  text-decoration: none;
  line-height: 1.4;
}
.mh-btn--primary {
  background: var(--mh-primary);
  color: #fff;
}
.mh-btn--primary:hover {
  background: var(--mh-primary-dark);
}
.mh-btn--secondary {
  background: #fff;
  color: var(--mh-primary);
  border: 1px solid var(--mh-border);
}
.mh-btn--secondary:hover {
  background: var(--mh-primary-light);
}
.mh-btn--ghost {
  background: transparent;
  color: var(--mh-text-muted);
  border: 1px solid var(--mh-border);
  padding: 6px 14px;
  font-size: .82rem;
}
.mh-btn--ghost:hover {
  background: var(--mh-bg-card);
  color: var(--mh-text);
}

/* ── Results hidden by default ── */
.mh-results { display: none; }
.mh-results--visible { display: block; }

/* ── Security Summary Alert ── */
.mh-alert {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 22px;
  border-radius: var(--mh-radius);
  margin-bottom: 20px;
}
.mh-alert--safe {
  background: var(--mh-success-light);
  border: 1px solid var(--mh-success);
  color: #166534;
}
.mh-alert--warn {
  background: var(--mh-warn-light);
  border: 1px solid var(--mh-warn);
  color: #92400e;
}
.mh-alert--danger {
  background: var(--mh-error-light);
  border: 1px solid var(--mh-error);
  color: #991b1b;
}
.mh-alert__icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  line-height: 1;
}
.mh-alert__body {
  flex: 1;
}
.mh-alert__title {
  font-weight: 700;
  font-size: .95rem;
  margin: 0 0 4px 0 !important;
}
.mh-alert__desc {
  font-size: .84rem;
  margin: 0 !important;
  line-height: 1.5;
}

/* ── Cards ── */
.mh-card {
  border: 1px solid var(--mh-border);
  border-radius: var(--mh-radius);
  background: #fff;
  box-shadow: var(--mh-shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.mh-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--mh-bg-card);
  border-bottom: 1px solid var(--mh-border);
  font-weight: 700;
  font-size: .92rem;
  color: var(--mh-text);
  margin: 0 !important;
}
.mh-card__icon {
  font-size: 1.1rem;
  line-height: 1;
}
.mh-card__body {
  padding: 16px 20px;
}

/* ── Auth Grid (SPF/DKIM/DMARC) ── */
.mh-auth-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.mh-auth-card {
  border: 1px solid var(--mh-border);
  border-radius: var(--mh-radius);
  padding: 18px;
  background: #fff;
  box-shadow: var(--mh-shadow);
  text-align: center;
}
.mh-auth-card__label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--mh-text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 0 0 10px 0 !important;
}
.mh-auth-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 700;
}
.mh-badge--pass {
  background: var(--mh-success-light);
  color: var(--mh-success);
}
.mh-badge--fail {
  background: var(--mh-error-light);
  color: var(--mh-error);
}
.mh-badge--softfail {
  background: var(--mh-warn-light);
  color: #b45309;
}
.mh-badge--none {
  background: #f1f5f9;
  color: var(--mh-text-muted);
}
.mh-auth-card__detail {
  font-size: .78rem;
  color: var(--mh-text-muted);
  margin: 10px 0 0 0 !important;
  word-break: break-all;
}

/* ── Table ── */
.mh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
.mh-table th,
.mh-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--mh-border);
  vertical-align: top;
}
.mh-table th {
  background: var(--mh-bg-card);
  font-weight: 600;
  color: var(--mh-text-muted);
  white-space: nowrap;
  width: 140px;
}
.mh-table td {
  word-break: break-all;
  color: var(--mh-text);
}

/* ── Timeline ── */
.mh-timeline {
  position: relative;
  padding-left: 28px;
}
.mh-timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--mh-border);
}
.mh-hop {
  position: relative;
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1px solid var(--mh-border);
  border-radius: var(--mh-radius-sm);
  background: #fff;
  margin-left: 8px;
}
.mh-hop::before {
  content: '';
  position: absolute;
  left: -23px;
  top: 20px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mh-primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--mh-primary-light);
}
.mh-hop--slow::before { background: var(--mh-warn); box-shadow: 0 0 0 2px var(--mh-warn-light); }
.mh-hop--very-slow::before { background: var(--mh-error); box-shadow: 0 0 0 2px var(--mh-error-light); }
.mh-hop__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 6px 0 !important;
}
.mh-hop__num {
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  background: var(--mh-primary);
  padding: 2px 8px;
  border-radius: 10px;
}
.mh-hop--slow .mh-hop__num { background: var(--mh-warn); }
.mh-hop--very-slow .mh-hop__num { background: var(--mh-error); }
.mh-hop__delay {
  font-size: .78rem;
  font-weight: 600;
}
.mh-hop__delay--ok { color: var(--mh-success); }
.mh-hop__delay--slow { color: var(--mh-warn); }
.mh-hop__delay--very-slow { color: var(--mh-error); }
.mh-hop__row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: .8rem;
  color: var(--mh-text-muted);
  margin: 0 !important;
  line-height: 1.6;
}
.mh-hop__label {
  font-weight: 600;
  color: var(--mh-text);
  white-space: nowrap;
  min-width: 36px;
}
.mh-hop__value {
  font-family: 'Courier New', Consolas, monospace;
  word-break: break-all;
}
.mh-hop__time {
  font-size: .78rem;
  color: var(--mh-text-faint);
  margin: 4px 0 0 0 !important;
}

/* ── All Headers Toggle ── */
.mh-all-headers {
  max-height: 400px;
  overflow-y: auto;
}
.mh-all-headers .mh-table th {
  width: 200px;
}

/* ── Related Tools ── */
.mh-related-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0;
}

/* ── Actions ── */
.mh-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* ── Provider Badge ── */
.mh-provider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--mh-primary-light);
  color: var(--mh-primary);
  border-radius: 14px;
  font-size: .78rem;
  font-weight: 600;
}

/* ── Toast ── */
.mh-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 10px 24px;
  border-radius: 8px;
  background: var(--mh-text);
  color: #fff;
  font-size: .85rem;
  font-weight: 600;
  box-shadow: var(--mh-shadow-md);
  z-index: 9999;
  opacity: 0;
  transition: all .3s ease;
  pointer-events: none;
}
.mh-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Use Cases ── */
.mh-use-cases {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.mh-use-cases > p,
.mh-use-cases > br {
  display: none !important;
}
.mh-use-case {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  margin: 0 !important;
  border: 1px solid var(--mh-border);
  border-radius: var(--mh-radius-sm);
  background: #fff;
}
.mh-use-case-icon {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}
.mh-use-case-icon img {
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
}
.mh-use-case h4 {
  margin: 0 0 4px 0 !important;
  padding: 0 !important;
  font-size: .88rem;
}
.mh-use-case p {
  margin: 0 !important;
  padding: 0 !important;
  font-size: .82rem;
  color: var(--mh-text-muted);
  line-height: 1.5;
}

/* ── How-to Steps ── */
.mh-steps {
  counter-reset: step;
}
.mh-step {
  counter-increment: step;
  position: relative;
  padding-left: 40px;
  margin-bottom: 20px;
}
.mh-step::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mh-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}
.mh-step h4 {
  margin: 0 0 4px 0 !important;
  padding: 0 !important;
  font-size: .9rem;
}
.mh-step p {
  margin: 0 !important;
  font-size: .84rem;
  color: var(--mh-text-muted);
  line-height: 1.6;
}

/* ── Security Grid ── */
.mh-security {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.mh-security > p,
.mh-security > br {
  display: none !important;
}
.mh-security-item {
  text-align: center;
  padding: 16px;
  border: 1px solid var(--mh-border);
  border-radius: var(--mh-radius-sm);
  background: #fff;
  margin: 0 !important;
}
.mh-security-item span {
  font-size: 1.4rem;
  display: block;
  margin-bottom: 6px;
}
.mh-security-item p {
  margin: 0 !important;
  font-size: .82rem;
  color: var(--mh-text-muted);
}

/* ── FAQ ── */
.mh-faq dt {
  font-weight: 700;
  font-size: .9rem;
  margin: 16px 0 6px 0 !important;
  color: var(--mh-text);
}
.mh-faq dd {
  margin: 0 0 16px 0 !important;
  padding: 0 !important;
  font-size: .84rem;
  color: var(--mh-text-muted);
  line-height: 1.65;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .mh-auth-grid {
    grid-template-columns: 1fr;
  }
  .mh-use-cases {
    grid-template-columns: 1fr;
  }
  .mh-security {
    grid-template-columns: 1fr 1fr;
  }
  .mh-all-headers .mh-table th {
    width: 120px;
  }
  .mh-hop__header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 400px) {
  .mh-security {
    grid-template-columns: 1fr;
  }
  .mh-btn {
    width: 100%;
    justify-content: center;
  }
}
