/* ══════════════════════════════════════════════════════════════════════════
   Africa IPv6 & DNSSEC Deployment Monitor — Stylesheet
   No Tailwind. Pure CSS. Clean and beautiful.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --primary:       #1B5E20;
  --primary-light: #2E7D32;
  --primary-dark:  #0D3B0F;
  --accent:        #f47621; /* changed to orange */
  --accent-light:  #ff9a47;
  --body-bg:       #F3F4F6;
  --card-bg:       #FFFFFF;
  --stroke:        #E2E8F0;
  --text-dark:     #1E293B;
  --text-body:     #64748B;
  --success:       #10B981;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --info:          #3B82F6;
  --radius:        0.75rem;
  --shadow:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--body-bg);
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input { font-family: inherit; }
.hidden { display: none !important; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }


/* ═══════════════════════════════════════════════════════════════════════════
   LANDING PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  /* dark gray gradient with #333333 at the midpoint */
  background: linear-gradient(135deg, #121212 0%, #333333 50%, #4d4d4d 100%);
  color: #fff;
  text-align: center;
  padding: 3rem 1.5rem 4rem;
}
.hero-inner { max-width: 720px; margin: 0 auto; }

.hero-logo {
  display: flex; align-items: center; justify-content: center; gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.hero-logo-icon { width: 2.25rem; height: 2.25rem; color: var(--accent); }
.hero-logo-image { width: 20rem; height: auto; object-fit: contain; }
.hero-logo-text { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }

@media (min-width: 1024px) {
  /* larger logo on wide screens */
  .hero-logo-image { width: 20rem; }
}

@media (max-width: 480px) {
  /* smaller on very small screens */
  .hero-logo-image { width: 3.5rem; }
}

.hero-title {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 800; line-height: 1.15;
  margin-bottom: 1rem;
}
.hero-subtitle {
  color: rgba(255,255,255,0.75);
  font-size: 1rem; max-width: 540px; margin: 0 auto 2rem;
  line-height: 1.6;
}

.hero-stats {
  display: flex; align-items: center; justify-content: center; gap: 1.5rem;
  flex-wrap: wrap;
}
.hero-stat { text-align: center; }
.hero-stat-value { display: block; font-size: 1.75rem; font-weight: 700; color: var(--accent); }
.hero-stat-label { font-size: 0.7rem; color: rgba(255,255,255,0.55); letter-spacing: 0.02em; }
.hero-stat-divider { width: 1px; height: 2.5rem; background: rgba(255,255,255,0.2); }

/* ── Search ─────────────────────────────────────────────────────────────── */
.search-wrap {
  max-width: 900px; margin: -1.75rem auto 0; padding: 0 1rem;
  position: relative; z-index: 10;
}

/* ── Dropdown tweaks (country select) ────────────────────────────────────── */
/* when the form version of the landing page is active, avoid extra right
   padding/space inside the select and let it size to its content */
.country-select {
  width: auto !important;    /* don’t force 100% width if unused */
  min-width: 8rem;           /* reasonable minimum so arrow doesn’t overlap */
  padding-right: 1.5rem;     /* smaller than Tailwind’s pr-9 to reduce empty space */
  background-position: right 0.75rem center; /* arrow icon sits close */
}

/* the containing wrapper positions the dropdown arrow */
.country-select + span {
  right: 0.75rem;
}

.search-box {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.25rem;
}
.search-icon { width: 1.25rem; height: 1.25rem; color: var(--text-body); flex-shrink: 0; }
.search-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 0.9rem; color: var(--text-dark);
}
.search-input::placeholder { color: var(--text-body); }

/* ── Countries Grid ─────────────────────────────────────────────────────── */
.main-content { max-width: 900px; margin: 0 auto; padding: 2.5rem 1rem 3rem; }
.countries-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
@media (max-width: 768px) { .countries-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .countries-grid { grid-template-columns: repeat(2, 1fr); } }

