/* ============================================================
   SEO Analyser Pro – Main Stylesheet
   Aesthetic: Dark Industrial · Refined · High-contrast accents
   Fonts: Syne (display) · DM Sans (body) · DM Mono (code/data)
   ============================================================ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg-base:     #0A0A0F;
  --bg-surface:  #111118;
  --bg-elevated: #18181F;
  --bg-hover:    #1F1F28;

  --border:      rgba(255,255,255,.07);
  --border-mid:  rgba(255,255,255,.12);

  --text-primary:   #F0F0F8;
  --text-secondary: #9CA3AF;
  --text-muted:     #4B5563;

  --accent:      #7C6BFF;
  --accent-glow: rgba(124,107,255,.25);
  --teal:        #1ECBCB;
  --teal-glow:   rgba(30,203,203,.2);
  --amber:       #F59E0B;
  --red:         #EF4444;
  --green:       #10B981;

  --sidebar-w:   240px;
  --topbar-h:    60px;
  --radius:      10px;
  --radius-sm:   6px;

  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.4rem 1.2rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: -.5px;
}
.logo-icon {
  color: var(--accent);
  font-size: 1.4rem;
  line-height: 1;
}
.logo-text strong { color: var(--accent); }

/* Project selector */
.project-selector {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border);
}
.selector-label {
  display: block;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .35rem;
}
.project-selector select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
  font-family: var(--font-body);
  font-size: .85rem;
  cursor: pointer;
  outline: none;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: .6rem 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem 1.2rem;
  font-size: .9rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: all .15s;
}
.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(124,107,255,.08);
}
.nav-icon { font-size: 1rem; opacity: .8; }

.sidebar-footer {
  padding: .8rem 1.2rem;
  font-size: .72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── Main Layout ─────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.page-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.3px;
}
.domain-badge {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: .25rem .7rem;
  border-radius: 20px;
}
.status-dot {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--green);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .3rem;
}
.hamburger span {
  display: block;
  width: 20px; height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
}

/* Page body */
.page-body {
  padding: 1.5rem;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.2px;
}
.card-link {
  font-size: .8rem;
  color: var(--accent);
  transition: opacity .15s;
}
.card-link:hover { opacity: .7; }
.mt-4 { margin-top: 1.25rem; }

/* ── KPI Grid ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--text-muted);
}
.kpi-good::before { background: var(--green); box-shadow: 0 0 12px rgba(16,185,129,.5); }
.kpi-warn::before { background: var(--amber); box-shadow: 0 0 12px rgba(245,158,11,.5); }
.kpi-bad::before  { background: var(--red);   box-shadow: 0 0 12px rgba(239,68,68,.5); }
.kpi-neutral::before { background: var(--accent); }

.kpi-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}
.kpi-unit { font-size: 1rem; color: var(--text-muted); font-weight: 400; }
.kpi-label {
  font-size: .78rem;
  color: var(--text-secondary);
  margin-top: .4rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.kpi-sub {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ── Dashboard Grid ──────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
}

/* ── Meta info bar ───────────────────────────────────────────── */
.meta-info {
  font-size: .8rem;
  color: var(--text-muted);
  padding: .6rem 0;
  margin-bottom: .75rem;
}
.meta-info strong { color: var(--text-secondary); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table th {
  text-align: left;
  padding: .7rem 1rem;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-family: var(--font-display);
}
.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text-secondary);
}
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .text-center { text-align: center; }
.keyword-cell { color: var(--text-primary); font-weight: 500; }
.url-cell { font-family: var(--font-mono); font-size: .75rem; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-cell { font-family: var(--font-mono); font-size: .78rem; white-space: nowrap; }
.text-muted { color: var(--text-muted); }

/* Comparison table self column */
.self-col { background: rgba(124,107,255,.04); }
.avg-row td { border-top: 1px solid var(--border-mid); }

/* ── Position Badges ─────────────────────────────────────────── */
.position-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 500;
  padding: .2rem .55rem;
  border-radius: 4px;
  min-width: 40px;
  text-align: center;
}
.pos-top3  { background: rgba(16,185,129,.15); color: var(--green); border: 1px solid rgba(16,185,129,.3); }
.pos-top10 { background: rgba(30,203,203,.1);  color: var(--teal);  border: 1px solid rgba(30,203,203,.25); }
.pos-top30 { background: rgba(245,158,11,.1);  color: var(--amber); border: 1px solid rgba(245,158,11,.25); }
.pos-low   { background: rgba(239,68,68,.1);   color: var(--red);   border: 1px solid rgba(239,68,68,.25); }
.pos-none  { background: var(--bg-elevated);   color: var(--text-muted); border: 1px solid var(--border); }

