/* ============================================================
   IRIS MSME Global — shared design system
   Used by: index.html, admin.html, ghana.html
   ============================================================ */

:root {
  --iris-purple: #6C5CE7;
  --iris-purple-dark: #5849D6;
  --iris-purple-light: #8A7CF0;
  --iris-purple-bg: #F3F1FE;
  --iris-blue: #1E3A8A;
  --iris-green: #00A661;
  --iris-teal: #0EA5A5;

  --surface-app: #F4F4FB;
  --surface-card: #FFFFFF;
  --surface-sidebar: #FFFFFF;
  --surface-hover: #F3F1FE;
  --surface-subtle: #FAFAFB;

  --ink: #1A1A2E;
  --ink-soft: #4A4A68;
  --ink-muted: #8B8BA7;
  --ink-light: #B5B5C9;
  --border: #E8E8F0;
  --border-strong: #D4D4E4;

  --gh-red: #CE1126;
  --gh-gold: #FCD116;
  --gh-green: #006B3F;
  --gh-green-dark: #004D2D;
  --gh-soft-green: #E8F3ED;
  --gh-soft-gold: #FFF8D9;

  --success: #00A661;
  --success-bg: #E3F5ED;
  --warning: #F59E0B;
  --warning-bg: #FEF3C7;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;

  --shadow-sm: 0 1px 2px rgba(26, 26, 46, 0.04), 0 1px 3px rgba(26, 26, 46, 0.06);
  --shadow-md: 0 4px 6px rgba(26, 26, 46, 0.04), 0 10px 20px rgba(26, 26, 46, 0.06);
  --shadow-lg: 0 12px 24px rgba(26, 26, 46, 0.08), 0 24px 48px rgba(26, 26, 46, 0.08);
  --shadow-purple: 0 4px 14px rgba(108, 92, 231, 0.25);

  /* Themeable — overridden per-country by ConfigStore -> inline style */
  --theme-primary: var(--iris-purple);
  --theme-accent: var(--gh-green);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--surface-app);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ============================================================
   Typography helpers
   ============================================================ */
.serif { font-family: 'Fraunces', Georgia, serif; font-weight: 500; letter-spacing: -0.02em; }
.mono { font-family: 'JetBrains Mono', 'SF Mono', monospace; }

/* ============================================================
   Brand / logo
   ============================================================ */
.brand-logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-star { width: 26px; height: 26px; flex-shrink: 0; }
.brand-img { height: 28px; width: auto; display: block; flex-shrink: 0; }
.brand-img-sm { height: 22px; }
.brand-img-lg { height: 36px; }
.brand-text {
  font-weight: 800; font-size: 18px; letter-spacing: -0.02em;
  line-height: 1; display: flex; align-items: baseline;
}
.brand-text .iris { color: var(--iris-blue); }
.brand-text .msme { color: var(--iris-green); }
.brand-tag {
  font-size: 10px; color: var(--iris-purple); background: var(--iris-purple-bg);
  padding: 3px 8px; border-radius: 20px; margin-left: 4px;
  letter-spacing: 0.04em; font-weight: 700;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 9px; font-size: 13px; font-weight: 700;
  transition: transform .12s, box-shadow .12s, background .12s, color .12s, border-color .12s;
  border: 1px solid transparent; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--theme-primary); color: white; box-shadow: var(--shadow-purple); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(108,92,231,.35); }
.btn-secondary { background: white; color: var(--theme-primary); border-color: var(--theme-primary); }
.btn-secondary:hover { background: var(--iris-purple-bg); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--ink); }
.btn-green { background: var(--theme-accent); color: white; }
.btn-green:hover { background: var(--gh-green-dark); }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-lg { padding: 13px 26px; font-size: 14px; }

/* ============================================================
   Badges / chips / pills
   ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  background: var(--surface-hover); color: var(--ink-soft);
}
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-warn { background: var(--warning-bg); color: var(--warning); }
.pill-purple { background: var(--iris-purple-bg); color: var(--iris-purple); }
.pill-ghana { background: var(--gh-soft-green); color: var(--gh-green); }
.pill-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block;
}

.chip {
  padding: 4px 11px; border-radius: 18px; font-size: 11px; font-weight: 600;
  background: var(--iris-purple-bg); color: var(--iris-purple);
}
.chip-women { background: #FCE7F3; color: #BE185D; }
.chip-youth { background: #DBEAFE; color: #1E40AF; }
.chip-pwd { background: #F3E8FF; color: #6B21A8; }
.chip-loan { background: #E3F5ED; color: var(--gh-green); }
.chip-grant { background: #FEF3C7; color: #92400E; }
.chip-subsidy { background: #FDF4D3; color: #854D0E; }
.chip-all { background: var(--surface-app); color: var(--ink-muted); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: white; border-radius: 14px; border: 1px solid var(--border);
  padding: 20px;
}
.card-md { padding: 24px; }
.card-lg { padding: 28px; }

/* ============================================================
   Forms
   ============================================================ */
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--ink); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; font-size: 13px; color: var(--ink);
  background: white; border: 1px solid var(--border); border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
}
.field .helper { font-size: 10px; color: var(--ink-muted); margin-top: 5px; }
.field .source { font-size: 10px; color: var(--gh-green); margin-top: 5px; font-weight: 700; letter-spacing: 0.02em; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) {
  .field-row { grid-template-columns: repeat(2, 1fr); }
  .field-row.triple { grid-template-columns: repeat(3, 1fr); }
  .field-row.quad { grid-template-columns: repeat(4, 1fr); }
}

