/*
 * email-header-analyzer.css
 * Supplementary styles for the Email Header Analyzer section.
 * Relies on design-system.css being loaded first (CSS variables).
 * Font stack: DM Sans + DM Mono via Google Fonts.
 *
 * Variable assumptions from design-system.css:
 *   --accent: #2575fc
 *   --surface, --border, --text, --muted
 *   --radius-md, --radius-sm (fallback to 8px / 4px)
 */

/* ── Section wrapper ──────────────────────────────────────────────────────── */

.eha-section {
  margin: 2rem 0;
}

.eha-inner {
  position: relative;
  background: rgba(20, 20, 20, 0.9);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
  padding: 2rem;
}

/* ── Hero / heading ───────────────────────────────────────────────────────── */

.eha-hero {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.eha-hero-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm, 8px);
  background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.eha-title {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 1.375rem;
  color: var(--text, #f0f0f0);
  margin: 0 0 0.25rem;
  line-height: 1.25;
}

.eha-subtitle {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: var(--muted, #888);
  margin: 0;
  line-height: 1.5;
}

/* ── Input area ───────────────────────────────────────────────────────────── */

.eha-label {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted, #888);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.eha-textarea {
  width: 100%;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: var(--radius-sm, 8px);
  color: var(--text, #f0f0f0);
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  padding: 0.875rem 1rem;
  resize: vertical;
  transition: border-color 0.2s;
  outline: none;
}

.eha-textarea::placeholder {
  color: var(--muted, #555);
  font-family: 'DM Sans', sans-serif;
}

.eha-textarea:focus {
  border-color: var(--accent, #2575fc);
  box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.18);
}

.eha-hint {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--muted, #666);
  margin: 0.5rem 0 0;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.eha-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.eha-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  padding: 0.625rem 1.25rem;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  white-space: nowrap;
}

.eha-btn--primary {
  background: #6a11cb;
  color: #fff;
  box-shadow: 0 4px 12px rgba(106, 17, 203, 0.35);
}

.eha-btn--primary:hover {
  background: #2575fc;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 117, 252, 0.4);
}

.eha-btn--primary:active {
  transform: translateY(0);
}

.eha-btn--ghost {
  background: transparent;
  color: var(--muted, #888);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
}

.eha-btn--ghost:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text, #f0f0f0);
  transform: translateY(-1px);
}

/* ── Copy button ──────────────────────────────────────────────────────────── */

.eha-copy-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  background: transparent;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: var(--radius-sm, 6px);
  color: var(--muted, #888);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.eha-copy-btn:hover {
  color: var(--text, #f0f0f0);
  background: rgba(255,255,255,0.05);
}

.eha-copy-btn.eha-copied {
  color: #4caf50;
  border-color: #4caf50;
}

/* ── Output / cards ───────────────────────────────────────────────────────── */

.eha-output {
  margin-top: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.eha-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255,255,255,0.09));
  border-radius: var(--radius-sm, 8px);
  padding: 1.25rem;
}

.eha-card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text, #e0e0e0);
  margin: 0 0 1rem;
  letter-spacing: 0.01em;
}

/* ── Definition list (basic info / spam) ──────────────────────────────────── */

.eha-dl {
  margin: 0;
  padding: 0;
}

.eha-dl-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  align-items: baseline;
}

.eha-dl-row:last-child {
  border-bottom: none;
}

.eha-dl-row dt {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted, #777);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.eha-dl-row dd {
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  color: var(--text, #ddd);
  margin: 0;
  word-break: break-all;
}

/* ── Authentication grid ─────────────────────────────────────────────────── */

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

.eha-auth-item {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: var(--radius-sm, 6px);
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.eha-auth-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted, #777);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.eha-auth-detail {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted, #666);
  word-break: break-all;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */

.eha-badge {
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.eha-badge--pass    { background: rgba(76, 175, 80, 0.2);  color: #66bb6a; border: 1px solid rgba(76,175,80,0.35); }
.eha-badge--fail    { background: rgba(244, 67, 54, 0.2);  color: #ef5350; border: 1px solid rgba(244,67,54,0.35); }
.eha-badge--softfail{ background: rgba(255,152,0,0.2);     color: #ffa726; border: 1px solid rgba(255,152,0,0.35); }
.eha-badge--neutral { background: rgba(158,158,158,0.15);  color: #9e9e9e; border: 1px solid rgba(158,158,158,0.25); }
.eha-badge--none    { background: rgba(158,158,158,0.1);   color: #757575; border: 1px solid rgba(158,158,158,0.2); }
.eha-badge--error   { background: rgba(255,152,0,0.2);     color: #ffa726; border: 1px solid rgba(255,152,0,0.35); }
.eha-badge--accent  { background: rgba(37,117,252,0.2);    color: var(--accent, #2575fc); border: 1px solid rgba(37,117,252,0.35); }

/* ── Timeline / hops ─────────────────────────────────────────────────────── */

.eha-timeline {
  position: relative;
  padding-left: 2rem;
}

.eha-timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 20px;
  bottom: 20px;
  width: 2px;
  background: linear-gradient(to bottom, #6a11cb, #2575fc);
  border-radius: 2px;
  opacity: 0.5;
}

.eha-hop {
  position: relative;
  display: flex;
  gap: 0.875rem;
  margin-bottom: 0.875rem;
}

.eha-hop:last-child {
  margin-bottom: 0;
}

.eha-hop-index {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.95);
  border: 2px solid var(--border, rgba(255,255,255,0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--muted, #888);
  margin-left: -2rem;
  position: relative;
  z-index: 1;
}

.eha-hop--first .eha-hop-index { border-color: #6a11cb; color: #6a11cb; }
.eha-hop--last  .eha-hop-index { border-color: var(--accent, #2575fc); color: var(--accent, #2575fc); }
.eha-hop--external .eha-hop-index { border-color: rgba(106,17,203,0.6); }

.eha-hop-body {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border, rgba(255,255,255,0.07));
  border-radius: var(--radius-sm, 6px);
  padding: 0.65rem 0.875rem;
}

.eha-hop-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}

.eha-hop-from {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text, #e0e0e0);
}

.eha-hop-ip {
  font-family: 'DM Mono', monospace;
  font-size: 0.74rem;
  background: rgba(255,255,255,0.07);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  color: var(--muted, #aaa);
}

.eha-hop-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--muted, #777);
  flex-wrap: wrap;
}

.eha-protocol {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent, #2575fc);
  background: rgba(37,117,252,0.1);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
}

.eha-hop-date {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted, #666);
  margin-top: 0.3rem;
}

.eha-delay {
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  background: rgba(76,175,80,0.15);
  color: #66bb6a;
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  margin-right: 0.4rem;
}

.eha-delay--warn {
  background: rgba(255,152,0,0.15);
  color: #ffa726;
}

/* ── Geolocation ──────────────────────────────────────────────────────────── */

.eha-geo-placeholder {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  color: var(--muted, #666);
  margin-top: 0.4rem;
}

.eha-geo-result {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--muted, #aaa);
  margin-top: 0.4rem;
}

.eha-geo-org {
  font-size: 0.72rem;
  color: var(--muted, #666);
  margin-left: 0.25rem;
}

/* ── Icon helpers ─────────────────────────────────────────────────────────── */

.eha-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  color: var(--accent, #2575fc);
}

.eha-card-title .eha-icon { color: var(--accent, #2575fc); }

@keyframes eha-spin {
  to { transform: rotate(360deg); }
}

.eha-spin {
  animation: eha-spin 1.2s linear infinite;
}

/* ── Collapsible raw details ──────────────────────────────────────────────── */

.eha-details {
  margin-top: 0.875rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 0.75rem;
}

.eha-details summary {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--muted, #777);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.eha-details summary::-webkit-details-marker { display: none; }

.eha-details summary::before {
  content: '▸';
  font-size: 0.65rem;
  transition: transform 0.2s;
  display: inline-block;
}

.eha-details[open] summary::before {
  transform: rotate(90deg);
}

.eha-pre {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted, #888);
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm, 4px);
  padding: 0.75rem;
  margin-top: 0.5rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

/* ── Error state ──────────────────────────────────────────────────────────── */

.eha-error {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(244, 67, 54, 0.08);
  border: 1px solid rgba(244, 67, 54, 0.25);
  border-radius: var(--radius-sm, 6px);
  padding: 1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: #ef9a9a;
  line-height: 1.5;
}

.eha-error .eha-icon {
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: #ef5350;
}

.eha-error p {
  margin: 0;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .eha-inner {
    padding: 1.5rem 1.25rem;
  }

  .eha-auth-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .eha-dl-row {
    grid-template-columns: 110px 1fr;
  }
}

@media (max-width: 400px) {
  .eha-inner {
    padding: 1.25rem 1rem;
  }

  .eha-hero {
    flex-direction: column;
    gap: 0.75rem;
  }

  .eha-auth-grid {
    grid-template-columns: 1fr;
  }

  .eha-dl-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .eha-dl-row dt {
    margin-bottom: 0.1rem;
  }

  .eha-timeline {
    padding-left: 1.5rem;
  }

  .eha-hop-index {
    margin-left: -1.5rem;
  }
}

/* ── Phishing Score ──────────────────────────────────────────────────────── */

.eha-phishing-card {
  border-color: rgba(255,255,255,0.12);
}

.eha-phishing-score-wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.eha-phishing-score-num {
  font-family: 'DM Mono', monospace;
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eha-phishing-score-right {
  flex: 1;
}

.eha-phishing-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.eha-phishing-bar-bg {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.eha-phishing-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.eha-phishing-signals {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.eha-phishing-signal {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  color: var(--muted, #aaa);
  line-height: 1.5;
}

.eha-phishing-signal-icon {
  flex-shrink: 0;
  margin-top: 0.05rem;
}
