/**
 * Multi-Language Code Viewer Styles
 */

.multilang-code-viewer {
    margin: 2rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Language Switcher */
.language-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.lang-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.lang-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.lang-button.active {
    background: rgba(255, 255, 255, 0.95);
    color: #667eea;
    border-color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.lang-button .flag {
    font-size: 1.25rem;
    line-height: 1;
}

.lang-button .name {
    white-space: nowrap;
}

/* Responsive: Hide language names on small screens */
@media (max-width: 640px) {
    .lang-button .name {
        display: none;
    }
    
    .lang-button {
        padding: 0.5rem;
    }
}

/* Code Container */
.code-container {
    background: #1e1e1e;
    color: #d4d4d4;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e3e;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.language-selector {
    padding: 0.375rem 0.75rem;
    background: #3e3e3e;
    border: 1px solid #4e4e4e;
    border-radius: 0.25rem;
    color: #e0e0e0;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
}

.language-selector:hover {
    background: #4e4e4e;
    border-color: #5e5e5e;
}

.language-selector:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.language-selector option {
    background: #2d2d2d;
    color: #e0e0e0;
    padding: 0.5rem;
}

.current-language {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #e0e0e0;
}

.current-language .flag {
    font-size: 1.25rem;
}

.copy-button {
    padding: 0.375rem 0.75rem;
    background: #3e3e3e;
    border: 1px solid #4e4e4e;
    border-radius: 0.25rem;
    color: #e0e0e0;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button:hover {
    background: #4e4e4e;
    border-color: #5e5e5e;
}

.copy-button:active {
    transform: scale(0.95);
}

.code-content {
    margin: 0;
    padding: 1.5rem;
    overflow-x: auto;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    background: #1e1e1e;
}

.code-content code {
    display: block;
    color: #d4d4d4;
}

/* RTL Support */
.code-content[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* Syntax Highlighting (basic) */
.code-content .keyword {
    color: #569cd6;
    font-weight: 600;
}

.code-content .string {
    color: #ce9178;
}

.code-content .comment {
    color: #6a9955;
    font-style: italic;
}

.code-content .number {
    color: #b5cea8;
}

.code-content .function {
    color: #dcdcaa;
}

.code-content .operator {
    color: #d4d4d4;
}

/* Loading State */
.code-content.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #808080;
}

.code-content.loading::before {
    content: "⏳ Loading...";
    font-size: 1rem;
}

/* Error State */
.code-content.error {
    color: #f48771;
}

/* Scrollbar Styling */
.code-content::-webkit-scrollbar {
    height: 8px;
}

.code-content::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.code-content::-webkit-scrollbar-thumb {
    background: #4e4e4e;
    border-radius: 4px;
}

.code-content::-webkit-scrollbar-thumb:hover {
    background: #5e5e5e;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.multilang-code-viewer {
    animation: fadeIn 0.3s ease-out;
}

/* Print Styles */
@media print {
    .language-switcher,
    .copy-button,
    .code-actions {
        display: none;
    }
    
    .code-container {
        border: 1px solid #ccc;
    }
}

/* Code Actions (Check, Compile, Run buttons) */
.code-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #2d2d2d;
    border-top: 1px solid #3e3e3e;
    justify-content: flex-end;
}

.action-button {
    padding: 0.5rem 1rem;
    background: #3e3e3e;
    border: 1px solid #4e4e4e;
    border-radius: 0.25rem;
    color: #e0e0e0;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.action-button:hover:not(:disabled) {
    background: #4e4e4e;
    border-color: #5e5e5e;
    transform: translateY(-1px);
}

.action-button:active:not(:disabled) {
    transform: translateY(0);
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-button.loading {
    position: relative;
}

.action-button.loading::after {
    content: '';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid #e0e0e0;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

.check-button:hover:not(:disabled) {
    background: #2d5016;
    border-color: #3d6026;
}

.compile-button:hover:not(:disabled) {
    background: #4a3a1a;
    border-color: #5a4a2a;
}

.run-button:hover:not(:disabled) {
    background: #1a3a5a;
    border-color: #2a4a6a;
}

/* Code Output */
.code-output {
    background: #1e1e1e;
    border-top: 2px solid #3e3e3e;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e3e;
}

.output-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #e0e0e0;
}

.close-output {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: none;
    color: #808080;
    font-size: 1rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-output:hover {
    color: #e0e0e0;
}

.output-content {
    padding: 1rem;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #d4d4d4;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.output-content.loading {
    color: #808080;
    font-style: italic;
}

.output-content.success {
    color: #4ec9b0;
}

.output-content.error {
    color: #f48771;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .code-actions {
        flex-wrap: wrap;
    }
    
    .action-button {
        flex: 1;
        min-width: 80px;
        justify-content: center;
    }
}


/* Line Numbers */
.code-content-with-lines {
    display: flex;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    background: #1e1e1e;
}

.line-numbers {
    padding: 1.5rem 0;
    padding-right: 1rem;
    padding-left: 1.5rem;
    background: #252526;
    color: #858585;
    text-align: right;
    user-select: none;
    border-right: 1px solid #3e3e3e;
    min-width: 3.5rem;
}

.line-numbers span {
    display: block;
    line-height: 1.6;
}

.code-lines {
    flex: 1;
    padding: 1.5rem;
    overflow-x: auto;
}

.code-lines code {
    display: block;
    color: #d4d4d4;
}

/* Error Line Highlighting */
.error-line-highlight {
    background-color: rgba(255, 0, 0, 0.2) !important;
    border-left: 3px solid #ff4444 !important;
    padding-left: 0.5rem !important;
    font-weight: bold !important;
    color: #ff6b6b !important;
}

.code-lines.has-error {
    position: relative;
}

.code-lines.has-error::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #ff4444;
    opacity: 0.5;
}


/* ============================================================================
   Project Explorer Styles
   ============================================================================ */

.tree-view {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    line-height: 1.8;
}

.tree-folder {
    display: block;
    margin-bottom: 2px;
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 2px 0;
    transition: background-color 0.2s;
}

.tree-item:hover {
    background-color: rgba(139, 92, 246, 0.05);
    border-radius: 4px;
}

.tree-item.folder {
    cursor: pointer;
}

.tree-item.folder:hover {
    background-color: rgba(139, 92, 246, 0.1);
}

.tree-icon {
    margin-right: 8px;
    font-size: 16px;
    user-select: none;
}

.tree-label {
    user-select: none;
}

.tree-children {
    margin-top: 4px;
    margin-bottom: 4px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
}

.tree-item.file .tree-label {
    transition: all 0.2s;
}

.tree-item.file:hover .tree-label {
    text-decoration: underline;
    transform: translateX(2px);
}

/* File Viewer Modal */
#file-viewer-modal pre {
    margin: 0;
}

#file-viewer-modal code {
    display: block;
    white-space: pre;
    overflow-x: auto;
}

/* Make Package Button Animation */
button[onclick="makePackage()"] {
    position: relative;
    overflow: hidden;
}

button[onclick="makePackage()"]:hover {
    transform: translateY(-2px);
}

button[onclick="makePackage()"]:active {
    transform: translateY(0);
}

button[onclick="makePackage()"]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button[onclick="makePackage()"]:active::before {
    width: 300px;
    height: 300px;
}
.hidden { display: none !important; }

.tree-children.visible { display: block !important; visibility: visible !important; opacity: 1 !important; }
.tree-children.hidden { display: none !important; }

/* Progress bar width controlled by data-width attribute */
#test-progress-bar {
    width: attr(data-width percentage, 0%);
}

/* Data-width attribute support for progress bars */
[data-width] {
    width: calc(attr(data-width) * 1%);
}
