/**
 * WebSchoolSun Code Visualizer - WordPress Integration Styles
 * Version: 1.0.0
 */

:root {
    --wscv-primary-600: #3b82f6;
    --wscv-primary-700: #1d4ed8;
    --wscv-primary-800: #1e40af;
    --wscv-secondary-500: #10b981;
    --wscv-secondary-600: #059669;
    --wscv-danger-500: #ef4444;
    --wscv-warning-500: #f59e0b;
    --wscv-gray-50: #f9fafb;
    --wscv-gray-100: #f3f4f6;
    --wscv-gray-200: #e5e7eb;
    --wscv-gray-300: #d1d5db;
    --wscv-gray-400: #9ca3af;
    --wscv-gray-500: #6b7280;
    --wscv-gray-600: #4b5563;
    --wscv-gray-700: #374151;
    --wscv-gray-800: #1f2937;
    --wscv-gray-900: #111827;
    
    --wscv-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --wscv-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --wscv-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --wscv-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --wscv-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --wscv-font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --wscv-font-mono: 'JetBrains Mono', 'Fira Code', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}

/* Container Styles */
.wscv-container {
    font-family: var(--wscv-font-sans);
    background: linear-gradient(135deg, var(--wscv-gray-50) 0%, #ffffff 100%);
    color: var(--wscv-gray-800);
    line-height: 1.6;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--wscv-shadow-xl);
    margin: 2rem 0;
}

.wscv-container * {
    box-sizing: border-box;
}

/* Header Styles */
.wscv-header {
    text-align: center;
    padding: 2rem 2rem 1rem;
    position: relative;
}

.wscv-header::before {
    content: '';
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--wscv-primary-600)20, transparent 70%);
    border-radius: 50%;
    z-index: -1;
    animation: wscv-pulse 3s ease-in-out infinite;
}

@keyframes wscv-pulse {
    0%, 100% { 
        transform: translateX(-50%) scale(1); 
        opacity: 0.3; 
    }
    50% { 
        transform: translateX(-50%) scale(1.1); 
        opacity: 0.5; 
    }
}

.wscv-logo {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--wscv-primary-600), var(--wscv-secondary-500));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.wscv-subtitle {
    color: var(--wscv-gray-600);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

/* Layout */
.wscv-main-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    padding: 0 2rem 2rem;
    min-height: 500px;
}

.wscv-editor-section,
.wscv-visualizer-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--wscv-shadow-md);
    border: 1px solid var(--wscv-gray-200);
    display: flex;
    flex-direction: column;
    position: relative;
}

.wscv-editor-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--wscv-primary-600), var(--wscv-secondary-500), var(--wscv-warning-500));
    background-size: 200% 100%;
    animation: wscv-shimmer 3s ease-in-out infinite;
}

@keyframes wscv-shimmer {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
}

/* Section Titles */
.wscv-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--wscv-gray-800);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wscv-section-icon,
.wscv-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--wscv-primary-600), var(--wscv-secondary-500));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
}

/* Language Selector */
.wscv-language-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--wscv-gray-100);
    padding: 0.25rem;
    border-radius: 10px;
    overflow-x: auto;
}

.wscv-language-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--wscv-gray-600);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--wscv-font-sans);
    white-space: nowrap;
    flex-shrink: 0;
}

.wscv-language-tab.active {
    background: white;
    color: var(--wscv-primary-600);
    box-shadow: var(--wscv-shadow-sm);
}

.wscv-language-tab:hover:not(.active) {
    color: var(--wscv-gray-800);
    background: rgba(255, 255, 255, 0.5);
}

/* Code Editor */
.wscv-code-editor {
    flex: 1;
    font-family: var(--wscv-font-mono);
    font-size: 14px;
    line-height: 1.6;
    border: 2px solid var(--wscv-gray-200);
    border-radius: 12px;
    padding: 1rem;
    background: var(--wscv-gray-50);
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    min-height: 300px;
    width: 100%;
}

.wscv-code-editor:focus {
    border-color: var(--wscv-primary-600);
    background: white;
    box-shadow: 0 0 0 4px rgb(59 130 246 / 0.1);
}

