/* ============================================================
   AfriBiz Intelligence — Clean Light Theme
   ============================================================ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg:       #f1f5f9;
  --card:     #ffffff;
  --border:   #e2e8f0;
  --text:     #0f172a;
  --text-2:   #475569;
  --text-3:   #94a3b8;
  --green:    #10b981;
  --amber:    #f59e0b;
  --red:      #ef4444;
  --accent:   #10b981;
  --radius:   12px;
  --shadow:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:0 10px 30px rgba(0,0,0,.14);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ── Header ─────────────────────────────────────────────────── */
header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.brand-icon { font-size: 30px; line-height: 1; }
.brand h1 { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.2; }
.brand p  { font-size: 12px; color: var(--text-2); margin-top: 1px; }

.search-wrap { flex: 1; max-width: 300px; }
.search-wrap input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.search-wrap input::placeholder { color: var(--text-3); }
.search-wrap input:focus { border-color: var(--accent); }

/* ── Offline banner ─────────────────────────────────────────── */
.offline-banner {
  background: #fef9c3;
  color: #854d0e;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid #fde047;
}
.offline-banner.hidden { display: none; }

/* ── Main ───────────────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Controls ───────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.regions { display: flex; gap: 8px; flex-wrap: wrap; }
.region-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.region-btn:hover  { border-color: var(--accent); color: var(--accent); }
.region-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.sort-wrap { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.sort-wrap label { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.sort-wrap select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.sort-wrap select:focus { border-color: var(--accent); }

/* ── Status bar ─────────────────────────────────────────────── */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-2);
}
#data-status {
  padding: 3px 10px;
  background: #f0fdf4;
  color: #15803d;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
#data-status.hidden { display: none; }

/* ── Grid ───────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow .2s, transform .15s;
  box-shadow: var(--shadow);
}
.card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.09);
  transform: translateY(-2px);
}
.card:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.flag {
  width: 40px;
  height: 27px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--border);
}
.card-name { flex: 1; min-width: 0; }
.card-name strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.region-tag { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── Score badge ────────────────────────────────────────────── */
.score-badge {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.score-badge.big   { width: 58px; height: 58px; font-size: 17px; }
.score-high        { background: var(--green); }
.score-mid         { background: var(--amber); }
.score-low         { background: var(--red); }
.score-na          { background: var(--text-3); font-size: 11px; }

/* ── Card stats ─────────────────────────────────────────────── */
.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.stat { text-align: center; }
.stat-val   { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.stat-label { display: block; font-size: 10px; color: var(--text-3); margin-top: 2px; line-height: 1.3; }

/* ── Skeleton loaders ───────────────────────────────────────── */
.skeleton { pointer-events: none; }
.skel {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-flag   { width: 40px; height: 27px; border-radius: 4px; }
.skel-name   { width: 110px; height: 15px; margin-bottom: 6px; }
.skel-region { width: 75px;  height: 11px; }
.skel-score  { width: 48px;  height: 48px; border-radius: 50%; margin-left: auto; }
.skel-stat   { height: 34px; border-radius: 6px; }

/* ── Empty / Error states ───────────────────────────────────── */
.empty, .error-card {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-2);
}
.empty p, .error-card p { margin-bottom: 16px; font-size: 15px; }
.error-card .retry-btn, .empty .retry-btn {
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s;
}
.error-card .retry-btn:hover, .empty .retry-btn:hover { opacity: .85; }

/* ── Modal overlay ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  backdrop-filter: blur(3px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--border); }

/* ── Modal header ───────────────────────────────────────────── */
.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.modal-flag {
  width: 64px;
  height: 43px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--border);
}
.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 2px;
}
.modal-header .meta { font-size: 13px; color: var(--text-2); }
.modal-header .score-badge { margin-left: auto; flex-shrink: 0; }

/* ── Modal section headings ─────────────────────────────────── */
.modal-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}

/* ── Indicator rows ─────────────────────────────────────────── */
.modal-indicators { margin-bottom: 24px; }
.ind-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.ind-row:last-child { border-bottom: none; }
.ind-label { color: var(--text-2); }
.ind-val   { font-weight: 600; color: var(--text); }

/* ── News section ───────────────────────────────────────────── */
.modal-news { margin-top: 4px; }
.news-loading { font-size: 13px; color: var(--text-3); padding: 8px 0; }
.news-empty   { font-size: 13px; color: var(--text-3); padding: 8px 0; }
.news-item {
  display: block;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  transition: color .15s;
}
.news-item:last-child { border-bottom: none; }
.news-item strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1.4;
}
.news-item:hover strong { color: var(--accent); }
.news-item .news-meta { font-size: 11px; color: var(--text-3); }

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  z-index: 300;
  max-width: 300px;
  box-shadow: var(--shadow-lg);
}
.toast.hidden   { display: none; }
.toast-info     { background: #334155; }
.toast-error    { background: var(--red); }
.toast-success  { background: var(--green); }
.toast-warn     { background: var(--amber); }

/* ── Footer ─────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 28px 24px;
  font-size: 12px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner     { gap: 12px; }
  .brand p          { display: none; }
  .search-wrap      { max-width: 100%; width: 100%; flex: none; order: 3; }
  main              { padding: 16px; }
  .controls         { gap: 10px; }
  .sort-wrap        { margin-left: 0; width: 100%; justify-content: flex-end; }
  .grid             { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card             { padding: 14px; }
  .modal            { padding: 24px 18px; }
  .modal-flag       { font-size: 36px; }
  .modal-header h2  { font-size: 17px; }
}

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