/* ============================================
   SUBSTACKER - UNIFIED DESIGN SYSTEM
   Comprehensive design tokens and components
   Dark theme with glass morphism aesthetic
   ============================================ */

/* ====== CSS CUSTOM PROPERTIES (DESIGN TOKENS) ====== */
:root {
    /* ===== COLOR PALETTE ===== */

    /* Primary Brand Colors */
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-primary-light: #818cf8;
    --color-secondary: #8b5cf6;
    --color-secondary-dark: #7c3aed;
    --color-secondary-light: #a78bfa;

    /* Status & Feedback Colors */
    --color-success: #10b981;
    --color-success-dark: #059669;
    --color-success-light: #34d399;
    --color-warning: #f59e0b;
    --color-warning-dark: #d97706;
    --color-warning-light: #fbbf24;
    --color-danger: #ef4444;
    --color-danger-dark: #dc2626;
    --color-danger-light: #f87171;
    --color-info: #3b82f6;
    --color-info-dark: #2563eb;
    --color-info-light: #60a5fa;

    /* Accent Colors */
    --accent-purple: #8b5cf6;
    --accent-blue: #6366f1;
    --accent-pink: #ec4899;
    --accent-amber: #f59e0b;

    /* Background Colors - Dark Theme */
    --bg-primary: #0a0a0f;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16162a;

    /* Glass Morphism Surfaces */
    --glass-white: rgba(255, 255, 255, 0.05);
    --glass-white-hover: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-border-hover: rgba(255, 255, 255, 0.2);

    /* Text Colors - Dark Mode */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.85);
    --text-tertiary: rgba(255, 255, 255, 0.65);
    --text-muted: rgba(255, 255, 255, 0.45);

    /* Neutral Grays (for light mode & mixed contexts) */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* ===== GRADIENTS ===== */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-purple-blue: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-accent: linear-gradient(135deg, #f59e0b 0%, #ec4899 100%);
    --gradient-text: linear-gradient(135deg, #a78bfa 0%, #ec4899 50%, #f59e0b 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);

    /* ===== SPACING SCALE ===== */
    --spacing-xs: 0.25rem;    /* 4px */
    --spacing-sm: 0.5rem;     /* 8px */
    --spacing-md: 1rem;       /* 16px */
    --spacing-lg: 1.5rem;     /* 24px */
    --spacing-xl: 2rem;       /* 32px */
    --spacing-2xl: 3rem;      /* 48px */
    --spacing-3xl: 4rem;      /* 64px */
    --spacing-4xl: 6rem;      /* 96px */

    /* ===== TYPOGRAPHY ===== */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Courier New', monospace;

    /* Font Sizes */
    --font-size-xs: 0.75rem;      /* 12px */
    --font-size-sm: 0.875rem;     /* 14px */
    --font-size-base: 1rem;       /* 16px */
    --font-size-lg: 1.125rem;     /* 18px */
    --font-size-xl: 1.25rem;      /* 20px */
    --font-size-2xl: 1.5rem;      /* 24px */
    --font-size-3xl: 1.875rem;    /* 30px */
    --font-size-4xl: 2.25rem;     /* 36px */
    --font-size-5xl: 3rem;        /* 48px */
    --font-size-6xl: 3.75rem;     /* 60px */

    /* Font Weights */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;

    /* Line Heights */
    --line-height-tight: 1.25;
    --line-height-snug: 1.375;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;
    --line-height-loose: 2;

    /* ===== BORDER RADIUS ===== */
    --radius-sm: 0.25rem;    /* 4px */
    --radius-md: 0.5rem;     /* 8px */
    --radius-lg: 0.75rem;    /* 12px */
    --radius-xl: 1rem;       /* 16px */
    --radius-2xl: 1.5rem;    /* 24px */
    --radius-full: 9999px;

    /* ===== SHADOWS ===== */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.3);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 32px rgba(139, 92, 246, 0.4);
    --shadow-glow-hover: 0 0 48px rgba(139, 92, 246, 0.6);

    /* ===== BLUR EFFECTS ===== */
    --blur-sm: blur(8px);
    --blur-md: blur(16px);
    --blur-lg: blur(24px);
    --blur-xl: blur(32px);

    /* ===== TRANSITIONS ===== */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ===== Z-INDEX SCALE ===== */
    --z-base: 1;
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;

    /* ===== LAYOUT ===== */
    --container-max-width: 1280px;
    --container-padding: 24px;
    --section-padding: 120px;
}

