/* ============================================================
   SBM Portal — Design System
   Aesthetic: Corporate Precision / Fintech Professional
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&family=JetBrains+Mono:ital,wght@0,400;0,500;1,400&display=swap');

/* ── Design Tokens (Dark = Default) ──────────────────────── */
:root {
  /* ── Backgrounds */
  --clr-bg:           #09090b;
  --clr-surface:      #111113;
  --clr-surface-2:    #18181b;
  --clr-surface-3:    #27272a;
  --clr-surface-4:    #3f3f46;

  /* ── Borders */
  --clr-border:       #27272a;
  --clr-border-light: #3f3f46;

  /* ── Brand / Semantic */
  --clr-primary:      #3b82f6;
  --clr-primary-dim:  rgba(59,130,246,.12);
  --clr-primary-glow: rgba(59,130,246,.2);
  --clr-primary-hover:#2563eb;

  --clr-success:      #22c55e;
  --clr-success-dim:  rgba(34,197,94,.12);
  --clr-warning:      #f59e0b;
  --clr-warning-dim:  rgba(245,158,11,.12);
  --clr-danger:       #ef4444;
  --clr-danger-dim:   rgba(239,68,68,.12);
  --clr-info:         #06b6d4;
  --clr-info-dim:     rgba(6,182,212,.12);

  /* ── Text */
  --clr-text:         #fafafa;
  --clr-text-muted:   #a1a1aa;
  --clr-text-faint:   #52525b;

  /* ── Typography */
  --font-display: 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:   .75rem;    /* 12px */
  --text-sm:   .875rem;   /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.25rem;   /* 20px */
  --text-2xl:  1.5rem;    /* 24px */
  --text-3xl:  1.875rem;  /* 30px */
  --text-4xl:  2.25rem;   /* 36px */

  /* ── Spacing */
  --sp-1: .25rem;   --sp-2: .5rem;    --sp-3: .75rem;
  --sp-4: 1rem;     --sp-5: 1.25rem;  --sp-6: 1.5rem;   --sp-7: 1.75rem;
  --sp-8: 2rem;     --sp-10: 2.5rem;  --sp-12: 3rem;
  --sp-16: 4rem;

  /* ── Shape */
  --radius-sm:   4px;
  --radius:      6px;
  --radius-lg:   10px;
  --radius-xl:   14px;
  --radius-full: 9999px;

  /* ── Elevation */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.03);
  --shadow:     0 4px 12px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
  --shadow-xl:  0 20px 60px rgba(0,0,0,.7), 0 4px 16px rgba(0,0,0,.5);

  /* ── Motion */
  --ease-out:  cubic-bezier(.16,1,.3,1);
  --ease-in:   cubic-bezier(.4,0,1,1);
  --ease-snap: cubic-bezier(.34,1.56,.64,1);
  --dur-fast:  80ms;
  --dur-base:  140ms;
  --dur-slow:  260ms;

  /* ── Layout */
  --sidebar-w:         256px;
  --sidebar-collapsed: 60px;
  --topbar-h:          56px;
}

/* ── Dark Theme (Explicit) ──────────────────────────────────*/
[data-theme="dark"] {
  --clr-bg:           #09090b;
  --clr-surface:      #111113;
  --clr-surface-2:    #18181b;
  --clr-surface-3:    #27272a;
  --clr-surface-4:    #3f3f46;

  --clr-border:       #27272a;
  --clr-border-light: #3f3f46;

  --clr-text:         #fafafa;
  --clr-text-muted:   #a1a1aa;
  --clr-text-faint:   #52525b;

  --clr-primary-dim:  rgba(59,130,246,.12);
  --clr-primary-glow: rgba(59,130,246,.2);

  --clr-success-dim:  rgba(34,197,94,.12);
  --clr-warning-dim:  rgba(245,158,11,.12);
  --clr-danger-dim:   rgba(239,68,68,.12);
  --clr-info-dim:     rgba(6,182,212,.12);

  --shadow-sm:  0 1px 2px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.03);
  --shadow:     0 4px 12px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
  --shadow-xl:  0 20px 60px rgba(0,0,0,.7), 0 4px 16px rgba(0,0,0,.5);
}

/* ── Light Theme ────────────────────────────────────────────*/
[data-theme="light"] {
  --clr-bg:           #f4f4f5;
  --clr-surface:      #ffffff;
  --clr-surface-2:    #f4f4f5;
  --clr-surface-3:    #e4e4e7;
  --clr-surface-4:    #d4d4d8;

  --clr-border:       #e4e4e7;
  --clr-border-light: #d4d4d8;

  --clr-text:         #09090b;
  --clr-text-muted:   #71717a;
  --clr-text-faint:   #a1a1aa;

  --clr-primary-dim:  rgba(59,130,246,.08);
  --clr-primary-glow: rgba(59,130,246,.14);

  --clr-success-dim:  rgba(34,197,94,.08);
  --clr-warning-dim:  rgba(245,158,11,.08);
  --clr-danger-dim:   rgba(239,68,68,.08);
  --clr-info-dim:     rgba(6,182,212,.08);

  --shadow-sm:  0 1px 2px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.04);
  --shadow:     0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.06);
  --shadow-xl:  0 20px 60px rgba(0,0,0,.12), 0 4px 16px rgba(0,0,0,.08);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family:    var(--font-body);
  font-size:      var(--text-base);
  font-weight:    400;
  color:          var(--clr-text);
  background:     var(--clr-bg);
  line-height:    1.6;
  min-height:     100vh;
  letter-spacing: -.011em;
}

