/* ============================================
   Creaton — Design System
   Premium Design Tokens & Base Styles
   ============================================ */

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

/* ====== CSS Custom Properties (Design Tokens) ====== */
:root {
    /* Colors — Primary */
    --primary-50: #ecf9fc;
    --primary-100: #d5f0f7;
    --primary-200: #ade2ef;
    --primary-300: #7ecde2;
    --primary-400: #46b3d2;
    --primary-500: #1f97bc;
    --primary-600: #167ca0;
    --primary-700: #156583;
    --primary-800: #16536b;
    --primary-900: #17455a;

    /* Colors — Secondary (Blue-Gray) */
    --secondary-400: #9fc6d8;
    --secondary-500: #7fadc5;
    --secondary-600: #5e8ea9;
    --secondary-700: #4a738b;

    /* Colors — Accent */
    --accent-400: #f3cf84;
    --accent-500: #e9b85b;
    --accent-600: #d9992e;

    /* Colors — Semantic */
    --success-50: #ecfdf5;
    --success-100: #d1fae5;
    --success-500: #10b981;
    --success-600: #059669;
    --danger-50: #fef2f2;
    --danger-100: #fee2e2;
    --danger-500: #ef4444;
    --danger-600: #dc2626;
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --info-50: #eff6ff;
    --info-100: #dbeafe;
    --info-500: #3b82f6;
    --info-600: #2563eb;

    /* Colors — Neutral */
    --gray-50: #f8fafc;
    --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;
    --gray-950: #020617;

    /* Surface Colors */
    --surface: #fbfdff;
    --surface-raised: #ffffff;
    --surface-overlay: rgba(251, 253, 255, 0.95);
    --body-bg: #e6eef3;
    --border-color: #ccdbe5;

    /* Text */
    --text-primary: #1f3343;
    --text-secondary: #3d5568;
    --text-muted: #7390a3;
    --text-inverse: #ffffff;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
    --text-6xl: 3.75rem;

    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    --tracking-tight: -0.025em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;

    /* 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;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 20px rgba(31, 151, 188, 0.3);
    --shadow-colored: 0 4px 14px rgba(31, 151, 188, 0.25);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Z-Index */
    --z-dropdown: 50;
    --z-sticky: 100;
    --z-fixed: 200;
    --z-overlay: 300;
    --z-modal: 400;
    --z-toast: 500;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #167ca0, #3ea8c8);
    --gradient-secondary: linear-gradient(135deg, #2e8ea9, #89c3d8);
    --gradient-accent: linear-gradient(135deg, #e9b85b, #e8906f);
    --gradient-success: linear-gradient(135deg, #10b981, #059669);
    --gradient-hero: linear-gradient(135deg, #0b3e50 0%, #11566c 45%, #1a6f88 100%);
    --gradient-glass: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));

    /* Container */
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1280px;
    --container-2xl: 1400px;

    /* Sidebar */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 64px;
}

/* ====== Dark Mode ====== */
[data-theme="dark"] {
    --surface: #173648;
    --surface-raised: #1f4458;
    --surface-overlay: rgba(23, 54, 72, 0.95);
    --body-bg: #0e2633;
    --border-color: #28516a;
    --text-primary: #e6f3fb;
    --text-secondary: #bfd9e7;
    --text-muted: #7fa8bc;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
}

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

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

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--body-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a {
    color: var(--primary-600);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--primary-700);
}

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

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }

p { margin-bottom: var(--space-4); color: var(--text-secondary); }

::selection {
    background: var(--primary-200);
    color: var(--primary-900);
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-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); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--gray-600); }

/* ====== Container ====== */
.container {
    width: 100%;
    max-width: var(--container-xl);
    margin: 0 auto;
    padding: 0 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); }

/* ====== Focus Styles ====== */
:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ====== Utilities ====== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary-600); }
.text-success { color: var(--success-500); }
.text-danger { color: var(--danger-500); }
.text-warning { color: var(--warning-500); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.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); }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.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;
}

.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relative { position: relative; }

/* ====== Animations ====== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade { animation: fadeIn 0.4s ease forwards; }
.animate-slide-up { animation: slideUp 0.5s ease forwards; }
.animate-scale { animation: scaleIn 0.3s ease forwards; }
.animate-pulse { animation: pulse 2s infinite; }

/* Staggered animation delays */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}
.skeleton--text { height: 1em; width: 80%; margin-bottom: var(--space-2); }
.skeleton--title { height: 1.5em; width: 60%; margin-bottom: var(--space-3); }
.skeleton--avatar { width: 40px; height: 40px; border-radius: var(--radius-full); }
.skeleton--card { height: 200px; }

/* ====== Responsive ====== */
@media (max-width: 768px) {
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    h3 { font-size: var(--text-xl); }
    .container { padding: 0 var(--space-4); }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .hide-mobile { display: none !important; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1025px) {
    .hide-desktop { display: none !important; }
}