/* Toggle switch */
.toggle {
  width: 36px; height: 22px; background: var(--border-strong);
  border-radius: 20px; position: relative; cursor: pointer;
  transition: background .2s; flex-shrink: 0;
}
.toggle.on { background: var(--theme-accent); }
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; background: white; border-radius: 50%;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle.on::after { transform: translateX(14px); }

/* ============================================================
   Flag components
   ============================================================ */
.flag {
  width: 40px; height: 28px; border-radius: 4px; box-shadow: var(--shadow-sm);
  overflow: hidden; position: relative; flex-shrink: 0;
}
.flag-lg { width: 72px; height: 48px; border-radius: 6px; box-shadow: var(--shadow-md); }
.flag-ghana {
  background: linear-gradient(to bottom,
    var(--gh-red) 0% 33.3%,
    var(--gh-gold) 33.3% 66.6%,
    var(--gh-green) 66.6% 100%);
}
.flag-ghana::after {
  content: '★'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); color: black; font-size: 12px; line-height: 1;
}
.flag-lg.flag-ghana::after { font-size: 18px; }
.flag-india { background: linear-gradient(to bottom, #FF9933 33%, white 33% 66%, #138808 66%); }
.flag-india::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); width: 9px; height: 9px;
  border: 1.5px solid #000080; border-radius: 50%;
}
.flag-sa { background: #002395; }
.flag-sa::before {
  content: ''; position: absolute; inset: 0; height: 50%; background: #E03C31;
}
.flag-sa::after {
  content: ''; position: absolute; top: 50%; left: 0; transform: translateY(-50%);
  width: 0; height: 0; border-top: 14px solid transparent; border-bottom: 14px solid transparent;
  border-left: 12px solid #007A4D;
}
.flag-kenya { background: linear-gradient(to bottom, #000 33%, #BB0000 33% 66%, #006600 66%); }
.flag-nigeria { background: linear-gradient(to right, #008751 33%, white 33% 66%, #008751 66%); }

/* ============================================================
   Utility
   ============================================================ */
.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.grow { flex: 1; }
.text-muted { color: var(--ink-muted); }
.text-soft { color: var(--ink-soft); }

/* Small helpers from the legacy portal */
.gh-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--gh-soft-green); color: var(--gh-green);
  padding: 3px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
}
.gh-badge-dot { width: 5px; height: 5px; background: var(--gh-green); border-radius: 50%; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadeIn .3s ease; }
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(108,92,231,.18);
  border-top-color: var(--theme-primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ============================================================
   Config-mark (shown in end-user portal when ?mark=1)
   Marks an element as country-configurable.
   ============================================================ */
body.mark-config [data-config] {
  position: relative; outline: 2px dashed rgba(108,92,231,.55);
  outline-offset: 3px; border-radius: 6px;
}
body.mark-config [data-config]::before {
  content: '⚙ ' attr(data-config);
  position: absolute; top: -10px; left: -2px;
  background: var(--iris-purple); color: white;
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 4px; z-index: 100;
  font-family: 'Inter', sans-serif; pointer-events: none;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 12px 18px;
  border-radius: 10px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 1000; display: flex;
  align-items: center; gap: 10px; max-width: 90vw;
  animation: fadeIn .25s ease;
}
.toast-success { background: var(--gh-green); }
.toast-error { background: var(--danger); }

/* ============================================================
   Overlay / modal
   ============================================================ */
.overlay {
  position: fixed; inset: 0; background: rgba(26, 26, 46, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 900; animation: fadeIn .25s ease;
  backdrop-filter: blur(6px);
}
.modal {
  background: white; border-radius: 18px; max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 22px 26px 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.modal-body { padding: 8px 26px 22px; }
.modal-footer {
  padding: 16px 26px 22px; display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--border); margin-top: 8px;
}
