/* ============================================================
   Kings Research — SEO Audit Dashboard
   ============================================================ */

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

:root {
  --navy:      #1a2332;
  --navy-light:#243044;
  --orange:    #f97316;
  --orange-dk: #ea6c0a;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --green:     #10b981;
  --blue:      #3b82f6;
  --amber:     #f59e0b;
  --red:       #ef4444;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius:    8px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

a { color: inherit; text-decoration: none; }

/* ── Navbar ──────────────────────────────────────────────── */
.navbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.navbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.navbar-brand .logo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.navbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: #94a3b8; }
.navbar-right strong { color: #e2e8f0; }
.btn-logout {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #cbd5e1;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.14); }

/* ── Page wrapper ─────────────────────────────────────────── */
.page { max-width: 1400px; margin: 0 auto; padding: 24px 24px 48px; }

/* ── Stats row ───────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase;
              letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-value.orange { color: var(--orange); }
.stat-value.green  { color: var(--green); }
.stat-value.red    { color: var(--red); }

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-tabs { display: flex; gap: 4px; }
.tab {
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: all .15s;
}
.tab:hover  { border-color: var(--orange); color: var(--orange); }
.tab.active { background: var(--orange); border-color: var(--orange); color: #fff; }

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.search-box input:focus { border-color: var(--orange); }
.search-box .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px;
}

/* Category filter select */
.cat-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  outline: none;
  max-width: 180px;
  transition: border-color .15s;
}
.cat-select:focus { border-color: var(--orange); }

/* Smart batch button group */
.batch-group {
  margin-left: auto;
  position: relative;
  display: flex;
}
.btn-batch-main {
  padding: 7px 14px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  border-right: 1px solid rgba(255,255,255,.15);
}
.btn-batch-main:hover { background: var(--navy-light); }
.btn-batch-arrow {
  padding: 7px 10px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 0 6px 6px 0;
  font-size: 11px;
  cursor: pointer;
  transition: background .15s;
}
.btn-batch-arrow:hover { background: var(--navy-light); }

/* Batch dropdown menu */
.batch-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 150;
  overflow: hidden;
}
.batch-menu.open { display: block; }
.batch-menu-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 10px 14px 4px;
}
.batch-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: background .1s;
}
.batch-menu-item:hover { background: #f8fafc; }
.bm-icon { font-size: 14px; flex-shrink: 0; width: 16px; text-align: center; }
.bm-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-left: 4px;
}

/* Batch drill-down header */
.batch-drill-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.batch-drill-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  transition: all .12s;
}
.batch-drill-back:hover { border-color: var(--orange); color: var(--orange); }
.batch-drill-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

/* Category accordion in batch menu */
.batch-cat-header { justify-content: flex-start; gap: 8px; }
.bm-cat-name { flex: 1; font-weight: 600; }
.bm-arrow { font-size: 12px; color: var(--muted); margin-left: auto; transition: transform .15s; }

