/* ================================================================
   JB'S 100 SACCO — Global Design System
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ───── CSS Custom Properties ───── */
:root {
  /* Colors */
  --bg-primary:    #0a0f1e;
  --bg-secondary:  #0d1526;
  --bg-card:       #111827;
  --bg-card-hover: #1a2236;
  --bg-input:      #0d1526;
  --bg-modal:      #111827;

  --accent-cyan:   #00d4ff;
  --accent-purple: #7c3aed;
  --accent-green:  #10b981;
  --accent-amber:  #f59e0b;
  --accent-red:    #ef4444;
  --accent-blue:   #3b82f6;
  --accent-pink:   #ec4899;

  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #475569;
  --text-inverse:  #0a0f1e;

  --border-color:  #1e293b;
  --border-light:  #263348;

  --sidebar-w:     260px;
  --topbar-h:      64px;

  /* Gradients */
  --grad-cyan:   linear-gradient(135deg, #00d4ff, #0099cc);
  --grad-purple: linear-gradient(135deg, #7c3aed, #a855f7);
  --grad-green:  linear-gradient(135deg, #10b981, #059669);
  --grad-amber:  linear-gradient(135deg, #f59e0b, #d97706);
  --grad-red:    linear-gradient(135deg, #ef4444, #dc2626);
  --grad-brand:  linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);
  --grad-dark:   linear-gradient(135deg, #0d1526, #111827);

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
  --shadow-cyan: 0 0 20px rgba(0,212,255,0.15);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.4);

  /* Spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 9999px;

  /* Transitions */
  --t-fast: 0.15s ease;
  --t-med:  0.25s ease;
  --t-slow: 0.4s ease;

  /* Z-index */
  --z-sidebar:  100;
  --z-topbar:   200;
  --z-modal:    300;
  --z-toast:    400;
  --z-loader:   500;
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-cyan); text-decoration: none; }
a:hover { opacity: 0.85; }

img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ───── Scrollbar ───── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ───── Typography ───── */
h1 { font-size: 2rem; font-weight: 800; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 600; }
h4 { font-size: 1rem;   font-weight: 600; }
h5 { font-size: 0.875rem; font-weight: 600; }

.text-xs   { font-size: 0.75rem; }
.text-sm   { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg   { font-size: 1.125rem; }
.text-xl   { font-size: 1.25rem; }
.text-2xl  { font-size: 1.5rem; }
.text-3xl  { font-size: 2rem; }

.font-light   { font-weight: 300; }
.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-black   { font-weight: 800; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-cyan      { color: var(--accent-cyan); }
.text-purple    { color: var(--accent-purple); }
.text-green     { color: var(--accent-green); }
.text-amber     { color: var(--accent-amber); }
.text-red       { color: var(--accent-red); }
.text-center    { text-align: center; }
.text-right     { text-align: right; }
.text-left      { text-align: left; }

/* ───── Utility Layout ───── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.flex-1 { flex: 1; }
.grid { display: grid; }

.hidden        { display: none !important; }
.invisible     { visibility: hidden; }
.block         { display: block; }
.inline-block  { display: inline-block; }
.inline-flex   { display: inline-flex; }
.w-full        { width: 100%; }
.h-full        { height: 100%; }

.p-0  { padding: 0; }
.p-2  { padding: var(--sp-2); }
.p-4  { padding: var(--sp-4); }
.p-6  { padding: var(--sp-6); }
.pt-4 { padding-top: var(--sp-4); }
.pb-4 { padding-bottom: var(--sp-4); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.py-2 { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }

.m-0  { margin: 0; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.ml-2 { margin-left: var(--sp-2); }
.mr-2 { margin-right: var(--sp-2); }
.mx-auto { margin-left: auto; margin-right: auto; }

.rounded-sm  { border-radius: var(--r-sm); }
.rounded-md  { border-radius: var(--r-md); }
.rounded-lg  { border-radius: var(--r-lg); }
.rounded-xl  { border-radius: var(--r-xl); }
.rounded-full{ border-radius: var(--r-full); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }

.cursor-pointer { cursor: pointer; }
.select-none    { user-select: none; }
.opacity-50     { opacity: 0.5; }
.opacity-0      { opacity: 0; }

/* ───── Badges / Status ───── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-success { background: rgba(16,185,129,0.18); color: var(--accent-green); border: 1px solid rgba(16,185,129,0.3); }
.badge-warning { background: rgba(245,158,11,0.18); color: var(--accent-amber); border: 1px solid rgba(245,158,11,0.3); }
.badge-danger  { background: rgba(239,68,68,0.18);  color: var(--accent-red);   border: 1px solid rgba(239,68,68,0.3); }
.badge-info    { background: rgba(0,212,255,0.15);   color: var(--accent-cyan);  border: 1px solid rgba(0,212,255,0.25); }
.badge-purple  { background: rgba(124,58,237,0.18); color: var(--accent-purple);border: 1px solid rgba(124,58,237,0.3); }
.badge-muted   { background: rgba(71,85,105,0.3);   color: var(--text-secondary);border: 1px solid var(--border-color); }

/* ───── Animations ───── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0,212,255,0.3); }
  50%       { box-shadow: 0 0 24px rgba(0,212,255,0.6); }
}

.animate-fade-in    { animation: fadeIn 0.3s ease forwards; }
.animate-slide-up   { animation: slideInUp 0.3s ease forwards; }
.animate-slide-left { animation: slideInLeft 0.3s ease forwards; }
.animate-pulse      { animation: pulse 2s ease-in-out infinite; }
.animate-spin       { animation: spin 1s linear infinite; }

/* ───── Sync Status ───── */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--t-med);
}
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.sync-online  { background: rgba(16,185,129,0.15); color: var(--accent-green);  border-color: rgba(16,185,129,0.3); }
.sync-online .sync-dot  { background: var(--accent-green);  animation: glowPulse 2s infinite; }
.sync-offline { background: rgba(239,68,68,0.15);  color: var(--accent-red);    border-color: rgba(239,68,68,0.3); }
.sync-offline .sync-dot { background: var(--accent-red); }
.sync-pending { background: rgba(245,158,11,0.15); color: var(--accent-amber);  border-color: rgba(245,158,11,0.3); }
.sync-pending .sync-dot { background: var(--accent-amber); animation: pulse 1s infinite; }
.sync-syncing { background: rgba(0,212,255,0.12);  color: var(--accent-cyan);   border-color: rgba(0,212,255,0.25); }
.sync-syncing .sync-dot { background: var(--accent-cyan); animation: pulse 0.8s infinite; }

/* ───── App Layout ───── */
.app-body {
  overflow: hidden;
  background: var(--bg-primary);
}
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-6);
  background: var(--bg-primary);
}

/* ───── Section Panels ───── */
.section-panel {
  display: none;
  animation: fadeIn 0.25s ease;
}
.section-panel.active {
  display: block;
}

/* ───── Global Loader ───── */
.global-loader {
  position: fixed;
  inset: 0;
  background: rgba(10,15,30,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-loader);
  backdrop-filter: blur(4px);
}

/* ───── Divider ───── */
.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--sp-4) 0;
}

/* ───── Loading Placeholder ───── */
.loading-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* ───── Empty State ───── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  color: var(--text-muted);
  gap: var(--sp-3);
}
.empty-state svg, .empty-state i {
  width: 48px; height: 48px;
  opacity: 0.4;
  margin-bottom: var(--sp-2);
}
.empty-state p { font-size: 0.95rem; }

/* ───── Print Styles ───── */
@media print {
  .sidebar, .topbar, .btn:not(.print-btn),
  .modal-close, .no-print { display: none !important; }
  body, .app-layout, .main-content, .content-area {
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
  }
  .section-panel { display: block !important; }
  table { border-collapse: collapse; width: 100%; }
  th, td { border: 1px solid #333; padding: 6px 8px; color: black; }
  th { background: #f0f0f0 !important; }
  .print-header { display: block !important; text-align: center; margin-bottom: 20px; }
  .badge { border: 1px solid #333 !important; color: black !important; background: transparent !important; }
  @page { margin: 1.5cm; }
}

/* ───── Responsive ───── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
}
@media (max-width: 768px) {
  .content-area { padding: var(--sp-4); }
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); transition: transform var(--t-med); }
  .sidebar.open { transform: translateX(0); width: 260px; }
}
