/* AI Visibility Audit — Cloudflare rewrite. Dark dashboard, ported from the original Streamlit theme. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #111827;
  color: #e2e8f0;
  font-size: 14px;
}
h1, h2, h3, h4 { color: #f8fafc; }
a { color: #93c5fd; }
hr { border: none; border-top: 1px solid #2d3748; margin: 0.9rem 0; }

#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 320px; flex-shrink: 0;
  background: #1a2133; border-right: 1px solid #2d3748;
  padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-title { font-size: 1rem; margin: 0 0 0.5rem; }
.sidebar-footer { margin-top: auto; padding-top: 1rem; }
.version { color: #64748b; font-size: 0.7rem; text-align: center; margin-top: 0.75rem; }

.panel { background: #1e2a3e; border: 1px solid #2d3748; border-radius: 8px; }
.panel > summary {
  cursor: pointer; padding: 0.7rem 0.9rem; font-weight: 600; font-size: 0.8rem;
  color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em; list-style: none;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before { content: "▸ "; color: #64748b; }
.panel[open] > summary::before { content: "▾ "; }
.panel-body { padding: 0 0.9rem 0.9rem; display: flex; flex-direction: column; gap: 0.4rem; }

/* ── Main ── */
.main { flex: 1; padding: 1.75rem 2.25rem; max-width: 1400px; }
.section-head { margin: 1.25rem 0 0.75rem; }