/* ====== LIGHT MODE OVERRIDES ====== */
body.light-mode {
    /* Light Mode Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;

    /* Light Mode Glass Surfaces */
    --glass-white: rgba(255, 255, 255, 0.8);
    --glass-white-hover: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-border-hover: rgba(0, 0, 0, 0.2);

    /* Light Mode Text Colors */
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-tertiary: #6b7280;
    --text-muted: #9ca3af;

    /* Light Mode Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 32px rgba(139, 92, 246, 0.3);
    --shadow-glow-hover: 0 0 48px rgba(139, 92, 246, 0.4);
}

/* ====== REUSABLE COMPONENT CLASSES ====== */

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-normal);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-hover);
}

.btn-secondary {
    background: var(--glass-white);
    backdrop-filter: var(--blur-md);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: var(--glass-white-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-outline:hover {
    background: rgba(99, 102, 241, 0.1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}

.btn-ghost:hover {
    background: var(--glass-white);
    color: var(--text-primary);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--color-warning) 0%, var(--color-warning-dark) 100%);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 24px rgba(245, 158, 11, 0.4);
}

/* Button Sizes */
.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-2xl);
    font-size: var(--font-size-lg);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    aspect-ratio: 1;
}

/* ===== CARDS ===== */
.card {
    background: var(--glass-white);
    backdrop-filter: var(--blur-lg);
    -webkit-backdrop-filter: var(--blur-lg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-xl);
}

.card-compact {
    padding: var(--spacing-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--glass-border);
}

.card-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 0;
}

.card-footer {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--glass-border);
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.02em;
    line-height: 1;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-info);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--color-primary);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* ===== ALERTS ===== */
.alert {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    border-left: 4px solid;
}

.alert-icon {
    font-size: var(--font-size-xl);
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--spacing-xs);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success-dark);
    border-left-color: var(--color-success);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning-dark);
    border-left-color: var(--color-warning);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger-dark);
    border-left-color: var(--color-danger);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-info-dark);
    border-left-color: var(--color-info);
}

/* ===== TABLES ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--glass-white);
    backdrop-filter: var(--blur-lg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table thead {
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--glass-border);
}

.table th {
    padding: var(--spacing-lg) var(--spacing-lg);
    text-align: left;
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.table td {
    padding: var(--spacing-lg) var(--spacing-lg);
    border-bottom: 1px solid var(--glass-border);
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: all var(--transition-fast);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* ===== FORM ELEMENTS ===== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--glass-white);
    backdrop-filter: var(--blur-sm);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    transition: all var(--transition-base);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background: rgba(0, 0, 0, 0.3);
    cursor: not-allowed;
    opacity: 0.6;
}

.form-helper {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
}

.form-error {
    font-size: var(--font-size-sm);
    color: var(--color-danger);
}

/* ===== PROGRESS BAR ===== */
.progress {
    height: 8px;
    background: var(--glass-white);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    transition: width var(--transition-base);
    border-radius: var(--radius-full);
}

.progress-bar-success {
    background: var(--gradient-success);
}

.progress-bar-warning {
    background: linear-gradient(90deg, var(--color-warning), var(--color-warning-light));
}

.progress-bar-danger {
    background: var(--gradient-danger);
}

/* ===== SPINNER / LOADER ===== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== UTILITY CLASSES ===== */

/* Text Utilities */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-muted { color: var(--text-muted); }

.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-info { color: var(--color-info); }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }
.font-extrabold { font-weight: var(--font-weight-extrabold); }

/* Spacing Utilities */
.m-0 { margin: 0; }
.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.p-xs { padding: var(--spacing-xs); }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

/* Display Utilities */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Flexbox Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.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-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.gap-xl { gap: var(--spacing-xl); }

/* Border 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); }

/* Shadow Utilities */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }
.shadow-glow { box-shadow: var(--shadow-glow); }

/* Width/Height Utilities */
.w-full { width: 100%; }
.h-full { height: 100%; }
.w-auto { width: auto; }
.h-auto { height: auto; }

/* Cursor Utilities */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* Opacity Utilities */
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    :root {
        --section-padding: 80px;
        --container-padding: 16px;
    }

    .d-none-mobile { display: none !important; }
    .flex-col-mobile { flex-direction: column !important; }
}

@media (max-width: 480px) {
    :root {
        --section-padding: 60px;
    }
}

/* ===== ACCESSIBILITY ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
    border-radius: var(--radius-md);
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