.batch-range-list { display: none; background: #f8fafc; border-top: 1px solid var(--border); }
.batch-range-list.open { display: block; }
.batch-range-item { padding-left: 36px; color: var(--muted); font-size: 12px; }
.batch-range-item:hover { background: #f1f5f9; color: var(--orange); }

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

table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f8fafc;
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
tbody td { padding: 12px 16px; vertical-align: middle; }

.col-name  { min-width: 240px; max-width: 340px; }
.col-type  { width: 90px; }
.col-score { width: 100px; }
.col-checks{ width: 110px; }
.col-date  { width: 130px; }
.col-act   { width: 160px; }

/* Report name */
.report-name { font-weight: 600; color: var(--text); font-size: 13px;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.report-url  { font-size: 11px; color: var(--muted); margin-top: 2px;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }

/* Type badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-report { background: #eff6ff; color: #2563eb; }
.badge-blog   { background: #f0fdf4; color: #16a34a; }
.badge-pr     { background: #fdf4ff; color: #9333ea; }

/* Score pill */
.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
}
.score-a  { background: #d1fae5; color: #065f46; }
.score-b  { background: #dbeafe; color: #1e40af; }
.score-c  { background: #fef3c7; color: #92400e; }
.score-d  { background: #ffedd5; color: #9a3412; }
.score-f  { background: #fee2e2; color: #991b1b; }
.score-na { background: #f1f5f9; color: var(--muted); font-size: 11px; font-weight: 500; }

/* Pass/fail counts */
.check-counts { font-size: 12px; }
.pass-count { color: var(--green); font-weight: 600; }
.fail-count { color: var(--red);   font-weight: 600; }

/* Date */
.date-cell { font-size: 12px; color: var(--muted); }

/* Action buttons */
.actions { display: flex; gap: 6px; }
.btn-audit, .btn-view {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-audit {
  background: var(--orange);
  color: #fff;
}
.btn-audit:hover:not(:disabled) { background: var(--orange-dk); }
.btn-audit:disabled { opacity: .5; cursor: not-allowed; }
.btn-audit.running {
  background: #fed7aa;
  color: #c2410c;
  pointer-events: none;
}
.btn-view {
  background: #f1f5f9;
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn-view:hover { background: #e2e8f0; }
.btn-view:disabled { opacity: .4; cursor: not-allowed; }

/* Spinner inline */
.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-right: 4px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty / loading states */
.table-msg { text-align: center; padding: 48px 16px; color: var(--muted); }
.table-msg .icon { font-size: 32px; margin-bottom: 8px; }

/* ── Results panel (slide-in) ────────────────────────────── */
.panel-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
}
.panel-overlay.open { display: block; }

.results-panel {
  position: fixed;
  top: 0; right: -680px;
  width: 660px;
  height: 100vh;
  background: var(--card);
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.results-panel.open { right: 0; }

.panel-header {
  background: var(--navy);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.panel-title { font-size: 14px; font-weight: 700; line-height: 1.4; }
.panel-url   { font-size: 11px; color: #94a3b8; margin-top: 2px; word-break: break-all; }
.panel-close {
  background: none; border: none; color: #94a3b8;
  font-size: 20px; cursor: pointer; flex-shrink: 0; padding: 0 4px;
  line-height: 1;
}
.panel-close:hover { color: #fff; }

.panel-body { flex: 1; overflow-y: auto; padding: 20px; }

/* Score hero */
.score-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.score-big {
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
}
.score-meta { flex: 1; }
.score-grade {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.score-info { font-size: 12px; color: var(--muted); }

/* Category scores */
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 10px;
}
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.cat-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
}
.cat-name  { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
.cat-score { font-size: 20px; font-weight: 700; }

/* Core Web Vitals breakdown */
.vitals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}
.vitals-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.vitals-label    { font-size: 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.vitals-value    { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.vitals-threshold{ font-size: 10px; color: var(--muted); }

/* Priority fixes */
.fixes-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.fix-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 6px;
  border-left: 3px solid transparent;
  background: #f8fafc;
  border: 1px solid var(--border);
}
.fix-item.p1 { border-left-color: var(--red);   }
.fix-item.p2 { border-left-color: var(--amber);  }
.fix-item.p3 { border-left-color: var(--blue);   }
.fix-item.p4 { border-left-color: var(--muted);  }

.fix-priority {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 1px;
}
.p1 .fix-priority { background: #fee2e2; color: #991b1b; }
.p2 .fix-priority { background: #fef3c7; color: #92400e; }
.p3 .fix-priority { background: #dbeafe; color: #1e40af; }
.p4 .fix-priority { background: #f1f5f9; color: var(--muted); }

.fix-content { flex: 1; }
.fix-label   { font-weight: 600; font-size: 13px; color: var(--text); }
.fix-issue   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.fix-action  { font-size: 12px; color: var(--orange); margin-top: 3px; font-weight: 500; }

/* Checks accordion */
.checks-section { margin-bottom: 20px; }
.check-category { margin-bottom: 8px; }
.check-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 13px;
}
.check-cat-header:hover { background: #f1f5f9; }
.check-cat-header .cat-score-sm {
  font-size: 13px;
  font-weight: 700;
}
.check-cat-body { display: none; border: 1px solid var(--border); border-top: none;
                  border-radius: 0 0 6px 6px; overflow: hidden; }
.check-cat-body.open { display: block; }

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
}
.check-row:last-child { border-bottom: none; }
.check-icon { flex-shrink: 0; margin-top: 1px; }
.check-icon.pass { color: var(--green); }
.check-icon.fail { color: var(--red); }
.check-label { font-weight: 500; color: var(--text); }
.check-value { color: var(--muted); font-size: 11px; margin-top: 1px; }

/* ── Panel loading state ────────────────────────────────── */
.panel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  gap: 16px;
  color: var(--muted);
}
.panel-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.panel-status { font-size: 13px; }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #243760 100%);
}
.login-card {
  background: var(--card);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-text { font-size: 18px; font-weight: 800; color: var(--navy); }
.login-logo .logo-sub  { font-size: 12px; color: var(--muted); margin-top: 4px; }
.login-logo .logo-accent { color: var(--orange); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600;
                    color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249,115,22,.1); }

.btn-login {
  width: 100%;
  padding: 11px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-login:hover:not(:disabled) { background: var(--orange-dk); }
.btn-login:disabled { opacity: .65; cursor: not-allowed; }
.btn-login .spinner { border-color: rgba(255,255,255,.3); border-top-color: #fff; }

.login-error {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 14px;
  display: none;
}
.login-error.show { display: block; }

/* ── Audit progress banner ───────────────────────────────── */
.audit-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--navy);
  color: #fff;
  z-index: 300;
  padding: 0;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 -4px 20px rgba(0,0,0,.25);
}
.audit-banner.show { transform: translateY(0); }

.audit-banner-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.audit-banner-info { flex: 1; min-width: 0; }
.audit-banner-title {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audit-banner-status {
  font-size: 12px;
  color: #94a3b8;
}

.audit-banner-bar-wrap {
  flex: 1;
  max-width: 360px;
  background: rgba(255,255,255,.1);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}
.audit-banner-bar {
  height: 100%;
  background: var(--orange);
  border-radius: 4px;
  width: 0%;
  transition: width .5s ease;
}

.audit-banner-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--orange);
  min-width: 38px;
  text-align: right;
}

.audit-banner-warn {
  font-size: 11px;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  gap: 12px;
}
.pg-info { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pg-btns { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pg-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all .12s;
  font-weight: 500;
}
.pg-btn:hover:not(:disabled):not(.active) { border-color: var(--orange); color: var(--orange); }
.pg-btn.active { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.pg-btn:disabled { opacity: .35; cursor: not-allowed; }
.pg-nav { font-size: 16px; }
.pg-ellipsis { font-size: 13px; color: var(--muted); padding: 0 4px; line-height: 32px; }

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
