/**
 * Cryptobots.io Design System Enhancement
 * Modern Design Components and Layout System
 * Phase 7: Advanced Design & Development Implementation
 */

/* CSS Custom Properties (Design Tokens) */
:root {
    /* Colors */
    --primary-blue: #1e3a8a;
    --primary-blue-light: #3b82f6;
    --secondary-yellow: #fbbf24;
    --secondary-yellow-dark: #f59e0b;
    --success-green: #10b981;
    --warning-orange: #f59e0b;
    --error-red: #ef4444;
    --neutral-gray-50: #f9fafb;
    --neutral-gray-100: #f3f4f6;
    --neutral-gray-200: #e5e7eb;
    --neutral-gray-300: #d1d5db;
    --neutral-gray-400: #9ca3af;
    --neutral-gray-500: #6b7280;
    --neutral-gray-600: #4b5563;
    --neutral-gray-700: #374151;
    --neutral-gray-800: #1f2937;
    --neutral-gray-900: #111827;
    --white: #ffffff;
    --black: #000000;
    
    /* Typography */
    --font-family-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    --font-family-mono: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
    
    /* Font Sizes */
    --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 */
    
    /* Line Heights */
    --leading-none: 1;
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --leading-loose: 2;
    
    /* 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;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Border Radius */
    --radius-none: 0;
    --radius-sm: 0.125rem;
    --radius: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-3xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* CSS Custom Properties Fallbacks for IE11 and older browsers */
@supports not (--test: red) {
    /* Button fallbacks */
    .btn-primary {
        background-color: #1e3a8a !important;
    }
    .btn-secondary {
        background-color: #fbbf24 !important;
        color: #1f2937 !important;
    }

    /* Text color fallbacks */
    .text-primary {
        color: #1e3a8a !important;
    }
    .text-secondary {
        color: #fbbf24 !important;
    }
    .text-success {
        color: #10b981 !important;
    }
    .text-error {
        color: #ef4444 !important;
    }
    .text-warning {
        color: #f59e0b !important;
    }
    .text-gray-400 {
        color: #9ca3af !important;
    }
    .text-gray-500 {
        color: #6b7280 !important;
    }
    .text-gray-600 {
        color: #4b5563 !important;
    }
    .text-gray-700 {
        color: #374151 !important;
    }
    .text-gray-900 {
        color: #111827 !important;
    }

    /* Background color fallbacks */
    .bg-white {
        background-color: #ffffff !important;
    }
    .bg-black {
        background-color: #000000 !important;
    }
    .bg-gray-50 {
        background-color: #f9fafb !important;
    }
    .bg-gray-100 {
        background-color: #f3f4f6 !important;
    }
    .bg-gray-800 {
        background-color: #1f2937 !important;
    }
    .bg-primary {
        background-color: #1e3a8a !important;
    }
    .bg-secondary {
        background-color: #fbbf24 !important;
    }

    /* Border color fallbacks */
    .border-gray-200 {
        border-color: #e5e7eb !important;
    }
    .border-gray-300 {
        border-color: #d1d5db !important;
    }

    /* Shadow fallbacks */
    .shadow-sm {
        box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
    }
    .shadow {
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
    }
    .shadow-md {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    }
    .shadow-lg {
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    }
    .shadow-xl {
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    }

    /* Border radius fallbacks */
    .rounded {
        border-radius: 0.25rem !important;
    }
    .rounded-sm {
        border-radius: 0.125rem !important;
    }
    .rounded-lg {
        border-radius: 0.5rem !important;
    }
    .rounded-xl {
        border-radius: 0.75rem !important;
    }
    .rounded-full {
        border-radius: 9999px !important;
    }

    /* Typography fallbacks */
    .hero-title {
        font-size: 3rem !important;
        line-height: 1.25 !important;
    }

    .hero-subtitle {
        font-size: 2rem !important;
        line-height: 1.25 !important;
    }

    .hero-description {
        font-size: 1.25rem !important;
        line-height: 1.375 !important;
    }

    .section-title {
        font-size: 1.875rem !important;
        line-height: 1.375 !important;
    }

    .section-description {
        font-size: 1.125rem !important;
        line-height: 1.5 !important;
    }

    /* Spacing fallbacks */
    .gap-2 {
        gap: 0.5rem !important;
    }
    .gap-6 {
        gap: 1.5rem !important;
    }

    /* Transition fallbacks */
    .transition-fast {
        transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    .transition-normal {
        transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* Backdrop-filter fallbacks */
    .navbar {
        background: rgba(255, 255, 255, 0.9) !important;
    }

    /* Clamp() function fallbacks */
    .hero-title {
        font-size: 3rem !important;
    }

    .hero-subtitle {
        font-size: 2rem !important;
    }

    .hero-description {
        font-size: 1.25rem !important;
    }

    .section-title {
        font-size: 1.875rem !important;
    }
}

/* Modern Component System */

/* Button Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-family-primary);
    font-size: var(--text-base);
    font-weight: 600;
    line-height: var(--leading-none);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    white-space: nowrap;
    min-height: 44px; /* Touch target */
}

.btn:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Button Variants */
.btn-primary {
    background-color: var(--secondary-yellow);
    color: var(--primary-blue);
    border-color: var(--secondary-yellow);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--secondary-yellow-dark);
    border-color: var(--secondary-yellow-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: transparent;
    color: var(--white);
    border-color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--white);
    color: var(--primary-blue);
}

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

.btn-outline:hover:not(:disabled) {
    background-color: var(--primary-blue);
    color: var(--white);
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    min-height: 36px;
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-lg);
    min-height: 52px;
}