h1, h2, h3, h4, h5, h6 {
  font-family:    var(--font-display);
  font-weight:    600;
  letter-spacing: -.025em;
  line-height:    1.2;
  color:          var(--clr-text);
}

a {
  color: var(--clr-primary);
  text-decoration: none;
  transition: color var(--dur-fast);
}
a:hover { color: var(--clr-primary-hover); text-decoration: underline; }

code, pre, kbd {
  font-family: var(--font-mono);
  font-size:   .9em;
}

img, svg { display: block; }

/* ── Scrollbars ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--clr-surface-3);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--clr-surface-4); }

/* ── Focus ────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Selection ────────────────────────────────────────────── */
::selection {
  background: var(--clr-primary-dim);
  color: var(--clr-text);
}

/* ── Utility classes ──────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted { color: var(--clr-text-muted); }
.text-faint { color: var(--clr-text-faint); }
.text-sm    { font-size: var(--text-sm); }
.text-xs    { font-size: var(--text-xs); }
.font-mono  { font-family: var(--font-mono); }
.font-medium{ font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold  { font-weight: 700; }
.w-full     { width: 100%; }
.h-full     { height: 100%; }
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.mt-auto { margin-top: auto; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn    { from { opacity: 0 }            to { opacity: 1 } }
@keyframes slideUp   { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: translateY(0) } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: translateY(0) } }
@keyframes slideRight{ from { opacity: 0; transform: translateX(-8px) } to { opacity: 1; transform: translateX(0) } }
@keyframes spin      { to { transform: rotate(360deg) } }
@keyframes pulse     { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }
@keyframes shimmer   {
  0%   { background-position: -600px 0 }
  100% { background-position:  600px 0 }
}
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--clr-primary-glow) }
  50%       { box-shadow: 0 0 0 6px transparent }
}

.animate-fade-in   { animation: fadeIn    var(--dur-slow) var(--ease-out) both; }
.animate-slide-up  { animation: slideUp   var(--dur-slow) var(--ease-out) both; }
.animate-slide-right { animation: slideRight var(--dur-slow) var(--ease-out) both; }

/* ── Skeleton ─────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--clr-surface-2) 25%,
    var(--clr-surface-3) 50%,
    var(--clr-surface-2) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius);
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--clr-border);
  margin: var(--sp-4) 0;
}

/* ── Icon placeholder (before Lucide replaces <i> with <svg>) */
i[data-icon] {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    /* Reserve the declared width/height so layout doesn't shift */
    min-width:  var(--icon-w, 16px);
    min-height: var(--icon-h, 16px);
}
/* Once replaced, the <svg> carries its own display */
i[data-icon] svg { display: block; }

/* ── Status dot ───────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.success { background: var(--clr-success); }
.status-dot.warning { background: var(--clr-warning); }
.status-dot.danger  { background: var(--clr-danger);  }
.status-dot.info    { background: var(--clr-info);    }
.status-dot.muted   { background: var(--clr-text-faint); }
.status-dot.pulse   { animation: pulse 2s ease-in-out infinite; }

/* ── Listing toolbar ─────────────────────────────────────── */
.listing-toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}
.listing-search {
    flex: 1;
    max-width: 400px;
    min-width: 180px;
}
.listing-count {
    margin-left: auto;
    font-size: var(--text-sm);
    color: var(--clr-text-muted);
    white-space: nowrap;
}

/* ── Filter popover ──────────────────────────────────────── */
.filter-popover-wrap {
    position: relative;
}
.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--clr-primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    margin-left: var(--sp-1);
}
.filter-popover-backdrop {
    position: fixed;
    inset: 0;
    z-index: 49;
}
.filter-popover-panel {
    position: absolute;
    top: calc(100% + var(--sp-2));
    left: 0;
    z-index: 50;
    min-width: 300px;
    max-width: 440px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.filter-popover-body {
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}
.filter-popover-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--clr-border);
    background: var(--clr-surface);
}

@media (max-width: 768px) {
    .listing-search { max-width: 100%; width: 100%; }
    .listing-count { margin-left: 0; }
    .filter-popover-panel {
        left: auto;
        right: 0;
        min-width: 280px;
        max-width: calc(100vw - 2rem);
    }
}
