/* ============================================================
   SEOPulse — Stylesheet (GMC-aligned light theme)
   ============================================================ */

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

:root {
  --blue:    #2563eb; --blue-light: #dbeafe; --blue-dark: #1e40af;
  --green:   #16a34a; --green-light: #dcfce7;
  --red:     #dc2626; --red-light: #fee2e2;
  --amber:   #d97706; --amber-light: #fef3c7;
  --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0;
  --slate-400: #94a3b8; --slate-500: #64748b; --slate-700: #334155;
  --slate-800: #1e293b; --slate-900: #0f172a;
  --white: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --radius: 12px;
  --sidebar-w: 220px;
  /* Legacy aliases used by JS-generated markup */
  --primary: var(--blue);
  --primary-hover: var(--blue-dark);
  --text: var(--slate-800);
  --text-muted: var(--slate-500);
  --border: var(--slate-200);
  --bg: var(--slate-100);
  --bg-card: var(--white);
  --bg-input: var(--white);
  --yellow: var(--amber);
}

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

/* ---- Layout ---- */
#app { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-w);
  background: var(--slate-800);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 10;
}

#content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar-header { padding: 20px 18px 14px; }
.logo { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
.logo span { color: #60a5fa; }

.nav-section { padding: 6px 0; }
.nav-label {
  padding: 10px 18px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate-400);
}
.nav-item {
  display: block;
  padding: 7px 18px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.nav-item:hover { color: #e2e8f0; background: rgba(255,255,255,0.06); }
.nav-item.active { color: #fff; border-left-color: var(--blue); background: rgba(37,99,235,0.15); }
.nav-back { color: var(--slate-400); font-size: 12px; }
.nav-back::before { content: '\2190  '; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 8px 18px; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
#user-info { font-size: 12px; color: var(--slate-400); margin-bottom: 4px; padding: 0 0 4px; }

.site-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 18px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.site-item:hover { color: #e2e8f0; background: rgba(255,255,255,0.06); }
.site-item .fav { color: var(--amber); font-size: 10px; }

/* ---- View Container ---- */
.view-container { max-width: 1400px; }

/* ---- Page Header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--slate-900); }
.page-header .subtitle { color: var(--slate-500); font-size: 13px; margin-top: 2px; }

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.metric-card .label { font-size: 11px; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.06em; }
.metric-card .value { font-size: 30px; font-weight: 700; color: var(--slate-900); margin-top: 4px; line-height: 1; }
.metric-card .change { font-size: 12px; margin-top: 6px; color: var(--slate-400); }
.metric-card .change.up { color: var(--green); }
.metric-card .change.down { color: var(--red); }

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--slate-200) transparent;
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .table-wrap { box-shadow: none; border-radius: 0; }
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 3px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 9px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
  background: var(--slate-100);
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: relative;
}
thead th:hover { color: var(--blue); }
thead th.num { text-align: right; }
thead th .sort-icon { margin-left: 4px; font-size: 10px; opacity: 0.4; }
thead th.sort-asc .sort-icon, thead th.sort-desc .sort-icon { opacity: 1; color: var(--blue); }
tbody td {
  padding: 11px 16px;
  border-top: 1px solid var(--slate-100);
  vertical-align: middle;
}
tbody tr:hover td { background: var(--slate-50); }
td.url { max-width: 350px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.query { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Tooltips ---- */
.tip {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted var(--slate-400);
}
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--slate-800);
  color: var(--slate-50);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  line-height: 1.5;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.tip:hover::after { opacity: 1; visibility: visible; }

/* ---- Content Decay Visual ---- */
.decay-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.decay-bar {
  width: 120px;
  height: 8px;
  background: var(--slate-100);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.decay-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.decay-bar-fill.severe { background: var(--red); }
.decay-bar-fill.moderate { background: var(--amber); }
.decay-bar-fill.mild { background: var(--blue); }
.decay-bar-fill.growth { background: var(--green); }

.decay-pct {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 55px;
  text-align: right;
}
.decay-pct.severe { color: var(--red); }
.decay-pct.moderate { color: var(--amber); }
.decay-pct.mild { color: var(--blue); }
.decay-pct.growth { color: var(--green); }

.decay-spark {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
  vertical-align: middle;
}
.decay-spark-bar {
  width: 4px;
  border-radius: 1px;
  background: var(--slate-200);
  min-height: 2px;
}

.decay-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  background: var(--white);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
.decay-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.decay-card .decay-page { font-size: 13px; margin-bottom: 4px; }
.decay-card .decay-meta { font-size: 12px; color: var(--slate-500); display: flex; gap: 16px; }
.decay-card .decay-meta span { display: flex; align-items: center; gap: 4px; }
.decay-card .decay-right { text-align: right; }

/* ---- Badges / Tags ---- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: var(--green-light); color: #166534; }
.badge-red   { background: var(--red-light);   color: #991b1b; }
.badge-yellow { background: var(--amber-light); color: #92400e; }
.badge-blue  { background: var(--blue-light);  color: var(--blue-dark); }
.badge-muted { background: var(--slate-100);   color: var(--slate-500); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-content {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}
.modal-content .card { margin-bottom: 12px; }
.modal-content .metric-grid { margin-bottom: 0; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--slate-200);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--white);
  color: var(--slate-700);
  text-decoration: none;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); opacity: 1; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { color: #991b1b; background: var(--red-light); border-color: rgba(220,38,38,0.2); }
.btn-danger:hover { background: #fecaca; opacity: 1; }
.btn-success { color: #166534; background: var(--green-light); border-color: rgba(22,163,74,0.2); }
.btn-success:hover { background: #bbf7d0; opacity: 1; }
.btn-ghost { background: var(--slate-100); border-color: var(--slate-200); color: var(--slate-700); }
.btn-ghost:hover { background: var(--slate-200); opacity: 1; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Bulk action bar */
.bulk-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; margin-bottom: 12px;
  background: var(--blue-light); border: 1px solid rgba(37,99,235,0.2);
  border-radius: 8px; font-size: 13px; color: var(--slate-800);
}

/* External link style */
a.ext-link {
  color: var(--blue); text-decoration: none;
}
a.ext-link:hover { text-decoration: underline; }
a.ext-link .ext-icon { font-size: 11px; margin-left: 3px; opacity: 0.5; }

/* ---- Forms ---- */
.form-row { display: flex; gap: 12px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; position: relative; z-index: 1; }
.form-group { display: flex; flex-direction: column; gap: 4px; position: relative; }
.form-group label { font-size: 12px; color: var(--slate-500); }
.form-group input, .form-group select, .form-group textarea {
  padding: 8px 12px;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  color: var(--slate-800);
  font-size: 13px;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* ---- Date Range Bar ---- */
.date-range-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.date-range-bar input[type="date"] {
  padding: 5px 10px;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 7px;
  color: var(--slate-800);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.date-range-bar input[type="date"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.gran-toggle {
  display: inline-flex;
  border: 1px solid var(--slate-200);
  border-radius: 7px;
  overflow: hidden;
}
.gran-toggle .btn {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--slate-200);
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
}
.gran-toggle .btn:last-child { border-right: 0; }
.gran-toggle .btn.btn-primary { color: #fff; }

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
  padding: 6px 10px;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  color: var(--slate-700);
  font-size: 13px;
  font-family: inherit;
}
.filter-bar input:focus, .filter-bar select:focus {
  outline: none;
  border-color: var(--blue);
}

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 6px; top: 0; bottom: 0;
  width: 2px;
  background: var(--slate-200);
}
.timeline-item {
  position: relative;
  padding: 12px 0 12px 16px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -17px; top: 18px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid var(--white);
}
.timeline-item.auto::before { background: var(--blue); }
.timeline-item.system::before { background: var(--amber); }
.timeline-item .tl-date { font-size: 11px; color: var(--slate-400); }
.timeline-item .tl-summary { font-size: 13px; margin-top: 2px; color: var(--slate-800); }
.timeline-item .tl-url { font-size: 12px; color: var(--slate-500); margin-top: 2px; }

/* ---- Empty State ---- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--slate-400);
}
.empty h3 { font-size: 16px; color: var(--slate-800); margin-bottom: 8px; }

/* ---- Loading ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--slate-400);
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--slate-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 10px;
}

/* ---- Login ---- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--slate-900);
}
.login-card {
  text-align: center;
  padding: 48px;
  background: var(--slate-800);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
}
.login-card .logo { font-size: 32px; margin-bottom: 12px; }
.login-card p { color: var(--slate-400); margin-bottom: 24px; }
.btn-google { padding: 12px 24px; font-size: 15px; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); color: #991b1b; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  #sidebar { width: 180px; }
  #content { margin-left: 180px; padding: 16px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Verdict colors ---- */
.verdict-improved { color: var(--green); }
.verdict-declined { color: var(--red); }
.verdict-neutral { color: var(--slate-500); }
.verdict-inconclusive { color: var(--amber); }

/* ---- Tab bar ---- */
.tabs {
  display: flex;
  gap: 0;
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  margin-bottom: 20px;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0 4px;
}
.tab {
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--slate-800); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 13px;
  color: var(--slate-400);
}
