/* Variables globales - Palette moderne et cohérente */
:root {
    /* Couleurs principales */
    --primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-solid: #667eea;
    --secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --secondary-solid: #f093fb;
    --accent: #00d4aa;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Arrière-plans */
    --bg-main: #0f0f23;
    --bg-panel: #1a1a2e;
    --bg-elevated: #16213e;
    --bg-surface: #0f3460;
    
    /* Textes */
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Bordures et ombres */
    --border-color: #334155;
    --border-light: rgba(148, 163, 184, 0.1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --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-glow: 0 0 20px rgba(102, 126, 234, 0.3);
    
    /* Rayons */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* Reset et styles de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Importation de la police Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Arrière-plan avec effet de gradient subtil */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at top, rgba(102, 126, 234, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* Header moderne */
header {
    text-align: center;
    margin-bottom: 48px;
    position: relative;
}

header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    background: var(--primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
    position: relative;
}

header h1::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
}

header p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
}

/* Layout principal avec espacement amélioré */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 48px;
}

/* Panneaux avec design moderne */
.editor-panel, .emulator-panel {
    background: var(--bg-panel);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-light);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.editor-panel:hover, .emulator-panel:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow), var(--shadow-lg);
}

.panel-header {
    background: var(--bg-elevated);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.panel-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--primary);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Controls avec design moderne */
.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

button {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-solid);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: var(--bg-surface);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

button:disabled:hover {
    transform: none;
    box-shadow: none;
}

#runBtn:not(:disabled) {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border: none;
}

#stopBtn {
    background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
    color: white;
    border: none;
}

#fps {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

/* Boutons Import/Export avec style moderne */
#importBtn {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border: none;
}

#exportBtn {
    background: linear-gradient(135deg, var(--primary-solid) 0%, #4f46e5 100%);
    color: white;
    border: none;
}

#importBtn:hover, #exportBtn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}



/* Éditeur de code avec thème moderne */
.editor-container {
    position: relative;
    background: var(--bg-elevated);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

#codeEditor {
    width: 100%;
    height: 450px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: none;
    padding: 24px;
    padding-bottom: 80px; /* Espace pour les boutons */
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: all 0.2s ease;
}

#codeEditor:focus {
    box-shadow: inset 0 0 0 1px var(--primary-solid);
}

.editor-controls {
    position: absolute;
    bottom: 16px;
    right: 24px;
    display: flex;
    gap: 12px;
    z-index: 10;
}

.editor-controls button {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.editor-controls button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.editor-controls button:hover::before {
    left: 100%;
}

.editor-controls button:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.editor-controls #compileBtn {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: white;
    border: none;
}

.editor-controls #runBtn:not(:disabled) {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border: none;
}

#codeEditor::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Sortie de compilation moderne */
#compileOutput {
    padding: 20px 24px;
    border-top: 1px solid var(--border-light);
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
    max-height: 120px;
    overflow-y: auto;
    background: var(--bg-panel);
}

#compileOutput::-webkit-scrollbar {
    width: 6px;
}

#compileOutput::-webkit-scrollbar-track {
    background: var(--bg-elevated);
}

#compileOutput::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.compile-success {
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 8px;
}

.compile-success::before {
    content: '✓';
    font-weight: bold;
}

.compile-error {
    color: var(--error);
    display: flex;
    align-items: center;
    gap: 8px;
}

.compile-error::before {
    content: '✗';
    font-weight: bold;
}

/* Émulateur avec design moderne */
.emulator-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.95) 100%);
    min-height: 400px;
    position: relative;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.emulator-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(240, 147, 251, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

#gameCanvas {
    border: 3px solid var(--border-color);
    background: #000;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    border-radius: var(--radius-md);
    box-shadow: 
        var(--shadow-lg),
        0 0 40px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

#gameCanvas:hover {
    box-shadow: 
        var(--shadow-lg),
        0 0 60px rgba(102, 126, 234, 0.3),
        0 0 40px rgba(0,0,0,0.5);
}

.emulator-info {
    padding: 20px 24px;
    background: var(--bg-panel);
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    border-top: 1px solid var(--border-light);
}

/* Documentation avec style moderne */
.docs-section {
    background: var(--bg-panel);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-light);
    padding: 32px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}

.docs-section h3 {
    background: var(--secondary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
    font-size: 1.5rem;
    font-weight: 600;
    position: relative;
}

.docs-section h3::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 40px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
}

.docs-content h4 {
    color: var(--primary-solid);
    margin: 24px 0 16px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.docs-content ul {
    list-style: none;
    padding-left: 0;
    gap: 8px;
}

.docs-content li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.docs-content li:hover {
    color: var(--text-primary);
    padding-left: 8px;
}

.docs-content code {
    background: var(--bg-elevated);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    border: 1px solid var(--border-light);
}

/* Tableau des exemples */
.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.example-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.example-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

.example-card h5 {
    margin: 0 0 8px 0;
    color: var(--accent);
    font-size: 1.1em;
    font-weight: 600;
}

.example-card p {
    margin: 0 0 12px 0;
    color: var(--text-secondary);
    font-size: 0.9em;
    line-height: 1.4;
}

.example-load-btn {
    background: linear-gradient(135deg, var(--accent), #0099cc);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: center;
}

.example-load-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 212, 170, 0.3);
}

.example-load-btn:active {
    transform: scale(0.95);
}

/* Amélioration de la visibilité des liens dans la documentation */
.docs-content a {
    color: #ff6b35 !important;
    text-decoration: underline;
    font-weight: 600;
    transition: all 0.2s ease;
}

.docs-content a:hover {
    color: #ff8f65 !important;
    text-decoration: none;
    background: rgba(255, 107, 53, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Style spécifique pour le bouton de téléchargement VSIX */
.docs-content a[download] {
    background: #ff6b35 !important;
    color: white !important;
    text-decoration: none !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    font-weight: 500 !important;
    display: inline-block !important;
    transition: all 0.2s ease !important;
}

.docs-content a[download]:hover {
    background: #e55a2b !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 107, 53, 0.3);
    padding: 6px 12px !important;
}

/* Responsive design amélioré */
@media (max-width: 1024px) {
    .container {
        padding: 16px;
    }
    
    header h1 {
        font-size: 2.8rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .panel-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        padding: 16px 20px;
    }
    
    .controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    #codeEditor {
        height: 300px;
        padding: 16px;
        padding-bottom: 60px;
    }
    
    .editor-controls {
        bottom: 12px;
        right: 16px;
        gap: 8px;
    }
    
    .editor-controls button {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    #gameCanvas {
        max-width: 100%;
        height: auto;
    }
    
    .emulator-container {
        padding: 20px;
        min-height: 300px;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .docs-section {
        padding: 24px 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .panel-header h3 {
        font-size: 1.1rem;
    }
    
    button {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* Animations et transitions globales */
* {
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

/* Amélioration des scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-elevated);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-solid);
}

/* Animation de loading subtile pour les éléments qui se chargent */
@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

.loading {
    background: linear-gradient(90deg, var(--bg-panel) 25%, var(--bg-elevated) 50%, var(--bg-panel) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}