/**
 * Common Editor Styles
 * Shared CSS classes and styles for all editors
 */

/* Common Editor Container */
.editor-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
}

/* Common Editor Section */
.editor-section {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.editor-section:hover {
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    border-color: var(--primary-color);
}

/* Common Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-header h2 i {
    color: var(--primary-color);
    font-size: 1.25rem;
}

/* Common Editor Controls */
.editor-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.editor-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.editor-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.editor-btn:active {
    transform: translateY(0);
}

.editor-btn.run-btn {
    background: linear-gradient(135deg, var(--primary-color), #4a6bff);
}

.editor-btn.run-btn:hover {
    background: linear-gradient(135deg, #4a6bff, var(--primary-color));
}

.editor-btn.run-btn.running {
    background: linear-gradient(135deg, #ffa726, #ff7043);
    cursor: not-allowed;
}

.editor-btn.run-btn.running i {
    animation: spin 1s linear infinite;
}

.editor-btn.clear-btn {
    background: linear-gradient(135deg, #f44336, #e57373);
}

.editor-btn.clear-btn:hover {
    background: linear-gradient(135deg, #e57373, #f44336);
}

.editor-btn.validate-btn {
    background: linear-gradient(135deg, #4caf50, #66bb6a);
}

.editor-btn.validate-btn:hover {
    background: linear-gradient(135deg, #66bb6a, #4caf50);
}

/* Common Code Editor Container */
.code-editor-container {
    position: relative;
    display: flex;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: #1e1e1e;
    min-height: 400px;
}

.code-editor-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 107, 255, 0.1);
}

/* Common Line Numbers */
.line-numbers {
    background: #2d2d2d;
    color: #858585;
    padding: 1rem 0.75rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    min-width: 60px;
    text-align: right;
    border-right: 1px solid #404040;
    user-select: none;
    overflow: hidden;
}

.line-number {
    height: 1.5em;
    white-space: nowrap;
}

/* Common Editor Textarea */
.code-editor-container textarea {
    flex: 1;
    background: #1e1e1e;
    color: #d4d4d4;
    border: none;
    outline: none;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    tab-size: 4;
    white-space: nowrap;
    overflow-wrap: normal;
    word-wrap: normal;
}

.code-editor-container textarea::placeholder {
    color: #666;
}

/* Common Output Section */
.output-section,
.preview-section {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    min-height: 200px;
}

.output-container,
.preview-container {
    background: #f8f9fa;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    min-height: 300px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Common Status Messages */
.loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 2px solid #2196f3;
    border-radius: 12px;
    color: #1976d2;
    font-weight: 600;
}

.loading i {
    font-size: 1.1rem;
}

.success {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #e8f5e8, #c8e6c9);
    border: 2px solid #4caf50;
    border-radius: 12px;
    color: #2e7d32;
    font-weight: 600;
    margin-bottom: 1rem;
}

.success i {
    font-size: 1.1rem;
}

.error {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    border: 2px solid #f44336;
    border-radius: 12px;
    color: #c62828;
    font-weight: 600;
    margin-bottom: 1rem;
}

.error i {
    font-size: 1.1rem;
}

.warning {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border: 2px solid #ff9800;
    border-radius: 12px;
    color: #ef6c00;
    font-weight: 600;
    margin-bottom: 1rem;
}

.warning i {
    font-size: 1.1rem;
}

/* Common Info Display */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.info-item {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.info-item h4 {
    color: var(--secondary-color);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item .value {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 800;
}

/* Common Data Preview */
.data-preview {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre;
    max-height: 400px;
    overflow-y: auto;
}

/* Common Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.refreshing {
    animation: spin 1s linear infinite;
}

/* Enhanced Mobile-First Responsive Design */
@media (max-width: 1200px) {
    .editor-container {
        max-width: 100%;
        padding: 1.5rem;
        gap: 1.5rem;
    }
}

@media (max-width: 1024px) {
    .editor-container {
        padding: 1rem;
        gap: 1rem;
        height: calc(100vh - 120px);
    }
    
    .editor-section,
    .output-section,
    .preview-section {
        padding: 1.5rem;
        border-radius: 12px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    .section-header h2 {
        font-size: 1.3rem;
    }
    
    .editor-controls {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    
    .code-editor-container {
        min-height: 350px;
        border-radius: 8px;
    }
}

@media (max-width: 768px) {
    .editor-container {
        padding: 0.75rem;
        height: auto;
        min-height: calc(100vh - 80px);
        gap: 1rem;
    }
    
    .editor-section,
    .output-section,
    .preview-section {
        padding: 1rem;
        margin-bottom: 0;
    }
    
    .section-header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
    }
    
    .section-header h2 {
        font-size: 1.2rem;
    }
    
    .editor-controls {
        gap: 0.5rem;
    }
    
    .editor-btn {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
        flex: 1;
        min-width: 120px;
        max-width: 150px;
    }
    
    .code-editor-container {
        min-height: 320px;
        border-radius: 8px;
    }
    
    .line-numbers {
        min-width: 50px;
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .code-editor-container textarea {
        padding: 0.75rem;
        font-size: 0.85rem;
        line-height: 1.4;
    }
    
    .output-container,
    .preview-container {
        min-height: 250px;
        padding: 0.75rem;
        font-size: 0.85rem;
        border-radius: 8px;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .info-item {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .editor-container {
        padding: 0.5rem;
        gap: 0.75rem;
    }
    
    .editor-section,
    .output-section,
    .preview-section {
        padding: 0.75rem;
        border-radius: 8px;
    }
    
    .section-header h2 {
        font-size: 1.1rem;
    }
    
    .section-header h2 i {
        font-size: 1rem;
    }
    
    .editor-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .editor-btn {
        width: 100%;
        max-width: none;
        padding: 0.8rem;
        font-size: 0.9rem;
        justify-content: center;
    }
    
    .code-editor-container {
        min-height: 280px;
    }
    
    .line-numbers {
        min-width: 45px;
        padding: 0.5rem 0.3rem;
        font-size: 0.75rem;
    }
    
    .code-editor-container textarea {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .output-container,
    .preview-container {
        min-height: 200px;
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .info-item {
        padding: 0.5rem;
    }
    
    .info-item .value {
        font-size: 1.1rem;
    }
}

/* Touch-Friendly Improvements */
@media (hover: none) and (pointer: coarse) {
    .editor-btn {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .action-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .code-editor-container textarea {
        touch-action: manipulation;
    }
    
    /* Increase touch target sizes */
    .mobile-item {
        min-height: 60px;
        padding: 1rem;
    }
}

/* Dark Theme Support */
[data-theme="dark"] .editor-section,
[data-theme="dark"] .output-section,
[data-theme="dark"] .preview-section {
    background: var(--charcoal);
    border-color: var(--dark-gray);
    color: var(--midnight);
}

[data-theme="dark"] .section-header {
    border-color: var(--dark-gray);
}

[data-theme="dark"] .section-header h2 {
    color: var(--midnight);
}

[data-theme="dark"] .output-container,
[data-theme="dark"] .preview-container {
    background: var(--off-white);
    border-color: var(--dark-gray);
    color: var(--midnight);
}

[data-theme="dark"] .info-item {
    background: var(--off-white);
    border-color: var(--dark-gray);
}
