/**
 * Code Executor Modal Styles
 * For JavaScript and HTML code execution in tutorials
 */

/* Modal Overlay */
.code-executor-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.code-executor-modal.show {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

/* Modal Content */
.code-executor-content {
    background: linear-gradient(145deg, #1a1f2e 0%, #0f172a 100%);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 16px;
    width: 100%;
    max-width: 1000px;
    margin: 20px auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 
                0 0 40px rgba(96, 165, 250, 0.1);
    overflow: hidden;
}

/* Header */
.code-executor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(96, 165, 250, 0.2);
}

.code-executor-header h3 {
    margin: 0;
    color: #60a5fa;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.code-executor-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.code-executor-close:hover {
    color: #f87171;
}

/* Body */
.code-executor-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1.5rem;
    min-height: 400px;
}

/* Label */
.code-executor-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-executor-label button {
    background: rgba(71, 85, 105, 0.3);
    border: 1px solid rgba(71, 85, 105, 0.5);
    color: #94a3b8;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    margin-left: auto;
    transition: all 0.2s;
}

.code-executor-label button:hover {
    background: rgba(96, 165, 250, 0.2);
    border-color: rgba(96, 165, 250, 0.5);
    color: #60a5fa;
}

/* Textarea */
.code-executor-textarea {
    width: 100%;
    height: 300px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 8px;
    padding: 1rem;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}

.code-executor-textarea:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

/* Output Area */
.code-executor-output {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 8px;
    padding: 1rem;
    height: 300px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.code-executor-output pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.output-placeholder {
    color: #64748b;
    font-style: italic;
}

.output-loading {
    color: #60a5fa;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.output-success {
    color: #4ade80;
}

.output-error {
    color: #f87171;
}

.output-empty {
    color: #94a3b8;
    font-style: italic;
}

/* Footer */
.code-executor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(15, 23, 42, 0.6);
    border-top: 1px solid rgba(71, 85, 105, 0.3);
}

.code-executor-info {
    color: #64748b;
    font-size: 0.8rem;
}

.code-executor-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-run-code {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-run-code:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-run-code:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-close-modal {
    background: rgba(71, 85, 105, 0.3);
    color: #94a3b8;
    border: 1px solid rgba(71, 85, 105, 0.5);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-close-modal:hover {
    background: rgba(71, 85, 105, 0.5);
    color: #e2e8f0;
}

/* HTML Preview Modal Specific */
.html-preview-modal .code-executor-content {
    max-width: 1200px;
}

.html-preview-body {
    grid-template-columns: 1fr 1fr;
}

.html-preview-frame {
    width: 100%;
    height: 350px;
    background: white;
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 8px;
}

/* Scrollbar Styles */
.code-executor-output::-webkit-scrollbar,
.code-executor-textarea::-webkit-scrollbar {
    width: 8px;
}

.code-executor-output::-webkit-scrollbar-track,
.code-executor-textarea::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.5);
    border-radius: 4px;
}

.code-executor-output::-webkit-scrollbar-thumb,
.code-executor-textarea::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.4);
    border-radius: 4px;
}

.code-executor-output::-webkit-scrollbar-thumb:hover,
.code-executor-textarea::-webkit-scrollbar-thumb:hover {
    background: rgba(96, 165, 250, 0.6);
}

/* Try it Yourself Button (in topic pages) */
.btn-try-js-code {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.btn-try-js-code:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-try-html-code {
    background: linear-gradient(135deg, #e34c26 0%, #c73e1d 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.btn-try-html-code:hover {
    background: linear-gradient(135deg, #c73e1d 0%, #a33518 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(227, 76, 38, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .code-executor-modal {
        padding: 10px;
    }
    
    .code-executor-body {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .code-executor-textarea,
    .code-executor-output,
    .html-preview-frame {
        height: 200px;
    }
    
    .code-executor-footer {
        flex-direction: column;
        gap: 1rem;
    }
    
    .code-executor-info {
        text-align: center;
    }
    
    .code-executor-actions {
        width: 100%;
        justify-content: center;
    }
    
    .html-preview-body {
        grid-template-columns: 1fr;
    }
}

/* Spinning animation */
@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fa-spin {
    animation: fa-spin 1s linear infinite;
}
