/* ==========================================================================
   Kalqy — Global design tokens & base styles
   ========================================================================== */

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

:root {
  /* Brand */
  --primary: #6C63FF;
  --primary-dark: #5148D8;
  --primary-light: #EEECFF;
  --secondary: #FFB84D;
  --secondary-light: #FFF3E0;

  /* Supporting */
  --success: #42B883;
  --success-light: #E6F7EF;
  --danger: #EF6A6A;
  --danger-light: #FDECEC;
  --info: #55A7E8;
  --info-light: #EAF5FE;

  /* Background */
  --background: #F7F8FC;
  --surface: #FFFFFF;
  --border: #EAEBF3;

  /* Text */
  --text-primary: #202336;
  --text-secondary: #6F7487;
  --text-muted: #A0A5B5;
  --text-on-primary: #FFFFFF;

  /* Radii */
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(32, 35, 54, 0.05), 0 1px 4px rgba(32, 35, 54, 0.04);
  --shadow-md: 0 4px 16px rgba(32, 35, 54, 0.08);
  --shadow-lg: 0 12px 32px rgba(32, 35, 54, 0.12);

  /* Spacing (8px system) */
  --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;

  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Poppins', var(--font-body);

  --transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease, opacity 180ms ease;

  --nav-width: 264px;
  --content-max: 1440px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--background);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; margin: 0; color: var(--text-primary); }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }

.page-h1 { font-size: 28px; }
.page-h2 { font-size: 22px; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

@media (min-width: 768px) {
  .page-h1 { font-size: 34px; }
}

/* ---------- Focus & Accessibility ---------- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.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;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D9DBE9; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- App Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: var(--sp-6) var(--sp-5) calc(88px + var(--sp-6));
  max-width: 100%;
}

@media (min-width: 1024px) {
  .app-main {
    padding: var(--sp-8) var(--sp-10);
  }
}

.app-content {
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--primary-dark);
}
.brand .brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 16px;
  flex-shrink: 0;
}

/* ---------- Sidebar (desktop) ---------- */
.sidebar {
  display: none;
  width: var(--nav-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--sp-6) var(--sp-5);
  position: sticky;
  top: 0;
  height: 100vh;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .sidebar { display: flex; }
}

.sidebar .brand { margin-bottom: var(--sp-8); padding-left: var(--sp-1); }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 11px var(--sp-4);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
}
.side-nav a svg { width: 20px; height: 20px; flex-shrink: 0; }
.side-nav a:hover { background: var(--background); color: var(--text-primary); }
.side-nav a.active { background: var(--primary-light); color: var(--primary-dark); }

.side-nav-divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-4) var(--sp-1);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--sp-4);
}

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px var(--sp-2) calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
}
@media (min-width: 1024px) { .bottom-nav { display: none; } }

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  min-width: 52px;
  transition: var(--transition);
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.active svg { transform: translateY(-1px); }

/* ---------- Utility layout ---------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.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); }
.mt-2{margin-top:var(--sp-2)} .mt-3{margin-top:var(--sp-3)} .mt-4{margin-top:var(--sp-4)} .mt-6{margin-top:var(--sp-6)} .mt-8{margin-top:var(--sp-8)}
.mb-2{margin-bottom:var(--sp-2)} .mb-3{margin-bottom:var(--sp-3)} .mb-4{margin-bottom:var(--sp-4)} .mb-6{margin-bottom:var(--sp-6)}
.grid { display: grid; gap: var(--sp-4); }
.hide-mobile { display: none; }
@media (min-width: 768px) { .hide-mobile { display: block; } }
.hide-desktop { display: block; }
@media (min-width: 1024px) { .hide-desktop { display: none; } }
