/* SF Crew — SEO Audit: dark theme */

:root {
  --bg: #0e1117;
  --bg-soft: #161b24;
  --card: #1a2130;
  --card-border: #262f42;
  --text: #e6e9f0;
  --muted: #8b94a7;
  --accent: #4f9cf9;
  --accent-soft: #1c3252;
  --ok: #3ecf8e;
  --warn: #f5b942;
  --err: #f2647c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--err); }
.ok { color: var(--ok); }
.loading { color: var(--muted); font-style: italic; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Topbar ---- */

.topbar {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--card-border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { font-size: 1.15rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { color: var(--muted); font-weight: 400; margin-left: 4px; }

.crawl-form { display: flex; gap: 8px; flex: 1; min-width: 300px; justify-content: flex-end; }
.crawl-form input {
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.9rem;
}
.crawl-form input:focus { outline: none; border-color: var(--accent); }
#crawl-domain { width: 280px; }
#crawl-max-urls { width: 130px; }

/* ---- Bottoni ---- */

.btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-block;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-accent { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* ---- Job banner ---- */

.job-banner {
  margin: 18px 0 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 18px;
}
.job-head { display: flex; align-items: center; gap: 12px; }
.job-head #job-dismiss { margin-left: auto; }
.job-phase {
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.job-phase.done { background: rgba(62, 207, 142, 0.15); color: var(--ok); }
.job-phase.error { background: rgba(242, 100, 124, 0.15); color: var(--err); }
.job-domain { color: var(--muted); font-size: 0.9rem; }
.job-meta { margin-top: 8px; font-size: 0.85rem; color: var(--muted); }

.progress {
  margin-top: 10px;
  height: 8px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #7cc0ff);
  border-radius: 6px;
  transition: width 0.6s ease;
}
.progress-fill.indeterminate { animation: slide 1.6s ease-in-out infinite; }
@keyframes slide {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

/* ---- Card & tabelle ---- */

.page-title { font-size: 1.5rem; margin: 26px 0 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.card h2 { font-size: 1.05rem; margin: 0 0 12px; }
.table-wrap { overflow-x: auto; padding: 0; }
.card.table-wrap { padding: 6px 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--card-border); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 6px; }
.domain-link { font-weight: 600; }

/* ---- Badge ---- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-count { background: var(--accent-soft); color: var(--accent); }
.type-issue { background: rgba(242, 100, 124, 0.15); color: var(--err); }
.type-warning { background: rgba(245, 185, 66, 0.15); color: var(--warn); }
.type-opportunity { background: rgba(79, 156, 249, 0.15); color: var(--accent); }
.prio-high { background: rgba(242, 100, 124, 0.15); color: var(--err); }
.prio-medium { background: rgba(245, 185, 66, 0.15); color: var(--warn); }
.prio-low { background: rgba(139, 148, 167, 0.15); color: var(--muted); }

.score {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.score.s3 { background: rgba(242, 100, 124, 0.18); color: var(--err); }
.score.s2 { background: rgba(245, 185, 66, 0.18); color: var(--warn); }
.score.s1 { background: rgba(62, 207, 142, 0.15); color: var(--ok); }

/* ---- Dettaglio ---- */

.detail-head { margin-top: 26px; }
.back { font-size: 0.85rem; color: var(--muted); }
.detail-head .page-title { margin: 6px 0 4px; }
.detail-meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 18px; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 980px) { .detail-grid { grid-template-columns: 1fr; } }

.summary-body { white-space: pre-wrap; font-size: 0.92rem; }

.issues-table .issue-row { cursor: pointer; }
.issues-table .issue-row:hover td { background: var(--bg-soft); }
.issue-name { font-weight: 500; }
.issue-urls td { background: var(--bg); font-size: 0.82rem; }
.url-list { margin: 4px 0; padding-left: 18px; max-height: 260px; overflow-y: auto; }
.url-list li { word-break: break-all; }

/* ---- Chat ---- */

.chat-panel {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 110px);
}
.chat-head { display: flex; align-items: center; justify-content: space-between; }
.chat-head h2 { margin: 0; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
}
.bubble {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--bg-soft); border: 1px solid var(--card-border); border-bottom-left-radius: 4px; }
.bubble.typing { color: var(--muted); font-style: italic; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

.chat-input { display: flex; gap: 8px; }
.chat-input textarea {
  flex: 1;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.9rem;
}
.chat-input textarea:focus { outline: none; border-color: var(--accent); }

/* ---- Stato vuoto ---- */

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}
.empty h2 { color: var(--text); margin-bottom: 8px; }
