/* =============================================================
   MTDNES CARE V2 — base.css
   Design System: Tokens, Reset, Typography, Layout
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&family=DM+Mono:wght@400;500&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Colors */
  --navy-950:  #040D1A;
  --navy-900:  #0A1628;
  --navy-800:  #112238;
  --navy-700:  #1A3350;
  --navy-600:  #234468;
  --navy-500:  #2D5680;
  --navy-400:  #4A7AA8;
  --navy-300:  #6E9CC4;
  --navy-200:  #A4C3DD;
  --navy-100:  #D5E5F0;
  --navy-050:  #EDF4F9;

  --teal-700:  #006B65;
  --teal-600:  #008C84;
  --teal-500:  #00A89E;
  --teal-400:  #00B4A6;
  --teal-300:  #33C9BD;
  --teal-200:  #80DFDA;
  --teal-100:  #BBEFED;
  --teal-050:  #E5F9F8;

  --emerald-500: #10B981;
  --amber-500:   #F59E0B;
  --rose-500:    #F43F5E;
  --violet-500:  #8B5CF6;

  --white:  #FFFFFF;
  --gray-50:  #F8FAFB;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* Semantic */
  --bg-page:        var(--gray-50);
  --bg-surface:     var(--white);
  --bg-elevated:    var(--white);
  --bg-overlay:     rgba(4, 13, 26, 0.55);

  --text-primary:   var(--navy-900);
  --text-secondary: var(--gray-600);
  --text-muted:     var(--gray-400);
  --text-inverse:   var(--white);

  --border-default: var(--gray-200);
  --border-strong:  var(--gray-300);
  --border-focus:   var(--teal-400);

  --brand-primary:  var(--teal-400);
  --brand-dark:     var(--teal-700);
  --brand-light:    var(--teal-100);

  --status-success-bg:   #ECFDF5;
  --status-success-text: #065F46;
  --status-success-ring: #6EE7B7;
  --status-warning-bg:   #FFFBEB;
  --status-warning-text: #92400E;
  --status-warning-ring: #FCD34D;
  --status-error-bg:     #FFF1F2;
  --status-error-text:   #9F1239;
  --status-error-ring:   #FDA4AF;
  --status-info-bg:      var(--navy-050);
  --status-info-text:    var(--navy-700);
  --status-info-ring:    var(--navy-200);

  /* Typography */
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', ui-monospace, monospace;

  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.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 */
  --text-5xl:  3rem;      /* 48px */
  --text-6xl:  3.75rem;   /* 60px */

  --leading-tight:  1.25;
  --leading-snug:   1.375;
  --leading-normal: 1.5;
  --leading-relaxed:1.625;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Borders */
  --radius-sm:  0.25rem;
  --radius-md:  0.5rem;
  --radius-lg:  0.75rem;
  --radius-xl:  1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs:  0 1px 2px 0 rgba(10,22,40,.05);
  --shadow-sm:  0 1px 3px 0 rgba(10,22,40,.08), 0 1px 2px -1px rgba(10,22,40,.06);
  --shadow-md:  0 4px 6px -1px rgba(10,22,40,.08), 0 2px 4px -2px rgba(10,22,40,.06);
  --shadow-lg:  0 10px 15px -3px rgba(10,22,40,.08), 0 4px 6px -4px rgba(10,22,40,.05);
  --shadow-xl:  0 20px 25px -5px rgba(10,22,40,.10), 0 8px 10px -6px rgba(10,22,40,.06);
  --shadow-2xl: 0 25px 50px -12px rgba(10,22,40,.18);
  --shadow-inset: inset 0 2px 4px 0 rgba(10,22,40,.06);
  --shadow-brand: 0 4px 20px rgba(0,180,166,.25);

  /* Transitions */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base:   250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index layers */
  --z-below:   -1;
  --z-base:     0;
  --z-raised:   10;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  300;
  --z-modal:    400;
  --z-toast:    500;
  --z-tooltip:  600;

  /* Layout */
  --container-sm:  640px;
  --container-md:  768px;
  --container-lg:  1024px;
  --container-xl:  1280px;
  --container-2xl: 1440px;

  --sidebar-width:      260px;
  --sidebar-collapsed:  72px;
  --topbar-height:      64px;
  --card-padding:       var(--space-6);
}