/* Country Card */
.country-card {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 1.25rem 0.75rem;
  background: var(--card-bg); border: 1px solid var(--stroke);
  border-radius: var(--radius);
  transition: all 0.2s ease;
  position: relative;
}
.country-card:hover {
  border-color: rgba(27,94,32,0.3);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.country-card.no-data { opacity: 0.55; }
.country-card.no-data:hover { opacity: 0.85; }

.country-card-flag {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.5rem;
}
.country-card-flag .country-flag-img {
  width: 3.5rem; height: auto; border-radius: 0.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.2s ease;
}
.country-card:hover .country-flag-img { transform: scale(1.12); }

.country-card-name {
  font-size: 0.8rem; font-weight: 600; color: var(--text-dark);
  margin-bottom: 0.35rem; line-height: 1.3;
}

.country-card-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.65rem; font-weight: 500;
}
.country-card-badge.has-data { color: var(--primary); }
.country-card-badge.has-data::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--primary);
}
.country-card-badge.empty { color: var(--text-body); opacity: 0.6; }

.country-card-stats {
  display: flex; align-items: center; gap: 0.5rem;
  margin-top: 0.35rem;
}
.country-card-stat {
  display: inline-flex; align-items: center; gap: 0.2rem;
  font-size: 0.6rem; font-weight: 500;
}
.country-card-stat.ipv6 { color: var(--success); }
.country-card-stat.dnssec { color: var(--warning); }
.country-card-stat svg { width: 0.7rem; height: 0.7rem; }

/* CTA overlay */
.country-card-cta {
  position: absolute; inset: 0; border-radius: var(--radius);
  background: rgba(27,94,32,0.04);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 0.5rem;
  opacity: 0; transition: opacity 0.2s ease;
  pointer-events: none;
}
.country-card:hover .country-card-cta { opacity: 1; }
.country-card-cta span {
  font-size: 0.6rem; font-weight: 600; color: var(--primary);
  background: rgba(27,94,32,0.08); padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
}

