/* ============================================================
   ToolsHub4u — SEO Platform Design System
   Components: score gauge, summary, issue cards, groups, tables,
   alerts, empty/loading/error states, buttons, chips, tags, charts
   Built on the existing CSS custom-property palette.
   ============================================================ */

/* ---------- Score gauge ---------- */
.seo-score { display: flex; justify-content: center; margin: 1rem 0 0.5rem; }
.seo-chart-gauge { width: 150px; height: 150px; max-width: 100%; }
.seo-chart-gauge__val { font-size: 2rem; font-weight: 800; fill: var(--text-primary); }
.seo-chart-gauge__label { font-size: 0.7rem; letter-spacing: 0.05em; fill: var(--text-tertiary); text-transform: uppercase; }

/* ---------- Executive summary ---------- */
.seo-summary {
  margin: 0.9rem 0;
  padding: 1rem 1.1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.65;
}

/* ---------- Issue groups ---------- */
.seo-group { margin: 1.1rem 0; }
.seo-group__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}
.seo-group--error .seo-group__title { color: #ef4444; }
.seo-group--warning .seo-group__title { color: #b45309; }
.seo-group--pass .seo-group__title { color: #10b981; }

/* ---------- Issue card ---------- */
.seo-issue {
  margin: 0 0 0.6rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}
.seo-issue--error { border-left-color: #ef4444; }
.seo-issue--warning { border-left-color: #f59e0b; }
.seo-issue--pass { border-left-color: #10b981; }
.seo-issue__problem { margin: 0 0 0.35rem; font-weight: 600; }
.seo-issue__why, .seo-issue__fix { margin: 0.25rem 0; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; }
.seo-issue__code {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.8rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.8rem;
}
.seo-issue__action {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.seo-issue__action:hover, .seo-issue__action:focus-visible { text-decoration: underline; }

/* ---------- Tags / chips ---------- */
.seo-tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.seo-tag--error { background: color-mix(in srgb, #ef4444 14%, transparent); color: #ef4444; }
.seo-tag--warning { background: color-mix(in srgb, #f59e0b 14%, transparent); color: #b45309; }
.seo-tag--pass { background: color-mix(in srgb, #10b981 14%, transparent); color: #059669; }
.seo-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.seo-chip:hover { border-color: var(--primary); }
.seo-chip[aria-pressed="true"], .seo-chip--active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }

/* ---------- Buttons ---------- */
.seo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.seo-btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.seo-btn--primary:hover { filter: brightness(1.08); }
.seo-btn--ghost { background: transparent; }
.seo-btn--danger { border-color: color-mix(in srgb, #ef4444 40%, transparent); color: #ef4444; }
.seo-btn:hover, .seo-btn:focus-visible { border-color: var(--primary); }
.seo-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Tables ---------- */
.seo-scroll { overflow-x: auto; max-height: 480px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.seo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}
.seo-table th, .seo-table td {
  padding: 0.55rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.seo-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.seo-table tbody tr:hover { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.seo-table--sortable th[data-sort] { cursor: pointer; user-select: none; }
.seo-table--sortable th[data-sort]:hover { color: var(--text-primary); }

/* ---------- Alerts / empty / loading / error ---------- */
.seo-alert {
  margin: 0.8rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.6;
}
.seo-alert--info { border-left: 4px solid var(--primary); }
.seo-alert--success { border-left: 4px solid #10b981; }
.seo-alert--warning { border-left: 4px solid #f59e0b; }
.seo-alert--error { border-left: 4px solid #ef4444; color: #ef4444; }
.seo-empty {
  margin: 1rem 0;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-tertiary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}
.seo-empty p { margin: 0 0 0.8rem; }
.seo-loading { display: flex; align-items: center; gap: 0.7rem; color: var(--text-secondary); font-size: 0.88rem; padding: 1rem 0; }
.seo-loading__bar {
  width: 120px;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--border);
  position: relative;
}
.seo-loading__bar::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: 2px;
  background: var(--primary);
  animation: seo-slide 1.1s ease-in-out infinite;
}
@keyframes seo-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ---------- Detail / audit shell ---------- */
.seo-detail { margin-top: 1.2rem; }
.seo-audit { margin: 1rem 0; }
.seo-actions-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.8rem 0; }

/* ---------- Charts ---------- */
.seo-chart-bar, .seo-chart-donut { max-width: 100%; height: auto; }
.seo-chart__tick { font-size: 10px; fill: var(--text-tertiary); }

/* ---------- Bulk progress ---------- */
.seo-progress {
  margin: 0.8rem 0;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
}
.seo-progress__bar { height: 100%; background: var(--primary); transition: width 0.2s ease; }
.seo-progress__text { font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.3rem; }

/* ---------- History ---------- */
.seo-history {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
}
.seo-history__title { margin: 0 0 0.5rem; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); }
.seo-history__list { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }
.seo-history__item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; }
.seo-history__link { color: var(--primary); text-decoration: none; }
.seo-history__link:hover { text-decoration: underline; }
.seo-history__score { font-weight: 700; }

/* ---------- Visible keyboard focus ---------- */
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary, #6366f1) 60%, transparent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .seo-loading__bar::after { animation: none; }
  .seo-btn, .seo-chip, .seo-issue, .seo-table tbody tr { transition: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .seo-btn { width: 100%; }
  .seo-actions-row .seo-btn { width: auto; flex: 1 1 45%; }
  .seo-score { margin-top: 0.5rem; }
}