.hero {
  background: linear-gradient(135deg, #111827 0%, #1e2a3e 100%);
  border: 1px solid #2d3748; border-radius: 16px; padding: 2rem 2.5rem; margin-bottom: 0.5rem;
}
.hero-badge {
  display: inline-block; background: #1e3a5f; color: #7dd3fc; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; padding: 0.2em 0.7em; letter-spacing: 0.05em;
  text-transform: uppercase; margin-bottom: 0.6rem;
}
.hero h1 { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.25rem; }
.hero p { color: #94a3b8; font-size: 0.9rem; margin: 0; }

/* ── Inputs ── */
label { color: #cbd5e1; font-weight: 500; font-size: 0.8rem; margin-top: 0.3rem; }
label.checkbox { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
input[type=text], input[type=password], select, textarea {
  background: #1e2a3e; border: 1px solid #2d3748; border-radius: 8px;
  color: #f1f5f9; padding: 0.5rem 0.7rem; font-size: 0.85rem; font-family: inherit; width: 100%;
}
input::placeholder, textarea::placeholder { color: #4b5563; }
input[type=range] { width: 100%; }
.opt { color: #64748b; font-size: 0.7rem; font-weight: 400; }
.hint { color: #94a3b8; font-size: 0.78rem; margin: 0.25rem 0; }

/* ── Buttons ── */
button { cursor: pointer; font-family: inherit; }
.btn-primary {
  background: linear-gradient(135deg, #1d4ed8, #2563eb); color: #fff; border: none;
  border-radius: 8px; font-weight: 600; font-size: 0.9rem; padding: 0.6rem 1.5rem;
  margin: 1rem 0; box-shadow: 0 2px 8px rgba(37,99,235,0.35); transition: all 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37,99,235,0.5); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: #1e2a3e; border: 1px solid #3b82f6; color: #93c5fd; font-weight: 500;
  border-radius: 8px; padding: 0.45rem 0.9rem; font-size: 0.8rem;
}
.btn-secondary:hover { background: #24334d; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary.full { width: 100%; margin-bottom: 0.3rem; }
.row { display: flex; gap: 0.5rem; }
.row .btn-secondary { flex: 1; }

/* ── Setup grid ── */
.setup-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.card {
  background: #1a2133; border: 1px solid #2d3748; border-radius: 12px;
  padding: 1.25rem; display: flex; flex-direction: column; gap: 0.35rem;
}

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; background: #1a2133; border-radius: 8px; padding: 4px; margin: 1.5rem 0 1rem; width: fit-content; }
.tab { background: transparent; border: none; border-radius: 6px; color: #94a3b8; font-weight: 500; font-size: 0.875rem; padding: 0.45rem 1.1rem; }
.tab.active { background: #1e3a5f; color: #93c5fd; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.info-box {
  background: rgba(30,58,95,0.2); border-left: 3px solid #3b82f6; border-radius: 0 8px 8px 0;
  padding: 0.75rem 1rem; font-size: 0.85rem; color: #bae6fd; margin: 0.5rem 0 1rem;
}

/* ── Category checkboxes ── */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1.5rem; }
.cat-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: #e2e8f0; }
.cat-item .count { color: #64748b; font-size: 0.75rem; }

/* ── Metrics ── */
.metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.75rem; margin: 1rem 0; }
.metric { background: #1e2a3e; border: 1px solid #2d3748; border-radius: 10px; padding: 0.9rem 1rem; }
.metric .label { font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.metric .value { font-size: 1.5rem; font-weight: 700; color: #f1f5f9; margin-top: 0.2rem; }

/* ── Charts ── */
.charts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.chart-card { background: #1a2133; border: 1px solid #2d3748; border-radius: 12px; padding: 1rem; }
.chart-card h4 { margin: 0 0 0.6rem; font-size: 0.85rem; color: #cbd5e1; }
.chart-card canvas { max-height: 220px; }

/* ── Filters ── */
.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin: 1rem 0 0.5rem; align-items: end; }
.multiselect { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip { background: #1e2a3e; border: 1px solid #2d3748; border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.75rem; cursor: pointer; }
.chip.on { background: #1e3a5f; color: #bae6fd; border-color: #3b82f6; }

/* ── Divider ── */
.divider { border-top: 1px solid #2d3748; margin: 1rem 0; }

/* ── Result cards ── */
.results { margin-top: 0.5rem; }
.result { background: #1a2133; border: 1px solid #2d3748; border-radius: 8px; margin-bottom: 0.5rem; overflow: hidden; }
.result summary { cursor: pointer; padding: 0.75rem 1rem; font-size: 0.85rem; list-style: none; color: #e2e8f0; }
.result summary::-webkit-details-marker { display: none; }
.result-body { padding: 1rem; border-top: 1px solid #2d3748; }
.result-cols { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 1rem; margin-bottom: 0.75rem; }
.response-box { background: #0d1117; border-radius: 8px; padding: 1rem; font-size: 0.85rem; color: #cbd5e1; line-height: 1.6; white-space: pre-wrap; }

/* ── Badges ── */
.badge { display: inline-block; padding: 0.2em 0.65em; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-positive { background: #14532d; color: #bbf7d0; }
.badge-neutral  { background: #1e3a5f; color: #bae6fd; }
.badge-negative { background: #450a0a; color: #fecaca; }
.badge-low      { background: #14532d; color: #bbf7d0; }
.badge-medium   { background: #78350f; color: #fde68a; }
.badge-high     { background: #450a0a; color: #fecaca; }

/* GEO bar */
.geo-bar-bg { background: #2d3748; border-radius: 999px; height: 6px; width: 100%; }
.geo-bar-fill { border-radius: 999px; height: 6px; }
.geo-row { display: flex; align-items: center; gap: 8px; }

.note-success { background: rgba(20,83,45,0.4); border-radius: 6px; padding: 0.5rem 0.75rem; color: #bbf7d0; font-size: 0.82rem; margin-top: 0.4rem; }
.note-warn { background: rgba(120,53,15,0.4); border-radius: 6px; padding: 0.5rem 0.75rem; color: #fde68a; font-size: 0.82rem; margin-top: 0.4rem; }
.note-error { background: rgba(69,10,10,0.5); border-radius: 6px; padding: 0.5rem 0.75rem; color: #fecaca; font-size: 0.82rem; margin-top: 0.4rem; }

.cite-pill { display: inline-block; background: #1e3a5f; color: #93c5fd; border-radius: 4px; font-size: 0.7rem; padding: 0.15em 0.5em; margin: 0.1em; word-break: break-all; text-decoration: none; }
.fixbox { background: #1a2e1a; border: 1px solid #166534; border-radius: 8px; padding: 1rem 1.25rem; font-size: 0.85rem; color: #d1fae5; line-height: 1.7; white-space: pre-wrap; margin-top: 0.75rem; }

/* Progress */
.progress-wrap { margin: 0.5rem 0; }
.progress-bar { background: #2d3748; border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { background: #2563eb; height: 100%; width: 0; transition: width 0.2s; }
.progress-label { color: #94a3b8; font-size: 0.8rem; margin-top: 0.3rem; }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(200%);
  background: #1e2a3e; border: 1px solid #3b82f6; color: #e2e8f0; padding: 0.75rem 1.25rem;
  border-radius: 8px; font-size: 0.85rem; transition: transform 0.3s; z-index: 1000; max-width: 90%;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: #ef4444; }

@media (max-width: 1100px) {
  .setup-grid, .charts { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .result-cols { grid-template-columns: 1fr; }
}