/* Trend */
.trend { font-size: .75rem; font-weight: 700; }
.trend-up    { color: var(--green); }
.trend-down  { color: var(--red); }
.trend-stable{ color: var(--text-muted); }
.trend-new   { font-size: .65rem; background: var(--accent); color: #fff; border-radius: 3px; padding: 1px 4px; }

/* Score pills */
.score-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .8rem;
  font-weight: 500;
  padding: .2rem .5rem;
  border-radius: 4px;
  min-width: 36px;
  text-align: center;
}
.score-good { background: rgba(16,185,129,.15); color: var(--green); }
.score-warn { background: rgba(245,158,11,.15); color: var(--amber); }
.score-bad  { background: rgba(239,68,68,.15);  color: var(--red); }

/* Source badge */
.source-badge { font-size: .72rem; padding: .15rem .45rem; border-radius: 3px; }
.source-mock   { background: rgba(124,107,255,.15); color: var(--accent); }
.source-api    { background: rgba(30,203,203,.15);  color: var(--teal); }
.source-manual { background: rgba(245,158,11,.15);  color: var(--amber); }

/* ── Issues ──────────────────────────────────────────────────── */
.issue-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: .84rem;
}
.issue-badge {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .15rem .45rem;
  border-radius: 3px;
  white-space: nowrap;
}
.severity-critical .issue-badge { background: rgba(239,68,68,.15);   color: var(--red); }
.severity-warning  .issue-badge { background: rgba(245,158,11,.15);  color: var(--amber); }
.severity-info     .issue-badge { background: rgba(30,203,203,.1);   color: var(--teal); }
.issue-text { color: var(--text-secondary); }

/* Issue detail */
.issue-detail {
  padding: .8rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.issue-detail-header { display: flex; align-items: center; gap: .6rem; margin-bottom: .3rem; }
.issue-detail-desc { font-size: .83rem; color: var(--text-muted); line-height: 1.5; padding-left: calc(.65rem + 0.45rem + .6rem); }

/* Suggestions */
.suggestion-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  padding: .8rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: .83rem;
}
.suggestion-key { font-family: var(--font-mono); font-size: .75rem; color: var(--accent); text-transform: uppercase; }
.suggestion-text { color: var(--text-secondary); line-height: 1.5; }
.more-issues { font-size: .8rem; color: var(--text-muted); padding: .6rem 1.25rem; }
.success-text { color: var(--green); }
.padded { padding: 1rem 1.25rem; }

/* ── Analyze Page ────────────────────────────────────────────── */
.analyze-form { padding: 1.25rem; }
.input-group { display: flex; gap: .75rem; align-items: stretch; }
.form-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: .6rem .9rem;
  font-family: var(--font-body);
  font-size: .9rem;
  outline: none;
  transition: border-color .2s;
}
.form-input:focus { border-color: var(--accent); }
.form-input-lg { font-size: 1rem; padding: .75rem 1rem; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .5rem; }

/* Progress */
.progress-bar {
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 2px;
  margin: 1rem 1.25rem .5rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  border-radius: 2px;
  width: 0;
  transition: width .4s ease;
}
.progress-text { font-size: .8rem; color: var(--text-muted); text-align: center; padding-bottom: 1rem; }

/* Score Overview */
.score-overview {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 2.5rem;
  margin-top: 1.25rem;
}
.score-main { text-align: center; }
.score-circle {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto .5rem;
}
.score-circle svg { transform: rotate(-90deg); }
.score-bg  { fill: none; stroke: var(--bg-elevated); stroke-width: 8; }
.score-arc { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .8s ease, stroke .4s; }
.score-number {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
}
.score-label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

