/* ==========================================================================
   Simal KYC Portal — Design System (base.css)
   Design tokens, reset, and shared components.
   RTL-ready: logical properties used where relevant (padding-inline etc.)
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Brand — trustworthy fintech blue */
  --brand-50:  #F0F6FE;
  --brand-100: #DCE9F9;
  --brand-200: #B9D4F3;
  --brand-500: #2E7BD6;
  --brand-600: #1467C8;   /* primary */
  --brand-700: #104993;
  --brand-800: #0D3A73;
  --brand-900: #0B2E5B;

  /* Semantic */
  --success-700: #05603A;  --success-600: #067647;  --success-100: #ECFDF3;  --success-500: #12B76A;
  --warn-700:    #93370D;  --warn-600:    #B54708;  --warn-100:    #FFFAEB;  --warn-500:    #F79009;
  --danger-700:  #912018;  --danger-600:  #B42318;  --danger-100:  #FEF3F2;  --danger-500:  #F04438;
  --info-700:    #19389E;  --info-600:    #175CD3;  --info-100:    #EFF6FF;
  --teal-700:    #095C56;  --teal-600:    #0E9384;  --teal-100:    #F0F9FF;
  --purple-700:  #5027A5;  --purple-600:  #6941C6;  --purple-100:  #F4F1FE;

  /* Neutrals */
  --gray-900: #101828;  --gray-800: #1D2939;  --gray-700: #344054;  --gray-600: #475467;
  --gray-500: #667085;  --gray-400: #98A2B3;  --gray-300: #D0D5DD;  --gray-200: #EAECF0;
  --gray-100: #F2F4F7;  --gray-50:  #F9FAFB;  --white:    #FFFFFF;

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: .75rem;   --fs-sm: .8125rem;  --fs-md: .875rem;  --fs-base: .9375rem;
  --fs-lg: 1.0625rem; --fs-xl: 1.25rem;  --fs-2xl: 1.5rem;  --fs-3xl: 1.875rem;

  /* Spacing (4pt scale) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;

  /* Radius / shadow / motion */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;
  --shadow-xs: 0 1px 2px rgba(16,24,40,.05);
  --shadow-sm: 0 1px 3px rgba(16,24,40,.10), 0 1px 2px rgba(16,24,40,.06);
  --shadow-md: 0 4px 8px -2px rgba(16,24,40,.10), 0 2px 4px -2px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 16px -4px rgba(16,24,40,.08), 0 4px 6px -2px rgba(16,24,40,.03);
  --focus-ring: 0 0 0 4px rgba(20,103,200,.18);
  --transition: 160ms cubic-bezier(.2,.8,.3,1);

  /* Layout */
  --container: 1128px;
  --header-h: 64px;
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4 { margin: 0; color: var(--gray-900); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: var(--fs-3xl); line-height: 1.25; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p  { margin: 0 0 var(--sp-4); }
a  { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
ul,ol { margin: 0; padding-inline-start: 1.2em; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; border-radius: 4px; }
::placeholder { color: var(--gray-400); }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; inset-inline-start: -9999px; top: 0; z-index: 200;
  background: var(--brand-700); color: #fff; padding: var(--sp-2) var(--sp-4);
  border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { inset-inline-start: 0; }

/* ---------- 3. Layout primitives ---------- */
.container { max-width: var(--container); margin-inline: auto; padding-inline: var(--sp-5); }
.stack > * + * { margin-top: var(--sp-4); }
.row { display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.muted { color: var(--gray-500); }
.small { font-size: var(--fs-sm); }
.text-right { text-align: end; }
.mt-0{margin-top:0}.mt-2{margin-top:var(--sp-2)}.mt-4{margin-top:var(--sp-4)}.mt-6{margin-top:var(--sp-6)}
.mt-8{margin-top:var(--sp-8)}.mb-0{margin-bottom:0}.mb-2{margin-bottom:var(--sp-2)}.mb-4{margin-bottom:var(--sp-4)}
.mb-6{margin-bottom:var(--sp-6)}.mb-8{margin-bottom:var(--sp-8)}
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- 4. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  border-radius: var(--r-md); border: 1px solid transparent;
  padding: 10px 18px; font-weight: 600; font-size: var(--fs-md);
  cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition), transform var(--transition);
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-300); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); }
.btn-ghost { background: transparent; color: var(--brand-600); }
.btn-ghost:hover:not(:disabled) { background: var(--brand-50); }
.btn-danger { background: var(--danger-600); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-700); }
.btn-success { background: var(--success-600); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-700); }
.btn-warn { background: var(--warn-600); color: #fff; }
.btn-warn:hover:not(:disabled) { background: var(--warn-700); }
.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { padding: 13px 24px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn .icon { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---------- 5. Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-weight: 600; font-size: var(--fs-sm); color: var(--gray-700); }
.field .label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.field .optional { font-weight: 400; color: var(--gray-400); font-size: var(--fs-xs); }
.field .hint { font-size: var(--fs-xs); color: var(--gray-500); }
.input, .select, .textarea {
  width: 100%; background: #fff; border: 1px solid var(--gray-300);
  border-radius: var(--r-md); padding: 9px 12px; font-size: var(--fs-md);
  transition: border-color var(--transition), box-shadow var(--transition);
  color: var(--gray-900);
}
.textarea { min-height: 88px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23667085' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-inline-end: 34px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-400); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-500); box-shadow: var(--focus-ring); outline: none; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger-500); background: #FFFBFA; }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(240,68,56,.16); }
.field .error { display: none; font-size: var(--fs-xs); color: var(--danger-600); font-weight: 500; align-items: center; gap: 6px; }
.field.invalid .error { display: inline-flex; }
.field.invalid > label { color: var(--danger-700); }
.input:disabled, .select:disabled { background: var(--gray-100); cursor: not-allowed; }

/* checkbox & radio */
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: var(--r-md); background: #fff; cursor: pointer; transition: border-color var(--transition), background var(--transition); }
.choice:hover { border-color: var(--brand-200); background: var(--brand-50); }
.choice input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand-600); flex: 0 0 auto; }
.choice .choice-title { font-weight: 600; font-size: var(--fs-md); color: var(--gray-800); }
.choice .choice-sub { font-size: var(--fs-xs); color: var(--gray-500); }
.choice:has(input:checked) { border-color: var(--brand-500); background: var(--brand-50); }
.choice:has(input:focus-visible) { outline: 3px solid var(--brand-500); outline-offset: 2px; }

/* checkbox plain (declarations) */
.checkline { display: flex; gap: 10px; align-items: flex-start; }
.checkline input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand-600); flex: 0 0 auto; }