/* Controls */
.wscv-controls {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.wscv-btn {
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: 10px;
    font-family: var(--wscv-font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    outline: none;
}

.wscv-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s;
}

.wscv-btn:hover::before {
    left: 100%;
}

.wscv-btn-primary {
    background: linear-gradient(135deg, var(--wscv-primary-600), var(--wscv-primary-700));
    color: white;
}

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

.wscv-btn-secondary {
    background: var(--wscv-gray-100);
    color: var(--wscv-gray-700);
    border: 1px solid var(--wscv-gray-300);
}

.wscv-btn-secondary:hover {
    background: var(--wscv-gray-200);
    transform: translateY(-1px);
}

.wscv-btn-success {
    background: linear-gradient(135deg, var(--wscv-secondary-500), var(--wscv-secondary-600));
    color: white;
}

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

.wscv-btn-warning {
    background: linear-gradient(135deg, var(--wscv-warning-500), #ea580c);
    color: white;
}

.wscv-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Progress Bar */
.wscv-progress-bar {
    background: var(--wscv-gray-200);
    height: 6px;
    border-radius: 3px;
    margin: 1rem 0;
    overflow: hidden;
}

.wscv-progress-fill {
    background: linear-gradient(90deg, var(--wscv-primary-600), var(--wscv-secondary-500));
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    position: relative;
    width: 0%;
}

.wscv-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: wscv-shimmer 2s ease-in-out infinite;
}

/* Status */
.wscv-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 1rem;
}

.wscv-status.wscv-ready {
    background: var(--wscv-gray-100);
    color: var(--wscv-gray-700);
}

.wscv-status.wscv-running {
    background: linear-gradient(135deg, var(--wscv-warning-500)20, var(--wscv-warning-500)30);
    color: var(--wscv-warning-500);
}

.wscv-status.wscv-completed {
    background: linear-gradient(135deg, var(--wscv-secondary-500)20, var(--wscv-secondary-500)30);
    color: var(--wscv-secondary-600);
}

.wscv-status.wscv-error {
    background: linear-gradient(135deg, var(--wscv-danger-500)20, var(--wscv-danger-500)30);
    color: var(--wscv-danger-500);
}

.wscv-loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: wscv-spin 1s linear infinite;
}

@keyframes wscv-spin {
    to { transform: rotate(360deg); }
}

/* Output */
.wscv-output {
    background: var(--wscv-gray-900);
    color: var(--wscv-gray-100);
    font-family: var(--wscv-font-mono);
    padding: 1rem;
    border-radius: 12px;
    margin-top: 1rem;
    min-height: 120px;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Execution Steps */
.wscv-execution-steps {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.wscv-step {
    background: var(--wscv-gray-50);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--wscv-gray-300);
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateX(20px);
    animation: wscv-slideIn 0.5s ease-forwards;
}

.wscv-step.wscv-current {
    border-left-color: var(--wscv-primary-600);
    background: linear-gradient(135deg, var(--wscv-primary-600)05, var(--wscv-primary-600)10);
    transform: scale(1.02);
}

.wscv-step.wscv-executed {
    border-left-color: var(--wscv-secondary-500);
    background: linear-gradient(135deg, var(--wscv-secondary-500)05, var(--wscv-secondary-500)10);
}

@keyframes wscv-slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.wscv-step-number {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--wscv-primary-600);
    margin-bottom: 0.5rem;
}

.wscv-step-code {
    font-family: var(--wscv-font-mono);
    font-size: 0.9rem;
    background: white;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--wscv-gray-200);
    word-break: break-all;
}

/* Variables */
.wscv-variables {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
}

.wscv-variable {
    background: white;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--wscv-gray-200);
    font-family: var(--wscv-font-mono);
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    word-break: break-all;
}

.wscv-variable.wscv-changed {
    border-color: var(--wscv-warning-500);
    background: linear-gradient(135deg, var(--wscv-warning-500)10, var(--wscv-warning-500)20);
    animation: wscv-glow 0.6s ease-in-out;
}

@keyframes wscv-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgb(245 158 11 / 0.4); }
    50% { box-shadow: 0 0 0 4px rgb(245 158 11 / 0.4); }
}

.wscv-variable-name {
    color: var(--wscv-gray-700);
    font-weight: 600;
    margin-right: 0.5rem;
}

