/**
 * KPI Portal – Base Styles
 * Reset, typography, global utilities.
 */

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

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  background: var(--page-bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
}

/* ── Scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Focus ──────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Typography scale ─────────────────────────────────────────────── */
.text-xs    { font-size: 11px; }
.text-sm    { font-size: 12px; }
.text-base  { font-size: 14px; }
.text-md    { font-size: 15px; }
.text-lg    { font-size: 18px; }
.text-xl    { font-size: 22px; }
.text-2xl   { font-size: 28px; }
.text-3xl   { font-size: 36px; }

.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.font-mono    { font-family: var(--font-data); }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-faint     { color: var(--text-faint); }
.text-accent    { color: var(--accent); }
.text-success   { color: var(--success-chart); }
.text-warning   { color: var(--warning-chart); }
.text-danger    { color: var(--danger-chart); }
.text-purple    { color: var(--purple-chart); }
.text-upper     { text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Layout helpers ────────────────────────────────────────────────── */
.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.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-2          { gap: 4px; }
.gap-3          { gap: 8px; }
.gap-4          { gap: 12px; }
.gap-5          { gap: 16px; }
.gap-6          { gap: 20px; }
.flex-1         { flex: 1; }
.flex-shrink-0  { flex-shrink: 0; }
.w-full         { width: 100%; }
.min-w-0        { min-width: 0; }
.hidden         { display: none !important; }
.invisible      { visibility: hidden; }
.overflow-hidden{ overflow: hidden; }
.truncate       { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relative       { position: relative; }
.absolute       { position: absolute; }

/* ── Grid helpers ─────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Spacing helpers ─────────────────────────────────────────────── */
.mb-2 { margin-bottom: 4px; }
.mb-3 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 12px; }
.mb-5 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 20px; }
.mb-8 { margin-bottom: 24px; }
.mb-10{ margin-bottom: 32px; }
.mt-3 { margin-top: 8px; }
.mt-4 { margin-top: 12px; }
.mt-5 { margin-top: 16px; }

/* ── Data number ─────────────────────────────────────────────────── */
.num {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

/* ── Loading spinner ─────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Skeleton loader ─────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border-color) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  opacity: 0.35;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}
.empty-state-desc {
  font-size: 13px;
  max-width: 320px;
  line-height: 1.6;
}

/* ── Page enter animation ────────────────────────────────────────── */
.page-enter {
  animation: pageEnter 0.2s ease forwards;
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