/* Card Components */
.card {
    background-color: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--neutral-gray-200);
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--neutral-gray-200);
    background-color: var(--neutral-gray-50);
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--space-6);
}

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

.grid-auto-fit {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* CSS Grid Fallbacks for browsers without grid support */
@supports not (display: grid) {
    .grid {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-6);
    }

    .grid > * {
        flex: 1 1 300px;
        min-width: 250px;
    }

    .grid-cols-1,
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        display: flex;
        flex-wrap: wrap;
    }

    .grid-cols-1 > * {
        flex: 1 1 100%;
    }

    .grid-cols-2 > * {
        flex: 1 1 calc(50% - var(--space-3));
    }

    .grid-cols-3 > * {
        flex: 1 1 calc(33.333% - var(--space-4));
    }

    .grid-cols-4 > * {
        flex: 1 1 calc(25% - var(--space-5));
    }

    .grid-auto-fit {
        display: flex;
        flex-wrap: wrap;
    }

    .grid-auto-fit > * {
        flex: 1 1 300px;
        min-width: 250px;
    }

    /* Mobile responsive fallbacks for grid */
    @media (max-width: 768px) {
        .grid-cols-2 > *,
        .grid-cols-3 > *,
        .grid-cols-4 > * {
            flex: 1 1 100%;
        }
    }
}

@media (max-width: 768px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

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

/* Typography Components */
.heading-1 {
    font-size: clamp(var(--text-4xl), 5vw, var(--text-6xl));
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--neutral-gray-900);
}

.heading-2 {
    font-size: clamp(var(--text-3xl), 4vw, var(--text-5xl));
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--neutral-gray-900);
}

.heading-3 {
    font-size: clamp(var(--text-2xl), 3vw, var(--text-4xl));
    font-weight: 600;
    line-height: var(--leading-snug);
    color: var(--neutral-gray-900);
}

.heading-4 {
    font-size: clamp(var(--text-xl), 2.5vw, var(--text-3xl));
    font-weight: 600;
    line-height: var(--leading-snug);
    color: var(--neutral-gray-900);
}

.body-large {
    font-size: var(--text-xl);
    line-height: var(--leading-relaxed);
    color: var(--neutral-gray-700);
}

.body {
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--neutral-gray-700);
}

.body-small {
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--neutral-gray-600);
}

/* Form Components */
.form-group {
    display: flex;
    border-radius: var(--radius-full);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--white);
}

.form-input {
    flex: 1;
    padding: var(--space-4) var(--space-6);
    border: none;
    font-size: var(--text-base);
    outline: none;
    background: transparent;
    color: var(--neutral-gray-900);
}

.form-input::placeholder {
    color: var(--neutral-gray-500);
}

.form-button {
    background: var(--secondary-yellow);
    color: var(--primary-blue);
    padding: var(--space-4) var(--space-8);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    font-size: var(--text-base);
}

.form-button:hover {
    background: var(--secondary-yellow-dark);
}

/* Navigation Components */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--neutral-gray-200);
    padding: var(--space-4) 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    margin-bottom: var(--space-6);
    opacity: 0.8;
}

.breadcrumb a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb a:hover {
    color: var(--secondary-yellow);
}

.breadcrumb-separator {
    color: var(--neutral-gray-400);
}

/* Hero Components */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
    color: var(--white);
    text-align: center;
    padding: var(--space-20) 0;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

@media (max-width: 768px) {
    .hero {
        min-height: 80vh;
        padding: var(--space-16) 0;
    }
}

/* Section Components */
.section {
    padding: var(--space-20) 0;
}

.section-sm {
    padding: var(--space-16) 0;
}