/* ── Empty State ────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-body); font-size: 0.9rem; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--stroke); background: #fff;
  padding: 1.5rem; text-align: center;
  font-size: 0.7rem; color: var(--text-body);
}


/* ═══════════════════════════════════════════════════════════════════════════
   COUNTRY PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.country-body {
  display: flex; flex-direction: column; height: 100vh;
  overflow: hidden;
}

/* ── Top Nav ────────────────────────────────────────────────────────────── */
.topnav {
  background: #fff; border-bottom: 1px solid var(--stroke);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  position: sticky; top: 0; z-index: 50;
}
.topnav-inner {
  padding: 0 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 3.5rem;
}
.topnav-left { display: flex; align-items: center; gap: 1rem; }
.topnav-back {
  display: flex; align-items: center; gap: 0.35rem;
  color: var(--primary); font-size: 0.85rem; font-weight: 500;
  transition: color 0.15s;
}
.topnav-back:hover { color: var(--primary-dark); }
.topnav-divider { width: 1px; height: 1.5rem; background: var(--stroke); }
.topnav-country { display: flex; align-items: center; gap: 0.5rem; }
.topnav-flag { display: flex; align-items: center; }
.topnav-flag .country-flag-img { width: 1.75rem; height: auto; border-radius: 0.15rem; box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.topnav-title { font-size: 0.9rem; font-weight: 600; color: var(--text-dark); }
.topnav-date { font-size: 0.75rem; color: var(--text-body); }

/* ── Two-Column Layout ──────────────────────────────────────────────────── */
.country-layout {
  flex: 1; display: flex; flex-direction: column;
  width: 100%;
}
@media (min-width: 1024px) {
  .country-layout {
    flex-direction: row;
    height: calc(100vh - 3.5rem);
    overflow: hidden;
  }
}

.map-column {
  padding: 0;
  position: relative;
}
@media (min-width: 1024px) {
  .map-column {
    width: 40%;
    height: 100%;
    display: flex; flex-direction: column;
    padding: 0;
    flex-shrink: 0;
    overflow: hidden;
  }
}
.data-column {
  padding: 1rem;
}
@media (min-width: 1024px) {
  .data-column {
    width: 60%;
    height: 100%;
    overflow-y: auto;
    padding: 1.25rem;
  }
}

/* ── Map (fills column) ─────────────────────────────────────────────────── */
#africa-map {
  width: 100%; height: 100%; min-height: 350px;
  z-index: 1;
}
.leaflet-container { background: #f0f4f0; }

/* Floating legend */
.map-floating-legend {
  position: absolute;
  top: 0.75rem; right: 0.75rem;
  z-index: 1000;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border: 1px solid var(--stroke);
  border-radius: 0.5rem;
  padding: 0.4rem 0.75rem;
  display: flex; align-items: center; gap: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.map-legend-item { display: flex; align-items: center; gap: 0.3rem; font-size: 0.65rem; color: var(--text-body); }
.map-legend-swatch { width: 0.75rem; height: 0.75rem; border-radius: 0.2rem; }
.map-legend-hasdata { background: rgba(46,125,50,0.35); border: 1px solid var(--primary); }
.map-legend-selected { background: rgba(249,168,37,0.6); border: 1px solid var(--accent); }

/* Leaflet custom tooltip */
.leaflet-tooltip-custom {
  background: #fff; color: var(--text-dark);
  font-family: var(--font); font-size: 0.75rem; font-weight: 600;
  border: 1px solid var(--stroke); border-radius: 0.35rem;
  padding: 0.25rem 0.65rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border: 1px solid var(--stroke);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card-flush { padding: 0; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--stroke); }
.card-title { font-size: 0.85rem; font-weight: 600; color: var(--text-dark); }
.card-subtitle { font-size: 0.7rem; color: var(--text-body); margin-top: 0.15rem; }

/* ── Country Header ─────────────────────────────────────────────────────── */
.country-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.country-flag-lg { display: flex; align-items: center; }
.country-flag-lg .country-flag-img { width: 3.5rem; height: auto; border-radius: 0.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.country-name { font-size: 1.5rem; font-weight: 700; color: var(--text-dark); }
.country-subtitle { font-size: 0.8rem; color: var(--text-body); margin-top: 0.15rem; }

/* ── KPIs ───────────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.75rem; }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  padding: 0.75rem; border-radius: 0.5rem; text-align: center;
}
.kpi-default { background: var(--body-bg); }
.kpi-success { background: rgba(16,185,129,0.06); }
.kpi-warning { background: rgba(245,158,11,0.06); }
.kpi-info { background: rgba(59,130,246,0.06); }
.kpi-dnssec { background: rgba(139,92,246,0.06); }
.kpi-value { display: block; font-size: 1.25rem; font-weight: 700; }
.kpi-success .kpi-value { color: var(--success); }
.kpi-warning .kpi-value { color: var(--warning); }
.kpi-info .kpi-value { color: var(--info); }
.kpi-dnssec .kpi-value { color: #7c3aed; }
.kpi-label { font-size: 0.6rem; color: var(--text-body); margin-top: 0.15rem; display: block; }

/* ── Progress Rings ─────────────────────────────────────────────────────── */
.rings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-top: 0.75rem; }
.ring-item { text-align: center; }
.ring-wrap { position: relative; width: 4rem; height: 4rem; margin: 0 auto 0.5rem; }
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--stroke); stroke-width: 3; }
.ring-fill { fill: none; stroke-width: 3; stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.ring-fill-green { stroke: var(--success); }
.ring-fill-blue { stroke: var(--info); }
.ring-fill-amber { stroke: var(--warning); }
.ring-pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: var(--text-dark);
}
.ring-label { font-size: 0.75rem; font-weight: 500; color: var(--text-dark); }
.ring-detail { font-size: 0.65rem; color: var(--text-body); }

/* ── NIST-style Domains Table ────────────────────────────────────────────── */
.nist-table-wrap { overflow-x: auto; }
.nist-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.78rem;
}
.nist-table thead {
  background: #1e293b; color: #fff;
}
.nist-table th {
  padding: 0.55rem 0.75rem;
  font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  text-align: center; white-space: nowrap;
}
.nist-th-domain, .nist-th-org { text-align: left; }
.nist-th-sector { text-align: center; }
.nist-table tbody tr { border-bottom: 1px solid var(--stroke); }
.nist-table tbody tr:hover { background: rgba(241,245,249,0.5); }

