/* ============================================================
   SEO Toolbox – Main Stylesheet
   Dark engineering aesthetic | matches websitereactor.com
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────── */
:root {
  --bg-base:       #09090f;
  --bg-surface:    #0f1018;
  --bg-elevated:   #141520;
  --bg-card:       #161824;
  --border:        #1e2235;
  --border-accent: #2a3060;

  --text-primary:  #e8eaf0;
  --text-secondary:#9ba3c2;
  --text-muted:    #5a6280;

  --accent:        #3b82f6;
  --accent-bright: #60a5fa;
  --accent-dim:    #1d3a6e;
  --accent-glow:   rgba(59,130,246,0.15);

  --green:         #10b981;
  --green-dim:     rgba(16,185,129,0.12);
  --red:           #ef4444;
  --red-dim:       rgba(239,68,68,0.12);
  --yellow:        #f59e0b;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;

  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 0 0 1px var(--border);
  --shadow-glow: 0 0 24px var(--accent-glow);

  --nav-height: 60px;
  --content-max: 1400px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
button { cursor: pointer; font: inherit; }
input, textarea, select { font: inherit; }

/* ── Login Screen ───────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(59,130,246,0.08) 0%, transparent 70%),
    var(--bg-base);
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-card);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.login-logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.login-logo-text {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.login-logo-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.login-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
  letter-spacing: -0.02em;
}

.login-sub {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.125rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.form-error {
  color: var(--red);
  font-size: 0.8125rem;
  margin-top: 0.75rem;
  display: none;
}

.form-error.visible { display: block; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: #2563eb; }

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover {
  background: var(--red-dim);
}

.btn-success {
  background: transparent;
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.3);
}

.btn-success:hover { background: var(--green-dim); }

.btn-full { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── App Shell ──────────────────────────────────────────── */
#app { display: none; min-height: 100vh; }

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(9,9,15,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}

.nav-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.nav-brand-text {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.nav-brand-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--accent-bright);
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  padding: 0.1rem 0.4rem;
  border-radius: 100px;
  letter-spacing: 0.05em;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Main Content ───────────────────────────────────────── */
.main-content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header-left {}

.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-bright);
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  padding: 0.25rem 0.6rem;
  border-radius: 100px;
  margin-bottom: 0.75rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.page-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Dashboard Cards ────────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  text-decoration: none;
  display: block;
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  opacity: 0;
  transition: opacity 0.2s;
}

.tool-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
  text-decoration: none;
}

.tool-card:hover::before { opacity: 1; }

.tool-card-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

.tool-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.tool-card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: none;
}

.tool-card-meta {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Citation Manager ───────────────────────────────────── */
#citation-view { display: none; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sort-select {
  padding: 0.45rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  outline: none;
}

.sort-select:focus { border-color: var(--accent); }

/* ── Citation Table ─────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

th:hover { color: var(--text-secondary); }

th .sort-icon {
  margin-left: 0.25rem;
  opacity: 0.4;
}

th.sorted .sort-icon { opacity: 1; color: var(--accent-bright); }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--bg-elevated); }

td {
  padding: 0.875rem 1rem;
  vertical-align: middle;
}

/* ── Status Light ───────────────────────────────────────── */
.status-light {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  cursor: help;
}

.status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
}

.status-dot:hover::after { opacity: 1; }

.status-dot.up {
  background: var(--green);
  box-shadow: 0 0 8px rgba(16,185,129,0.6);
}

.status-dot.up::after { background: rgba(16,185,129,0.2); }

.status-dot.down {
  background: var(--red);
  box-shadow: 0 0 8px rgba(239,68,68,0.6);
}

.status-dot.down::after { background: rgba(239,68,68,0.2); }

.status-dot.unknown {
  background: var(--text-muted);
  box-shadow: none;
}

/* Checked but unverifiable (5xx / WAF / anti-bot) */
.status-dot.unverifiable {
  background: var(--yellow);
  box-shadow: 0 0 8px rgba(245,158,11,0.5);
}

.status-dot.unverifiable::after { background: rgba(245,158,11,0.2); }

/* Tooltip */
[data-tooltip] { position: relative; }

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 50;
}

[data-tooltip]::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 50;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after { opacity: 1; }

/* ── URL Cell ───────────────────────────────────────────── */
.url-cell {
  max-width: 340px;
}

.url-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-bright);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.citation-site-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Campaign Badge ─────────────────────────────────────── */
.campaign-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  color: var(--accent-bright);
  white-space: nowrap;
}

.campaign-badge.none {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-muted);
}

.campaign-select {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.4rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  color: var(--accent-bright);
  white-space: nowrap;
  cursor: pointer;
  max-width: 160px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  padding-right: 1.4rem;
}

/* ── Color Swatch Picker ─────────────────────────────────── */
.color-swatch {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: transform 0.1s, box-shadow 0.1s;
}
.color-swatch[data-selected="1"] {
  transform: scale(1.25);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px currentColor;
}

/* ── Backlinks ──────────────────────────────────────────── */
.backlink-count {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.backlink-count.none { color: var(--text-muted); }

/* ── Actions Column ─────────────────────────────────────── */
.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 0.375rem;
  align-items: center;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  overflow: hidden;
}

.modal-header {
  padding: 1.375rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.625rem;
}

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-title { font-size: 1.125rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-sub { font-size: 0.875rem; }

/* ── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: slide-in 0.2s ease;
  max-width: 320px;
}

.toast.success { border-color: rgba(16,185,129,0.4); }
.toast.error   { border-color: rgba(239,68,68,0.4); }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}

/* ── Back button / breadcrumb ───────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-family: var(--font-mono);
}

.breadcrumb-sep { opacity: 0.4; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent-bright); text-decoration: none; }
.breadcrumb-current { color: var(--text-secondary); }

/* ── Spinner ────────────────────────────────────────────── */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

/* ── Filter bar ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.search-input {
  padding: 0.45rem 0.875rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  width: 240px;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* ── Stats bar ──────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red); }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 1.25rem 1rem; }
  .page-header { flex-direction: column; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { margin-left: 0; }
  .search-input { width: 100%; }
  th, td { padding: 0.65rem 0.75rem; }
}