.score-details { flex: 1; }
.score-item { margin-bottom: 1rem; }
.score-item-label { font-size: .8rem; color: var(--text-secondary); margin-bottom: .4rem; }
.score-bar-wrap { display: flex; align-items: center; gap: .75rem; }
.score-bar { flex: 1; height: 6px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; width: 0; transition: width .8s ease; }
.score-item-val { font-family: var(--font-mono); font-size: .85rem; min-width: 28px; text-align: right; }

/* Audit Grid */
.audit-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .6rem;
  margin-top: 1.25rem;
}
.audit-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .8rem;
  text-align: center;
  transition: border-color .2s;
}
.audit-ok   { border-color: rgba(16,185,129,.25); }
.audit-fail { border-color: rgba(239,68,68,.2); }
.audit-icon { font-size: 1rem; margin-bottom: .3rem; }
.audit-ok   .audit-icon { color: var(--green); }
.audit-fail .audit-icon { color: var(--red); }
.audit-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.audit-value { font-size: .8rem; color: var(--text-secondary); margin-top: .2rem; font-family: var(--font-mono); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover {
  background: #8f7fff;
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border-mid);
}
.btn-secondary:hover { color: var(--text-primary); border-color: var(--accent); }
.btn-lg { padding: .75rem 1.4rem; font-size: .95rem; }
.btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-icon {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: .3rem .5rem;
  cursor: pointer;
  font-size: .85rem;
  transition: all .15s;
  margin: 0 2px;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon-danger:hover { border-color: var(--red); color: var(--red); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8rem; color: var(--text-secondary); margin-bottom: .4rem; }
.inline-form {
  display: flex;
  gap: .75rem;
  padding: 1.25rem;
  align-items: center;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: modalIn .2s ease;
}
.modal-lg { width: 720px; }
@keyframes modalIn {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-family: var(--font-display); font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: .2rem;
  transition: color .15s;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 1.25rem; }

/* ── Empty States ────────────────────────────────────────────── */
.hidden { display: none !important; }
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-icon { font-size: 3rem; color: var(--text-muted); margin-bottom: 1rem; }
.empty-state h2 { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: .5rem; }
.empty-state p { color: var(--text-secondary); margin-bottom: 1.5rem; }
.empty-mini {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
  line-height: 1.6;
}
.link { color: var(--accent); }
.link:hover { text-decoration: underline; }

/* ── Charts ─────────────────────────────────────────────────── */
.chart-wrap { height: 220px; padding: 1rem; }

/* ── Alert ──────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  margin-bottom: 1rem;
}
.alert-success { background: rgba(16,185,129,.1); color: var(--green); border: 1px solid rgba(16,185,129,.3); }
.alert-warning { background: rgba(245,158,11,.1);  color: var(--amber); border: 1px solid rgba(245,158,11,.3); }

/* ── Competitors ─────────────────────────────────────────────── */
.competitor-list { padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .6rem; }
.competitor-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .7rem 1rem;
}
.competitor-info { display: flex; flex-direction: column; gap: .2rem; }
.competitor-info strong { font-size: .9rem; }
.domain-tag { font-family: var(--font-mono); font-size: .75rem; color: var(--text-muted); }

/* Badge */
.badge {
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 10px;
  font-family: var(--font-mono);
}

/* Section title */
.section-title {
  font-family: var(--font-display);
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .75rem 1.25rem .25rem;
}
.mt-3 { margin-top: .75rem; }

/* Settings info grid */
.info-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1px; background: var(--border); margin: 1px; }
.info-item {
  background: var(--bg-surface);
  padding: .9rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.info-item span { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.info-item strong { font-family: var(--font-mono); font-size: .85rem; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid    { grid-template-columns: repeat(2, 1fr); }
  .audit-grid  { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .info-grid   { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .audit-grid { grid-template-columns: repeat(2, 1fr); }
  .score-overview { flex-direction: column; gap: 1.5rem; }
  .input-group { flex-direction: column; }
  .inline-form { flex-direction: column; }
  .page-body { padding: 1rem; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .audit-grid { grid-template-columns: repeat(2, 1fr); }
}
