/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: #f5f5f5;
    border-bottom: 1px solid #ccc;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    font-size: 1.5em;
    font-weight: normal;
}

.header-link {
    color: #333;
    text-decoration: none;
    font-size: 14px;
    padding: 5px 10px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 3px;
}

.header-link:hover {
    background: #f0f0f0;
}

/* Split Container */
.split-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 51px); /* Account for header height */
}

/* Left Panel - Problem Display */
.left-panel {
    width: 40%;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ccc;
    overflow: hidden;
}

.problem-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    line-height: 1.6;
}

.problem-content h2 {
    margin-top: 0;
    margin-bottom: 10px;
}

.problem-content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.problem-content p {
    margin-bottom: 10px;
}

.problem-content pre {
    background: #f5f5f5;
    padding: 10px;
    border: 1px solid #ddd;
    overflow-x: auto;
    margin: 10px 0;
}

.problem-content code {
    background: #f5f5f5;
    padding: 2px 5px;
    font-family: monospace;
}

.problem-content ul {
    margin-left: 20px;
    margin-bottom: 10px;
}

.problem-content li {
    margin-bottom: 5px;
}

.difficulty {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: bold;
    margin-left: 10px;
}

.difficulty.easy {
    background: #d4edda;
    color: #155724;
}

.difficulty.medium {
    background: #fff3cd;
    color: #856404;
}

.difficulty.hard {
    background: #f8d7da;
    color: #721c24;
}

.example-box {
    background: #f9f9f9;
    border-left: 3px solid #666;
    padding: 10px;
    margin: 10px 0;
}

/* Draggable Divider */
.divider {
    width: 5px;
    background: #e0e0e0;
    cursor: col-resize;
    flex-shrink: 0;
}

.divider:hover {
    background: #bbb;
}

.divider.dragging {
    background: #999;
}

/* Right Panel - Editor and Console */
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 300px;
}

/* Controls */
.controls {
    padding: 10px 15px;
    background: #f9f9f9;
    border-bottom: 1px solid #ccc;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    font-size: 14px;
    border: 1px solid #999;
    background: white;
    cursor: pointer;
}

.btn:hover {
    background: #f0f0f0;
}

.btn:active {
    background: #e0e0e0;
}

.btn-run {
    font-weight: bold;
}

#status-message {
    color: #666;
    font-style: italic;
    font-size: 13px;
}

/* Editor Container */
.editor-container {
    flex: 1;
    overflow: hidden;
    border-bottom: 1px solid #d0d0d0;
}

.CodeMirror {
    height: 100%;
    font-size: 14px;
    border: 1px solid #d0d0d0 !important;
}

/* Output Container */
.output-container {
    height: 200px;
    display: flex;
    flex-direction: column;
    background: white;
}

.output-header {
    padding: 8px 15px;
    background: #f5f5f5;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
    font-size: 13px;
}

.output-console {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-family: monospace;
    font-size: 13px;
    background: #fafafa;
}

.output-info {
    color: #666;
}

.output-success {
    color: #155724;
    background: #d4edda;
    padding: 5px 10px;
    margin: 3px 0;
    border-left: 3px solid #28a745;
}

.output-error {
    color: #721c24;
    background: #f8d7da;
    padding: 5px 10px;
    margin: 3px 0;
    border-left: 3px solid #dc3545;
}

.output-result {
    color: #004085;
    background: #d1ecf1;
    padding: 5px 10px;
    margin: 3px 0;
    border-left: 3px solid #17a2b8;
}

/* Mobile Tabs - Hidden on Desktop */
.mobile-tabs {
    display: none;
    background: #f5f5f5;
    border-bottom: 2px solid #ccc;
}

.mobile-tab {
    flex: 1;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    background: #f5f5f5;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.mobile-tab:active {
    background: #e8e8e8;
}

.mobile-tab.active {
    color: #333;
    background: white;
    border-bottom-color: #4e4e4e;
    font-weight: bold;
}

/* Mobile Layout - Activated on smaller screens */
@media screen and (max-width: 768px) {
    /* Show mobile tabs */
    .mobile-tabs {
        display: flex;
    }
    
    .header {
        padding: 8px 15px;
    }
    
    .header h1 {
        font-size: 1.2em;
    }
    
    .header-link {
        font-size: 12px;
        padding: 4px 8px;
    }

    .problem-status {
        display: none;
    }
    
    /* Split container becomes single-panel on mobile */
    .split-container {
        position: relative;
        height: calc(100vh - 51px - 48px); /* Account for header and tabs */
    }
    
    /* Hide divider on mobile */
    .divider {
        display: none;
    }
    
    /* Panels stack and only one shows at a time */
    .left-panel,
    .right-panel {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        min-width: 0;
        display: none;
        border: none;
    }
    
    .panel-content.active {
        display: flex;
    }
    
    /* Adjust controls for mobile */
    .controls {
        padding: 8px 10px;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    #status-message {
        font-size: 12px;
        width: 100%;
    }
    
    /* Problem content adjustments */
    .problem-content {
        padding: 15px;
        font-size: 14px;
    }
    
    .problem-content h2 {
        font-size: 1.3em;
    }
    
    .problem-content h3 {
        font-size: 1.1em;
    }
    
    .problem-content pre {
        font-size: 12px;
        padding: 8px;
    }
    
    /* CodeMirror adjustments for mobile */
    .CodeMirror {
        font-size: 13px;
    }
    
    /* Output container takes less space on mobile */
    .output-container {
        height: 150px;
    }
    
    .output-console {
        font-size: 12px;
        padding: 8px;
    }
}

/* Very small screens (portrait phones) */
@media screen and (max-width: 480px) {
    .header h1 {
        font-size: 1em;
    }
    
    .problem-content {
        padding: 10px;
        font-size: 13px;
    }
    
    .controls {
        padding: 6px 8px;
    }
    
    .btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .CodeMirror {
        font-size: 12px;
    }
    
    .output-container {
        height: 120px;
    }
}

