/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    min-height: 100vh;
}

/* Dark Theme Variables */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #555555;
    --accent-color: #0d6efd;
    --success-color: #198754;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    margin: 0;
    padding: 0.5rem;
    z-index: 1000;
    background: var(--bg-primary);
}

/* Header */
.header {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header h1 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header h1 i {
    color: var(--accent-color);
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Language Selector */
.language-selector {
    margin-right: 1rem;
}

.language-select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.language-select:hover {
    border-color: var(--accent-color);
    background: var(--bg-primary);
}

.language-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* Buttons */
.btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent-color);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-success {
    background: var(--success-color);
}

.btn-info {
    background: #17a2b8;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Editor Container */
.editor-container {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 0;
}

.editor-panel {
    flex: 1;
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

.output-panel {
    flex: 1;
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Language Modes */
.language-mode {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.language-mode.hidden {
    display: none;
}

/* Editor Sections */
.editor-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-section.single-editor {
    flex: 1;
}

.editor-section.minimized {
    flex: 0 0 auto;
}

.editor-section.minimized .editor {
    display: none;
}

.editor-header {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.editor-header span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.editor-controls {
    display: flex;
    gap: 0.5rem;
}

.minimize-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.minimize-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Editors */
.editor {
    width: 100%;
    flex: 1;
    min-height: 120px;
    border: none;
    outline: none;
    background: var(--bg-primary);
    color: var(--text-primary) !important;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    padding: 1rem;
    resize: none;
    tab-size: 2;
}

.editor.large-editor {
    min-height: 300px;
}

.editor::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.editor:focus {
    background: var(--bg-primary);
    color: var(--text-primary); 
}

/* Output Panel */
.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
}

.output-header span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.output-controls {
    display: flex;
    gap: 0.5rem;
}

.output-frame {
    flex: 1;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    min-height: 300px;
}

/* Console */
.console {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.console.hidden {
    display: none;
}

.console-header {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.console-output {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
}

.console-log {
    margin-bottom: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    word-wrap: break-word;
}

.console-log {
    color: var(--text-primary);
}

.console-error {
    background: rgba(220, 53, 69, 0.1);
    color: var(--error-color);
    border-left: 3px solid var(--error-color);
}

.console-warn {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
    border-left: 3px solid var(--warning-color);
}

.console-info {
    background: rgba(13, 110, 253, 0.1);
    color: var(--accent-color);
    border-left: 3px solid var(--accent-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    padding: 20px;
    overflow-y: auto;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin: auto;
    display: flex;
    flex-direction: column;
}

.modal.hidden {
    display: none;
}

.modal-header {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.project-name-input {
    width: 100%;
    padding: 0.75rem;
    margin: 0 auto;
    max-width: 300px;
    text-align: center;
}

@media (max-width: 600px) {
    .modal-content {
        max-width: 95%;
        max-height: 95vh;
    }
    
    .modal-body {
        padding: 1rem;
    }
}

.modal-body input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
}

.modal-body input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* Project list styles */
.saved-projects {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
    text-align: center;
}

.project-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem auto;
    max-width: 400px;
    text-align: left;
}

.project-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
}

.project-info {
    margin-bottom: 0.5rem;
}

.project-name {
    font-weight: 600;
    color: var(--text-primary);
}

.project-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.project-actions {
    display: flex;
    gap: 0.5rem;
}
.btn-load {
    background: var(--accent-color);
}

.btn-delete {
    background: var(--error-color);
}

/* Messages */
.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1001;
    animation: slideIn 0.3s ease;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.message.success {
    background: var(--success-color);
}

.message.error {
    background: var(--error-color);
}

.message.info {
    background: var(--accent-color);
}

.message.fade-out {
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .editor-container {
        flex-direction: column;
    }
    
    .editor-panel,
    .output-panel {
        flex: none;
        height: 50vh;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    .header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
        text-align: center;
    }
    
    .controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .language-selector {
        margin-right: 0;
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    .language-select {
        width: 100%;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
    
    .editor-container {
        gap: 0.5rem;
    }
    
    .editor-panel,
    .output-panel {
        padding: 0.75rem;
    }
    
    .editor {
        font-size: 13px;
    }
    
    .modal-content {
        width: 95%;
        margin: 0.5rem;
    }
}

@media (max-width: 480px) {
    .project-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .project-actions {
        justify-content: center;
    }
    
    .btn {
        flex: 1;
        justify-content: center;
    }
}

.language-mode {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.editor-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin-bottom: 10px;
    overflow: hidden;
}

.editor-section.single-editor {
    flex: 1;
}

.editor {
    flex: 1;
    resize: none;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #1e1e1e;
    color: #d4d4d4;
}

/* Fullscreen preview styles */
.editor-hidden .editor-panel {
    display: none;
}

.editor-hidden .output-panel {
    width: 100%;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background: #1e1e1e;
}

.editor-hidden .output-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1001;
}

.editor-hidden .output-header {
    display: none;
}

.editor-hidden .output-frame {
    height: 100%;
}

/* Responsive Mode Styles */
.responsive-mode {
    position: relative;
}

.responsive-mode .output-frame {
    background: white;
    border: 2px solid #555;
    border-radius: 12px;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    overflow: hidden;
    resize: both;
    min-width: 320px;
    min-height: 480px;
    max-width: 100%;
    max-height: 90vh;
}

.responsive-mode .device-frame {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.responsive-mode .device-buttons {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 11;
}

.responsive-mode .device-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: all;
}

/* Device presets */
.responsive-mode.mobile .output-frame {
    width: 375px;
    height: 667px;
}

.responsive-mode.tablet .output-frame {
    width: 768px;
    height: 1024px;
}

.responsive-mode.desktop .output-frame {
    width: 100%;
    height: 100%;
    resize: none;
}

/* Responsive indicators */
.device-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 11;
}

@media (max-width: 768px) {
    .responsive-mode .output-frame {
        width: 100% !important;
        height: 80vh !important;
        resize: none !important;
    }
    
    .responsive-mode-btn {
        display: none;
    }
}

.visibility-options {
    margin: 15px 0;
}

.radio-group {
    margin: 8px 0;
    display: flex;
    align-items: center;
}

.radio-group input[type="radio"] {
    margin-right: 8px;
}

.radio-group label {
    margin-bottom: 0;
    cursor: pointer;
}

/* Project List Styles */
.saved-projects {
    max-height: 400px;
    overflow-y: auto;
    margin: 15px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.saved-projects h4 {
    padding: 10px;
    margin: 0;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

#projectsList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#projectsList li {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#projectsList li:last-child {
    border-bottom: none;
}

#projectsList li:hover {
    background-color: #f9f9f9;
}

.project-info {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.project-name {
    font-weight: bold;
    margin-right: 10px;
}

.project-language {
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8em;
}

.project-date {
    color: #666;
    font-size: 0.9em;
}

.project-visibility {
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 3px;
}

.project-visibility i {
    margin-right: 3px;
}

.public-project .project-visibility {
    background: #e6f7ff;
    color: #1890ff;
}

.project-actions {
    display: flex;
    gap: 5px;
}

.loading-projects, .no-projects {
    padding: 20px;
    text-align: center;
    color: #666;
}

.loading-projects i, .no-projects i {
    margin-right: 5px;
}

/* Simple Login Popup Styles */
.code-tester-login-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.code-tester-login-popup .popup-content {
    background: white;
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    text-align: center;
}

.code-tester-login-popup h3 {
    margin-top: 0;
    color: #2c3e50;
}

.code-tester-login-popup p {
    margin-bottom: 20px;
    color: #7f8c8d;
}

.popup-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.popup-buttons a, 
.popup-buttons button {
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-size: 14px;
}

.popup-buttons .login-btn {
    background: #3498db;
    color: white;
}

.popup-buttons .register-btn {
    background: #2ecc71;
    color: white;
}

.popup-buttons .close-popup {
    background: #e0e0e0;
    color: #333;
}