/* Dark mode tokens */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-page:        var(--navy-950);
    --bg-surface:     var(--navy-900);
    --bg-elevated:    var(--navy-800);
    --text-primary:   #EDF4F9;
    --text-secondary: var(--navy-200);
    --text-muted:     var(--navy-400);
    --border-default: var(--navy-700);
    --border-strong:  var(--navy-600);
  }
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-page);
  min-height: 100vh;
  overflow-x: hidden;
}

img, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, textarea, select, button {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol { list-style: none; }

table { border-collapse: collapse; }

hr {
  border: none;
  border-top: 1px solid var(--border-default);
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-3xl); letter-spacing: -0.015em; }
h3 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p { line-height: var(--leading-relaxed); }

small { font-size: var(--text-sm); }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  background: var(--gray-100);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  white-space: pre-wrap;
}

strong { font-weight: 600; }
em     { font-style: italic; }

/* ── Layout Utilities ───────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--sm  { max-width: var(--container-sm); }
.container--md  { max-width: var(--container-md); }
.container--lg  { max-width: var(--container-lg); }
.container--2xl { max-width: var(--container-2xl); }

.flex    { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end    { justify-content: flex-end; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-h-screen { min-height: 100vh; }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

.hidden   { display: none !important; }
.invisible { visibility: hidden; }

.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.overflow-y-auto { overflow-y: auto; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Text Utilities ─────────────────────────────────────────── */
.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-brand     { color: var(--brand-primary); }
.text-white     { color: var(--white); }

.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-display { font-family: var(--font-display); }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

.uppercase   { text-transform: uppercase; }
.capitalize  { text-transform: capitalize; }
.tracking-wider { letter-spacing: 0.05em; }
.tracking-widest { letter-spacing: 0.1em; }

/* ── Spacing Utilities ──────────────────────────────────────── */
.p-2  { padding: var(--space-2); }
.p-3  { padding: var(--space-3); }
.p-4  { padding: var(--space-4); }
.p-6  { padding: var(--space-6); }
.p-8  { padding: var(--space-8); }
.px-3 { padding-inline: var(--space-3); }
.px-4 { padding-inline: var(--space-4); }
.px-6 { padding-inline: var(--space-6); }
.py-2 { padding-block: var(--space-2); }
.py-3 { padding-block: var(--space-3); }
.py-4 { padding-block: var(--space-4); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mx-auto { margin-inline: auto; }

/* ── Border & Radius Utilities ──────────────────────────────── */
.rounded-sm   { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-xl   { border-radius: var(--radius-xl); }
.rounded-2xl  { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

.border        { border: 1px solid var(--border-default); }
.border-strong { border-color: var(--border-strong); }

/* ── Focus styles ───────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Selection ──────────────────────────────────────────────── */
::selection {
  background: var(--teal-200);
  color: var(--navy-900);
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.animate-fadeIn    { animation: fadeIn var(--transition-base) forwards; }
.animate-fadeInUp  { animation: fadeInUp var(--transition-slow) forwards; }
.animate-scaleIn   { animation: scaleIn var(--transition-spring) forwards; }
.animate-spin      { animation: spin 1s linear infinite; }
.animate-pulse     { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* Stagger helpers */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.30s; }

/* ── Skeleton ───────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--gray-100) 25%,
    var(--gray-200) 50%,
    var(--gray-100) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --card-padding: var(--space-4);
  }
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl); }
  .container { padding-inline: var(--space-4); }
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  :root { --card-padding: var(--space-4); }
  h1 { font-size: var(--text-2xl); }
}