/* ---------- 6. Cards / panels ---------- */
.card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.card-pad { padding: var(--sp-6); }
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--gray-300); }
.section-title { font-size: var(--fs-lg); font-weight: 700; color: var(--gray-900); margin-bottom: var(--sp-1); }
.section-desc { font-size: var(--fs-md); color: var(--gray-500); margin-bottom: var(--sp-6); }

/* ---------- 7. Badges & status pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-full); padding: 2px 10px; font-size: var(--fs-xs); font-weight: 600; line-height: 1.6; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-neutral { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.badge-info    { background: var(--info-100);  color: var(--info-600); }
.badge-brand   { background: var(--brand-50);  color: var(--brand-700); }
.badge-success { background: var(--success-100); color: var(--success-700); }
.badge-warn    { background: var(--warn-100);   color: var(--warn-700); }
.badge-danger  { background: var(--danger-100); color: var(--danger-700); }
.badge-teal    { background: var(--teal-100);   color: var(--teal-700); }
.badge-purple  { background: var(--purple-100); color: var(--purple-700); }

/* ---------- 8. Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--gray-200); border-radius: var(--r-lg); background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table thead th {
  text-align: start; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--gray-500); background: var(--gray-50);
  padding: 10px 16px; border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
.table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--brand-50); }
.table tbody tr.clickable { cursor: pointer; }
.table .cell-strong { font-weight: 600; color: var(--gray-900); }

/* ---------- 9. Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
  animation: fadeIn 140ms ease;
}
.modal {
  background: #fff; border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: 88vh; overflow: auto; padding: var(--sp-6);
  animation: slideUp 180ms cubic-bezier(.2,.8,.3,1);
}
.modal:focus { outline: none; }
.modal h3 { margin-bottom: var(--sp-2); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ---------- 10. Toast ---------- */
.toast-region { position: fixed; bottom: var(--sp-5); inset-inline-end: var(--sp-5); z-index: 150; display: flex; flex-direction: column; gap: var(--sp-2); }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--gray-900); color: #fff;
  border-radius: var(--r-md); padding: 12px 16px; box-shadow: var(--shadow-lg);
  font-size: var(--fs-md); font-weight: 500; max-width: 380px;
  animation: slideUp 180ms cubic-bezier(.2,.8,.3,1);
}
.toast.success { background: var(--success-700); }
.toast.error   { background: var(--danger-700); }
.toast.warn    { background: var(--warn-700); }