.wscv-variable-value {
    color: var(--wscv-primary-600);
    font-weight: 500;
    text-align: right;
}

/* Widget Title */
.wscv-widget-title {
    margin-bottom: 1rem;
}

.wscv-widget-title h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--wscv-gray-800);
}

/* Tooltips */
.wscv-help-tooltip {
    position: relative;
    cursor: help;
}

.wscv-help-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--wscv-gray-900);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.wscv-help-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .wscv-main-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem 1rem;
    }
    
    .wscv-header {
        padding: 1rem 1rem 0.5rem;
    }
    
    .wscv-logo {
        font-size: 1.5rem;
    }
    
    .wscv-subtitle {
        font-size: 0.9rem;
    }
    
    .wscv-controls {
        flex-direction: column;
    }
    
    .wscv-btn {
        width: 100%;
        justify-content: center;
    }
    
    .wscv-language-selector {
        overflow-x: scroll;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .wscv-language-selector::-webkit-scrollbar {
        display: none;
    }
    
    .wscv-variables {
        grid-template-columns: 1fr;
    }
    
    .wscv-code-editor {
        min-height: 250px;
        font-size: 13px;
    }
    
    .wscv-step-code {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .wscv-container {
        margin: 1rem 0;
    }
    
    .wscv-header {
        padding: 0.75rem 0.75rem 0.25rem;
    }
    
    .wscv-main-layout {
        padding: 0 0.75rem 0.75rem;
    }
    
    .wscv-editor-section,
    .wscv-visualizer-section {
        padding: 1rem;
    }
    
    .wscv-section-title {
        font-size: 1.1rem;
    }
    
    .wscv-btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
}

/* WordPress Theme Compatibility */
.wscv-container .wp-block,
.wscv-container .wp-element,
.wscv-container p,
.wscv-container h1,
.wscv-container h2,
.wscv-container h3,
.wscv-container h4,
.wscv-container h5,
.wscv-container h6 {
    margin: 0;
    padding: 0;
}

.wscv-container a {
    color: inherit;
    text-decoration: none;
}

.wscv-container button:focus,
.wscv-container input:focus,
.wscv-container textarea:focus {
    outline-color: var(--wscv-primary-600);
}

/* LearnDash Integration */
.learndash-wrapper .wscv-container {
    margin-top: 2rem;
    border: 1px solid var(--wscv-gray-200);
}

.single-sfwd-lessons .wscv-container,
.single-sfwd-topic .wscv-container,
.single-sfwd-quiz .wscv-container {
    background: white;
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--wscv-shadow);
}

/* Elementor Integration */
.elementor-widget-webschoolsun_code_visualizer .wscv-container {
    margin: 0;
}

.elementor-widget-webschoolsun_code_visualizer .wscv-widget-title {
    text-align: center;
    padding: 1rem 0;
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    :root {
        --wscv-gray-50: #18181b;
        --wscv-gray-100: #27272a;
        --wscv-gray-200: #3f3f46;
        --wscv-gray-300: #52525b;
        --wscv-gray-400: #71717a;
        --wscv-gray-500: #a1a1aa;
        --wscv-gray-600: #d4d4d8;
        --wscv-gray-700: #e4e4e7;
        --wscv-gray-800: #f4f4f5;
        --wscv-gray-900: #fafafa;
    }
    
    .wscv-container {
        background: linear-gradient(135deg, var(--wscv-gray-100) 0%, var(--wscv-gray-50) 100%);
    }
    
    .wscv-code-editor {
        background: var(--wscv-gray-100);
        color: var(--wscv-gray-800);
        border-color: var(--wscv-gray-300);
    }
    
    .wscv-code-editor:focus {
        background: var(--wscv-gray-50);
    }
}

/* Print Styles */
@media print {
    .wscv-container {
        box-shadow: none;
        border: 2px solid var(--wscv-gray-300);
    }
    
    .wscv-controls,
    .wscv-progress-bar {
        display: none;
    }
    
    .wscv-main-layout {
        grid-template-columns: 1fr;
    }
    
    .wscv-code-editor {
        border: 2px solid var(--wscv-gray-300);
        background: white;
        min-height: 200px;
    }
}