/* Styles pour les blocs de code exécutables dans les cours */

/* Code éditable */
code[contenteditable="true"] {
    outline: none;
    cursor: text;
    transition: all 0.2s ease;
}

code[contenteditable="true"]:hover {
    background: #f8f8f8;
}

code[contenteditable="true"]:focus {
    background: #fffbf0;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
    border-radius: 4px;
}

[data-theme="dark"] code[contenteditable="true"]:hover {
    background: #2a2a2a;
}

[data-theme="dark"] code[contenteditable="true"]:focus {
    background: #2d2d2d;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

/* Balises inline personnalisées */
.inline-red-code {
    background: #2C2C2E;
    color: #FF3B30;
    font-family: 'Courier New', monospace;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    border: 1px solid #3A3A3C;
    display: inline;
    white-space: nowrap;
}

.inline-info {
    background: #E3F2FD;
    color: #1976D2;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    display: inline;
}

[data-theme="dark"] .inline-info {
    background: rgba(25, 118, 210, 0.2);
    color: #64B5F6;
}

.inline-image {
    display: inline;
    max-height: 1.5em;
    vertical-align: middle;
    margin: 0 0.2rem;
    border-radius: 4px;
}

/* Section d'exécution de code */
.code-execute-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-execute-code {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-execute-code:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-execute-code:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Console de sortie Python */
.code-output {
    margin-top: 1rem;
    padding: 1.25rem;
    border-radius: 8px;
    background: #1e1e1e;
    border: 2px solid #2d2d2d;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
    max-height: 400px;
    overflow-y: auto;
}

/* Indicateur de chargement */
.code-loading {
    color: #64b5f6;
    font-weight: 600;
    text-align: center;
    padding: 0.75rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Sortie standard (stdout) */
.code-stdout {
    color: #a5d6a7;
    font-weight: 400;
    line-height: 1.6;
}

.code-stdout::before {
    content: ">>>  ";
    color: #66bb6a;
    font-weight: 600;
}

/* Sortie d'erreur (stderr) */
.code-stderr {
    color: #ef5350;
    font-weight: 500;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(239, 83, 80, 0.1);
    border-left: 3px solid #ef5350;
    border-radius: 4px;
}

/* Messages d'erreur */
.code-error {
    color: #ff6b6b;
    font-weight: 600;
    padding: 0.75rem;
    background: rgba(239, 83, 80, 0.15);
    border-radius: 6px;
    border-left: 4px solid #ff6b6b;
}

.code-error::before {
    content: "❌ ERROR: ";
    font-weight: 700;
}

/* Message de réussite sans sortie */
.code-empty {
    color: #81c784;
    font-style: normal;
    text-align: center;
    padding: 0.75rem;
    font-weight: 500;
}

.code-empty::before {
    content: "✓ ";
    font-size: 1.2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .code-output {
        max-height: 300px;
        font-size: 0.85rem;
        padding: 1rem;
    }
    
    .btn-execute-code {
        width: 100%;
        padding: 0.75rem;
    }
}