/* ---------- 11. Stepper (multi-step form) ---------- */
.stepper { display: flex; gap: var(--sp-2); list-style: none; margin: 0; padding: 0; overflow-x: auto; }
.stepper li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 600; color: var(--gray-500); white-space: nowrap; background: transparent; border: none; cursor: default; }
.stepper li .step-index {
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--gray-200); color: var(--gray-600); font-size: var(--fs-xs); font-weight: 700; flex: 0 0 auto;
}
.stepper li.active { color: var(--brand-700); background: var(--brand-50); }
.stepper li.active .step-index { background: var(--brand-600); color: #fff; }
.stepper li.done { color: var(--success-700); }
.stepper li.done .step-index { background: var(--success-100); color: var(--success-700); }
.stepper li.nav-btn { cursor: pointer; }
.stepper li.nav-btn:hover { background: var(--gray-100); }

/* ---------- 12. Upload dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--gray-300); border-radius: var(--r-lg); background: var(--gray-50);
  padding: var(--sp-6); text-align: center; transition: border-color var(--transition), background var(--transition);
}
.dropzone.dragover { border-color: var(--brand-500); background: var(--brand-50); }
.dropzone .dz-icon { margin-inline: auto; margin-bottom: var(--sp-2); color: var(--gray-400); }
.dropzone .dz-title { font-weight: 600; color: var(--gray-700); font-size: var(--fs-md); }
.dropzone .dz-hint { font-size: var(--fs-xs); color: var(--gray-500); margin-top: 2px; }
.dropzone .link { color: var(--brand-600); text-decoration: underline; }
.file-row { display: flex; align-items: center; gap: var(--sp-3); padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: var(--r-md); background: #fff; }
.file-row .file-ic { width: 34px; height: 34px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; background: var(--brand-50); color: var(--brand-600); flex: 0 0 auto; }
.file-row .file-meta { flex: 1; min-width: 0; }
.file-row .file-name { font-weight: 600; font-size: var(--fs-sm); color: var(--gray-800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .file-sub { font-size: var(--fs-xs); color: var(--gray-500); }
.icon-btn { background: transparent; border: none; border-radius: var(--r-sm); width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; color: var(--gray-500); cursor: pointer; }
.icon-btn:hover { background: var(--danger-100); color: var(--danger-600); }

/* ---------- 13. Timeline (status page) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding-inline-start: 30px; padding-bottom: var(--sp-5); }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 8px; top: 20px; bottom: 0; width: 2px; background: var(--gray-200); }
.timeline li:last-child::before { display: none; }
.timeline .tl-dot {
  position: absolute; inset-inline-start: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--gray-300);
}
.timeline li.done .tl-dot { border-color: var(--success-500); background: var(--success-100); }
.timeline li.current .tl-dot { border-color: var(--brand-600); background: var(--brand-600); box-shadow: 0 0 0 4px rgba(20,103,200,.18); }
.timeline .tl-title { font-weight: 600; color: var(--gray-900); font-size: var(--fs-md); }
.timeline .tl-sub { font-size: var(--fs-xs); color: var(--gray-500); }

/* ---------- 14. Utilities ---------- */
.divider { height: 1px; background: var(--gray-200); border: 0; margin: var(--sp-6) 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--gray-300); background: #fff; border-radius: var(--r-full); padding: 4px 12px; font-size: var(--fs-sm); font-weight: 500; color: var(--gray-600); cursor: pointer; }
.chip:hover { border-color: var(--brand-300, var(--brand-200)); color: var(--brand-700); }
.chip.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.empty-state { text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--gray-500); }
.empty-state .es-icon { margin: 0 auto var(--sp-4); color: var(--gray-300); }
.alert { display: flex; gap: 12px; border-radius: var(--r-md); padding: 12px 16px; font-size: var(--fs-md); border: 1px solid transparent; }
.alert-info    { background: var(--info-100);    border-color: #B2DDFF; color: var(--info-700); }
.alert-success { background: var(--success-100); border-color: #A6F4C5; color: var(--success-700); }
.alert-warn    { background: var(--warn-100);    border-color: #FEDF89; color: var(--warn-700); }
.alert-danger  { background: var(--danger-100);  border-color: #FECDCA; color: var(--danger-700); }

/* skeleton shimmer for async-feel */
.skeleton { border-radius: var(--r-md); background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- 15. Responsive ---------- */
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  h1 { font-size: var(--fs-2xl); }
  .card-pad { padding: var(--sp-5); }
}

/* ---------- 16. Print (confirmation / review evidence) ---------- */
@media print {
  body { background: #fff; }
  .no-print, .toast-region, .skip-link { display: none !important; }
  .card { box-shadow: none; border-color: var(--gray-300); }
}

/* ---------- 17. Motion & entrance animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeInOnly {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes barGrow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
.fade-in-up { animation: fadeUp .5s cubic-bezier(.2,.8,.3,1) both; }
.fade-in { animation: fadeInOnly .4s ease both; }

/* staggered hero entrance */
.hero-grid > * { animation: fadeUp .55s cubic-bezier(.2,.8,.3,1) both; }
.hero-grid > *:nth-child(2) { animation-delay: .12s; }
.role-grid .role-card { animation: fadeUp .5s cubic-bezier(.2,.8,.3,1) both; }
.role-grid .role-card:nth-child(1) { animation-delay: .2s; }
.role-grid .role-card:nth-child(2) { animation-delay: .3s; }

/* wizard step transition */
.step-body.step-enter { animation: fadeUp .32s cubic-bezier(.2,.8,.3,1) both; }

/* chart bars grow from left */
.funnel-row .f-bar { transform-origin: left center; animation: barGrow .7s cubic-bezier(.2,.8,.3,1) both; }
.funnel-row:nth-child(2) .f-bar { animation-delay: .05s; }
.funnel-row:nth-child(3) .f-bar { animation-delay: .1s; }
.funnel-row:nth-child(4) .f-bar { animation-delay: .15s; }
.funnel-row:nth-child(5) .f-bar { animation-delay: .2s; }
.funnel-row:nth-child(6) .f-bar { animation-delay: .25s; }
.funnel-row:nth-child(7) .f-bar { animation-delay: .3s; }

/* cards & KPI entrance */
.grid > .card { animation: fadeUp .45s cubic-bezier(.2,.8,.3,1) both; }
.grid > .card:nth-child(2) { animation-delay: .06s; }
.grid > .card:nth-child(3) { animation-delay: .12s; }
.grid > .card:nth-child(4) { animation-delay: .18s; }

/* partner strip */
.partner-strip { padding: var(--sp-8) 0; border-bottom: 1px solid var(--gray-200); background: #fff; }
.partner-strip .ps-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gray-400); text-align: center; margin-bottom: var(--sp-4); }
.partner-strip .ps-brands { display: flex; flex-wrap: wrap; gap: 10px var(--sp-5); justify-content: center; }
.partner-strip .ps-brand { font-weight: 700; font-size: var(--fs-md); color: var(--gray-500); letter-spacing: .02em; transition: color var(--transition); }
.partner-strip .ps-brand:hover { color: var(--gray-800); }

/* respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
