/* =============================================================
   NaijaBreaking Blog Automation Dashboard — Stylesheet
   ============================================================= */

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

:root {
  --green:        #00843D;
  --green-dark:   #005c2a;
  --green-light:  #e6f4ec;
  --white:        #ffffff;
  --gray-50:      #f9fafb;
  --gray-100:     #f3f4f6;
  --gray-200:     #e5e7eb;
  --gray-400:     #9ca3af;
  --gray-600:     #4b5563;
  --gray-800:     #1f2937;
  --red:          #dc2626;
  --red-light:    #fee2e2;
  --yellow:       #d97706;
  --yellow-light: #fef3c7;
  --blue:         #1d4ed8;
  --blue-light:   #dbeafe;
  --font-sans:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "SF Mono", "Fira Mono", "Consolas", monospace;
  --radius:       6px;
  --shadow:       0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html { font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

small { font-size: .8rem; }

/* ── Layout ──────────────────────────────────────────────────── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  flex: 1;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 0;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ── Header ──────────────────────────────────────────────────── */
.site-header {
  background: var(--green);
  color: var(--white);
  padding: .75rem 1.25rem;
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
}

.header-brand h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.header-subtitle {
  font-size: .8rem;
  opacity: .85;
  margin-left: .5rem;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.generated-at {
  font-size: .8rem;
  opacity: .85;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
}

.btn-primary {
  background: var(--green);
  color: var(--white);
  width: 100%;
  padding: .65rem;
  font-size: 1rem;
}

.btn-primary:hover { background: var(--green-dark); text-decoration: none; }

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255,255,255,.6);
  color: var(--white);
}

.btn-outline:hover { background: rgba(255,255,255,.15); text-decoration: none; }

.btn-sm { padding: .3rem .75rem; font-size: .8rem; }

/* ── Stats bar ───────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) { .stats-bar { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .stats-bar { grid-template-columns: 1fr 1fr; } }

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  text-align: center;
  border-top: 4px solid var(--green);
}

.stat-card.stat-published { border-top-color: var(--green); }
.stat-card.stat-draft      { border-top-color: var(--yellow); }
.stat-card.stat-pending    { border-top-color: var(--blue); }
.stat-card.stat-today      { border-top-color: #7c3aed; }
.stat-card.stat-week       { border-top-color: #0891b2; }

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: .78rem;
  color: var(--gray-600);
  margin-top: .35rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Section ─────────────────────────────────────────────────── */
.section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--green-light);
}

/* ── Table ───────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.data-table th {
  text-align: left;
  padding: .55rem .75rem;
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.data-table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }

.col-id   { width: 3rem; color: var(--gray-400); font-size: .8rem; }
.col-title { max-width: 320px; word-break: break-word; }
.col-date  { white-space: nowrap; color: var(--gray-600); font-size: .82rem; }
.col-num   { text-align: right; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.badge-publish {
  background: var(--green-light);
  color: var(--green-dark);
}

.badge-draft {
  background: var(--yellow-light);
  color: var(--yellow);
}

.badge-pending {
  background: var(--blue-light);
  color: var(--blue);
}

.badge-unknown {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ── Log box ─────────────────────────────────────────────────── */
.log-box {
  background: var(--gray-800);
  color: #d1fae5;
  font-family: var(--font-mono);
  font-size: .73rem;
  line-height: 1.6;
  padding: 1rem;
  border-radius: var(--radius);
  max-height: 360px;
  overflow-y: auto;
}

.log-line { padding: .05rem 0; word-break: break-all; }
.log-error { color: #fca5a5; }
.log-warn  { color: #fde68a; }

/* ── Misc helpers ────────────────────────────────────────────── */
.text-muted { color: var(--gray-400); }

.link-view {
  font-size: .8rem;
  font-weight: 500;
  color: var(--green);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--gray-400);
  font-size: .9rem;
}

.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .88rem;
}

.alert-error {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fca5a5;
}

/* ── Login page ──────────────────────────────────────────────── */
body.login-page {
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-box h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: .25rem;
}

.login-subtitle {
  color: var(--gray-600);
  font-size: .88rem;
  margin-bottom: 1.75rem;
}

.login-box label {
  display: block;
  text-align: left;
  font-size: .85rem;
  font-weight: 500;
  color: var(--gray-800);
  margin-bottom: .4rem;
}

.login-box input[type="password"] {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .95rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color .15s;
}

.login-box input[type="password"]:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-light);
}

/* ── Category grid ───────────────────────────────────────────── */
.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.cat-card {
  background: var(--green-light);
  border-radius: var(--radius);
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 100px;
}

.cat-count {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--green-dark);
}

.cat-name {
  font-size: .8rem;
  color: var(--gray-600);
  text-transform: capitalize;
}

/* ── API status grid ─────────────────────────────────────────── */
.api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
}

.api-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: var(--white);
}

.api-card.api-ok   { border-left: 4px solid var(--green); }
.api-card.api-warn { border-left: 4px solid var(--yellow); }
.api-card.api-error{ border-left: 4px solid var(--red); }

.api-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.api-ok   .api-dot { background: var(--green); }
.api-warn .api-dot { background: var(--yellow); }
.api-error .api-dot { background: var(--red); }

.api-info {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.api-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-800);
}

.api-detail {
  font-size: .75rem;
  color: var(--gray-600);
}

/* ── Sources section ────────────────────────────────────────── */
.source-add-form {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.subsection-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: .6rem;
}

.form-row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: center;
}

.form-select,
.form-input {
  padding: .4rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .85rem;
  background: var(--white);
  color: var(--gray-800);
}

.form-input { flex: 1; min-width: 180px; }

.form-msg {
  font-size: .8rem;
  margin-top: .4rem;
  min-height: 1.2em;
}

.form-msg-ok  { color: var(--green); }
.form-msg-err { color: var(--red); }

.chart-wrapper {
  margin-bottom: 1.25rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
}

/* Source table row colour-coding */
.source-row.source-active-high  { background: #f0fdf4; }
.source-row.source-active-low   { background: #fefce8; }
.source-row.source-zero         { background: #fff7ed; }
.source-row.source-inactive     { background: var(--gray-50); opacity: .7; }

.col-source { font-family: var(--font-mono); font-size: .82rem; }

.source-actions { display: flex; gap: .4rem; }

/* Niche badge colours */
.badge-niche         { font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; font-weight: 600; }
.badge-politics      { background: #d1fae5; color: #065f46; }
.badge-tech          { background: #dbeafe; color: #1e40af; }
.badge-sports        { background: #ffedd5; color: #9a3412; }
.badge-business      { background: #fef3c7; color: #92400e; }
.badge-entertainment { background: #ede9fe; color: #5b21b6; }

/* Danger button */
.btn-danger {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid var(--red-light);
}
.btn-danger:hover { background: var(--red); color: var(--white); text-decoration: none; }

/* ── Footer ──────────────────────────────────────────────────── */
.site-footer {
  background: var(--gray-800);
  color: var(--gray-400);
  text-align: center;
  padding: .75rem 1rem;
  font-size: .75rem;
}