.nist-domain {
  padding: 0.5rem 0.75rem;
  font-weight: 600; color: var(--text-dark);
  white-space: nowrap; font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
}
.nist-org {
  padding: 0.5rem 0.75rem;
  color: var(--text-body); font-size: 0.72rem;
  max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.nist-sector {
  padding: 0.5rem 0.75rem;
  color: var(--text-body); font-size: 0.72rem;
  max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center;
}

.nist-cell {
  padding: 0.45rem 0.6rem;
  text-align: center; font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.72rem; white-space: nowrap;
}

/* NIST colour coding */
.nist-green  { background: #22c55e; color: #fff; }
.nist-yellow { background: #facc15; color: #1e293b; }
.nist-red    { background: #ef4444; color: #fff; }
.nist-gray   { background: #e2e8f0; color: #64748b; }

/* Clickable rows */
.nist-clickable { cursor: pointer; }
.nist-clickable:hover { background: rgba(241,245,249,0.7); }

/* Expandable detail row */
.nist-detail-row { display: none; }
.nist-detail-row.open { display: table-row; }
.nist-expanded-cell { padding: 0 !important; }

.exp-inner {
  display: block;            /* ensure block-level so width applies */
  width: 100%;               /* span entire table cell */
  box-sizing: border-box;    /* include padding in width calculation */
  padding: 1rem 1.25rem;
  background: #f8fafc; border-top: 2px solid var(--primary);
}
.exp-title {
  font-size: 0.7rem; font-weight: 700; color: var(--text-dark);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
}

/* Expanded NIST detail table */
.exp-table { width: 100%; border-collapse: collapse; margin-bottom: 0.75rem; }
.exp-table th {
  font-size: 0.6rem; font-weight: 600; color: var(--text-body);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.3rem 0.5rem; text-align: center; border-bottom: 1px solid var(--stroke);
}
.exp-table th:first-child { text-align: left; }
.exp-table td { padding: 0.35rem 0.5rem; text-align: center; font-size: 0.72rem; }
.exp-label { font-weight: 600; color: var(--text-dark); text-align: left !important; }
.exp-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 700; font-size: 0.7rem;
  padding: 0.25rem 0.5rem !important; border-radius: 4px;
  white-space: nowrap;
}
.exp-detail { font-size: 0.7rem; color: var(--text-body); }

/* Extra info (SOA, DNSSEC) */
.exp-extra {
  display: flex; gap: 2rem; margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.exp-block { font-size: 0.72rem; }
.exp-key { font-weight: 600; color: var(--text-dark); margin-right: 0.25rem; }
.exp-val { color: var(--text-body); font-family: 'SF Mono', 'Fira Code', monospace; }

/* Legend */
.exp-legend {
  background: #fff; border: 1px solid var(--stroke); border-radius: 6px;
  padding: 0.65rem 0.85rem;
}
.exp-legend-title {
  font-size: 0.6rem; font-weight: 700; color: var(--text-body);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}
.exp-legend-grid {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.68rem; color: var(--text-body);
}
.exp-legend-grid strong { color: var(--text-dark); }
.exp-swatch {
  display: inline-block; width: 0.7rem; height: 0.7rem;
  border-radius: 3px; vertical-align: middle; margin-right: 0.15rem;
}

/* ── Loading / No Results ───────────────────────────────────────────────── */
.loading-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 5rem 1rem;
  color: var(--text-body); font-size: 0.85rem; gap: 1rem;
}
.spinner {
  width: 2rem; height: 2rem; border: 3px solid var(--stroke);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.country-content { }
.country-content > .card:last-child { margin-bottom: 0; }

.no-results {
  background: var(--card-bg); border: 1px solid var(--stroke);
  border-radius: var(--radius); padding: 2rem; text-align: center;
  margin-bottom: 1.25rem;
}
.no-results svg { margin: 0 auto 0.75rem; color: var(--warning); }
.no-results-title { font-size: 0.85rem; font-weight: 600; color: var(--text-dark); margin-bottom: 0.25rem; }
.no-results-text { font-size: 0.75rem; color: var(--text-body); }
