* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1e1e1e;
    color: #cccccc;
    height: 100vh;
    overflow: hidden;
}

.ide-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-bar {
    background: #323233;
    border-bottom: 1px solid #1e1e1e;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    font-weight: 600;
    font-size: 14px;
    color: #3794ff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.run-controls {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.btn {
    background: #0e639c;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.btn:hover {
    background: #1177bb;
}

.btn:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background: #3c3c3c;
}

.btn-secondary:hover {
    background: #4c4c4c;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    background: #252526;
    border-right: 1px solid #1e1e1e;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 12px 16px;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    color: #cccccc;
    background: #2d2d30;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.new-file-btn {
    background: none;
    border: none;
    color: #cccccc;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 16px;
}

.new-file-btn:hover {
    background: #3e3e42;
}

.file-list {
    flex: 1;
    overflow-y: auto;
}

.file-item {
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    border-left: 2px solid transparent;
    transition: background 0.2s;
}

.file-item:hover {
    background: #2a2d2e;
}

.file-item.active {
    background: #1e1e1e;
    border-left-color: #3794ff;
}

.file-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-delete {
    opacity: 0;
    background: none;
    border: none;
    color: #cccccc;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 14px;
}

.file-item:hover .file-delete {
    opacity: 1;
}

.file-delete:hover {
    background: #f14c4c;
    color: white;
}

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
}

.tabs-bar {
    background: #2d2d30;
    display: flex;
    align-items: flex-end;
    border-bottom: 1px solid #1e1e1e;
    overflow-x: auto;
}

.tab {
    padding: 8px 16px;
    background: #2d2d30;
    border-right: 1px solid #1e1e1e;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    transition: background 0.2s;
}

.tab:hover {
    background: #323233;
}

.tab.active {
    background: #1e1e1e;
    border-top: 1px solid #3794ff;
}

.tab-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-close {
    opacity: 0;
    background: none;
    border: none;
    color: #cccccc;
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    font-size: 16px;
    line-height: 1;
}

.tab:hover .tab-close {
    opacity: 1;
}

.tab-close:hover {
    background: #f14c4c;
    color: white;
}

.editor-container {
    flex: 1;
    overflow: hidden;
}

.CodeMirror {
    height: 100% !important;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.output-panel {
    height: 300px;
    background: #1e1e1e;
    border-top: 1px solid #3c3c3c;
    display: flex;
    flex-direction: column;
}

.output-header {
    background: #2d2d30;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #1e1e1e;
}

.io-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.terminal-container {
    flex: 1;
    background: #1e1e1e;
    padding: 4px;
    overflow: hidden;
}

.xterm-viewport {
    overflow-y: auto !important;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #2d2d30;
    padding: 24px;
    border-radius: 6px;
    min-width: 400px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-input {
    width: 100%;
    padding: 8px 12px;
    background: #3c3c3c;
    border: 1px solid #555;
    color: #cccccc;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 16px;
}

.modal-input:focus {
    outline: none;
    border-color: #3794ff;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .2);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* AI Debug Button */
.btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
}

.btn-ai:hover {
    background: linear-gradient(135deg, #7c8ff0 0%, #8b5ab8 100%);
}

.quota-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.btn-success {
    background: #28a745;
}

.btn-success:hover {
    background: #218838;
}

/* Diff Modal */
.diff-modal {
    min-width: 80vw;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-close {
    background: none;
    border: none;
    color: #cccccc;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #f14c4c;
    color: white;
}

.diff-explanation {
    background: #3c3c3c;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    border-left: 3px solid #667eea;
    font-size: 13px;
    line-height: 1.5;
}

.diff-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 1;
    overflow: hidden;
    margin-bottom: 16px;
}

.diff-side {
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    border-radius: 4px;
    overflow: hidden;
}

.diff-header {
    background: #323233;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid #1e1e1e;
}

.diff-code {
    flex: 1;
    overflow: auto;
    padding: 12px;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Diff Highlighting */
.diff-line-add {
    background: rgba(40, 167, 69, 0.2);
    border-left: 3px solid #28a745;
    padding-left: 8px;
    display: block;
}

.diff-line-remove {
    background: rgba(220, 53, 69, 0.2);
    border-left: 3px solid #dc3545;
    padding-left: 8px;
    display: block;
    text-decoration: line-through;
}

.diff-line-context {
    display: block;
}