.section-lg {
    padding: var(--space-32) 0;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

/* Icon Components */
.icon {
    width: var(--space-6);
    height: var(--space-6);
    display: inline-block;
    vertical-align: middle;
}

.icon-sm {
    width: var(--space-4);
    height: var(--space-4);
}

.icon-lg {
    width: var(--space-8);
    height: var(--space-8);
}

.icon-xl {
    width: var(--space-12);
    height: var(--space-12);
}

/* Badge Components */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-primary {
    background-color: var(--primary-blue);
    color: var(--white);
}

.badge-secondary {
    background-color: var(--secondary-yellow);
    color: var(--primary-blue);
}

.badge-success {
    background-color: var(--success-green);
    color: var(--white);
}

/* Animation Utilities */
.animate-fade-in {
    opacity: 0;
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-slide-up {
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 0.6s ease-out forwards;
}

.animate-bounce-in {
    transform: scale(0.3);
    opacity: 0;
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounceIn {
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

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

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

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.mb-6 {
    margin-bottom: var(--space-6);
}

.mb-8 {
    margin-bottom: var(--space-8);
}

.p-4 {
    padding: var(--space-4);
}

.p-6 {
    padding: var(--space-6);
}

.p-8 {
    padding: var(--space-8);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --neutral-gray-50: #111827;
        --neutral-gray-100: #1f2937;
        --neutral-gray-200: #374151;
        --neutral-gray-300: #4b5563;
        --neutral-gray-400: #6b7280;
        --neutral-gray-500: #9ca3af;
        --neutral-gray-600: #d1d5db;
        --neutral-gray-700: #e5e7eb;
        --neutral-gray-800: #f3f4f6;
        --neutral-gray-900: #f9fafb;
        --white: #111827;
        --black: #ffffff;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --shadow: none;
        --shadow-sm: none;
        --shadow-md: 0 0 0 2px currentColor;
        --shadow-lg: 0 0 0 3px currentColor;
        --shadow-xl: 0 0 0 4px currentColor;
    }
    
    .btn {
        border-width: 2px;
    }
    
    .card {
        border: 2px solid var(--neutral-gray-300);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .btn,
    .form-group {
        display: none;
    }
    
    .hero {
        min-height: auto;
        background: var(--white) !important;
        color: var(--black) !important;
    }
    
    .section {
        padding: var(--space-8) 0;
    }
}

/* IE11-Specific Fixes for Flexbox and Grid */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    /* IE11 Flexbox fixes */
    .w-layout-vflex {
        display: -ms-flexbox;
        -ms-flex-direction: column;
        -ms-flex-align: start;
    }

    .grid-responsive {
        display: -ms-flexbox;
        -ms-flex-wrap: wrap;
        -ms-flex-pack: center;
        -ms-flex-align: center;
    }

    .grid-responsive > * {
        -ms-flex: 0 0 auto;
        -ms-flex-positive: 0;
        -ms-flex-negative: 0;
        -ms-flex-preferred-size: auto;
    }

    /* IE11 Grid Layout fixes */
    .grid-layout {
        display: -ms-grid;
        -ms-grid-columns: 1fr 1fr;
        -ms-grid-rows: auto auto;
    }

    .grid-layout > * {
        -ms-grid-column: 1;
        -ms-grid-row: 1;
    }

    .grid-layout > *:nth-child(2) {
        -ms-grid-column: 2;
    }

    .grid-layout > *:nth-child(3) {
        -ms-grid-column: 1;
        -ms-grid-row: 2;
    }

    .grid-layout > *:nth-child(4) {
        -ms-grid-column: 2;
        -ms-grid-row: 2;
    }

    /* IE11 Button fixes */
    .btn {
        display: -ms-inline-flexbox;
        -ms-flex-pack: center;
        -ms-flex-align: center;
    }

    /* IE11 Container fixes */
    .container-regular {
        -ms-flex-pack: center;
        -ms-flex-align: center;
    }

    /* IE11 Form fixes */
    input[type="email"],
    input[type="text"],
    input[type="submit"],
    button {
        -ms-appearance: none;
        -ms-flex-positive: 1;
    }

    /* IE11 Typography fixes */
    .text-center {
        -ms-text-align-last: center;
    }

    /* IE11 Spacing fixes */
    .gap-fallback {
        -ms-flex-pack: justify;
    }

    .gap-fallback > * + * {
        margin-left: 16px;
        margin-right: 16px;
    }

    .gap-fallback > *:first-child {
        margin-left: 0;
    }

    .gap-fallback > *:last-child {
        margin-right: 0;
    }

    /* IE11 Animation fixes */
    .fade-in {
        -ms-animation: fadeIn 0.6s ease-out;
    }

    /* IE11 Position fixes */
    .absolute,
    .relative,
    .fixed {
        -ms-transform-origin: 50% 50%;
    }
}

/* IE11 Keyframes for animations */
@-ms-keyframes fadeIn {
    from {
        opacity: 0;
        -ms-transform: translateY(20px);
    }
    to {
        opacity: 1;
        -ms-transform: translateY(0);
    }
}