/* ============================================================
   BASE.CSS — Design Tokens, Reset, Typography
   ============================================================ */

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

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Colors */
  --color-bg:          #0f1117;
  --color-bg-2:        #161b27;
  --color-bg-3:        #1e2535;
  --color-bg-card:     #1a2030;
  --color-surface:     #212840;
  --color-border:      rgba(255,255,255,0.08);
  --color-border-2:    rgba(255,255,255,0.14);

  --color-primary:     #6c63ff;
  --color-primary-h:   #7b74ff;
  --color-primary-d:   #5549e8;
  --color-primary-glow: rgba(108,99,255,0.35);

  --color-secondary:   #00d9b5;
  --color-accent:      #ff6b6b;
  --color-amber:       #f9a825;

  --color-text:        #e8eaf6;
  --color-text-2:      #9ba3c0;
  --color-text-3:      #6b7594;
  --color-text-inv:    #0f1117;

  --color-success:     #4caf50;
  --color-warning:     #ff9800;
  --color-error:       #f44336;
  --color-info:        #2196f3;

  --color-online:      #4caf50;
  --color-offline:     #9ba3c0;

  /* Gradients */
  --grad-primary:   linear-gradient(135deg, #6c63ff, #a78bfa);
  --grad-card:      linear-gradient(145deg, #1e2535, #212840);
  --grad-cover:     linear-gradient(to bottom, transparent 40%, var(--color-bg-card));

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;

  /* Radius */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 24px var(--color-primary-glow);

  /* Typography */
  --font-family:  'Inter', system-ui, sans-serif;
  --font-xs:   11px;
  --font-sm:   13px;
  --font-base: 15px;
  --font-md:   17px;
  --font-lg:   20px;
  --font-xl:   24px;
  --font-2xl:  32px;
  --font-3xl:  40px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-med:  250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Sidebar */
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;
}

/* Light mode overrides */
[data-theme="light"] {
  --color-bg:       #f0f2f8;
  --color-bg-2:     #e8eaf3;
  --color-bg-3:     #dde0ed;
  --color-bg-card:  #ffffff;
  --color-surface:  #f5f6fc;
  --color-border:   rgba(0,0,0,0.08);
  --color-border-2: rgba(0,0,0,0.14);

  --color-text:    #1a1f36;
  --color-text-2:  #4a5568;
  --color-text-3:  #6b7280;
  --color-text-inv:#ffffff;

  --color-bg-card:  #ffffff;
  --grad-card: linear-gradient(145deg, #ffffff, #f7f8fc);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.12);
}

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

html {
  font-size: var(--font-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, video {
  display: block;
  max-width: 100%;
  height: auto;
}

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

a:hover { text-decoration: underline; }

ul, ol { list-style: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

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

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: var(--font-2xl); font-weight: 800; line-height: 1.2; }
h2 { font-size: var(--font-xl);  font-weight: 700; line-height: 1.3; }
h3 { font-size: var(--font-lg);  font-weight: 600; line-height: 1.4; }
h4 { font-size: var(--font-md);  font-weight: 600; }
h5 { font-size: var(--font-base);font-weight: 600; }

p { margin-bottom: var(--space-3); }
p:last-child { margin-bottom: 0; }

small { font-size: var(--font-sm); color: var(--color-text-2); }

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

/* ── Utilities ──────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}
.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.hidden { display: none !important; }
.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(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.text-sm { font-size: var(--font-sm); }
.text-xs { font-size: var(--font-xs); }
.text-muted { color: var(--color-text-2); }
.text-primary { color: var(--color-primary); }
.text-center { text-align: center; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.mt-auto { margin-top: auto; }
.ml-auto { margin-left: auto; }

/* ── 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 scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@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 bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}

.animate-fadein     { animation: fadeIn      var(--transition-med) forwards; }
.animate-scalein    { animation: scaleIn     var(--transition-med) forwards; }
.animate-slideinleft { animation: slideInLeft var(--transition-med) forwards; }

/* ── Skeleton loader ─────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-3) 25%,
    var(--color-surface) 50%,
    var(--color-bg-3) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
