/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Worksheet Selection Screen */
.worksheet-selection {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.worksheet-selection header {
    text-align: center;
    margin-bottom: 40px;
}

.worksheet-selection h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.worksheet-selection p {
    font-size: 1.2rem;
    color: #7f8c8d;
}

.worksheets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.worksheet-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: block;
    color: inherit;
}

.worksheet-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
    text-decoration: none;
    color: inherit;
}

.worksheet-card h3 {
    font-size: 1.4rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.worksheet-card p {
    color: #6c757d;
    margin-bottom: 15px;
    line-height: 1.5;
}









.selection-footer {
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Worksheet Interface */
.worksheet-interface {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.worksheet-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.start-over-btn {
    background: #6c757d;
    border: 2px solid #6c757d;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(108, 117, 125, 0.3);
}

.start-over-btn:hover {
    background: #5a6268;
    border-color: #5a6268;
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.4);
    transform: translateY(-1px);
}

.worksheet-info h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.worksheet-info p {
    opacity: 0.9;
    font-size: 1rem;
}



/* Progress Bar */
.progress-container {
    background: #f8f9fa;
    padding: 15px 30px;
    border-bottom: 1px solid #e9ecef;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
}

/* Problem Navigation */
.problem-nav {
    background: white;
    padding: 15px 30px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.nav-btn:hover {
    background: #5a6fd8;
}

.nav-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

#problem-counter {
    font-weight: 600;
    color: #495057;
}

/* Problems Container */
.problems-container {
    background: white;
    border-radius: 12px;
    margin: 20px 0;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Problem Container */
.problem-container {
    padding: 30px;
    border-bottom: 1px solid #e9ecef;
}

.problem-container:last-child {
    border-bottom: none;
}

.problem-container:nth-child(even) {
    background: #f8f9fa;
}

.problem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.problem-header h2 {
    color: #2c3e50;
    font-size: 1.6rem;
}

.problem-meta {
    display: flex;
    gap: 10px;
}



/* Problem Content */
.problem-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 768px) {
    .problem-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.explanation {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.explanation h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.explanation p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.problem-content-text {
    margin-bottom: 15px;
    line-height: 1.6;
}

.problem-content-text code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #e83e8c;
}

.task-box {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
}

.task-box h4 {
    color: #1976d2;
    margin-bottom: 8px;
}

/* Code Section */
.code-section {
    background: #2d3748;
    border-radius: 12px;
    overflow: hidden;
}

.code-header {
    background: #1a202c;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.code-header h4 {
    color: white;
    margin: 0;
}

.code-controls {
    display: flex;
    gap: 10px;
}

.hint-btn, .run-btn, .reset-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.reset-btn {
    background: #6c757d;
    color: white;
}

.reset-btn:hover {
    background: #5a6268;
}

.hint-btn {
    background: #ffc107;
    color: #212529;
}

.hint-btn:hover {
    background: #e0a800;
}

.run-btn {
    background: #28a745;
    color: white;
}

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

/* CodeMirror Customization */
.CodeMirror {
    font-size: 14px;
    border: none;
    min-height: 70px;
}

/* Input Section */
.input-section {
    background: #f8f9fa;
    border-top: 1px solid #e2e8f0;
    padding: 20px;
}

.input-fields {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.input-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.input-field label {
    color: #4a5568;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    white-space: nowrap;
}

.problem-input {
    padding: 8px 10px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
    width: 80px;
    text-align: center;
}

.problem-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.problem-input::placeholder {
    color: #a0aec0;
}

/* Responsive design for input fields */
@media (max-width: 768px) {
    .input-fields {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .input-field {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .problem-input {
        width: 100%;
        text-align: left;
    }
}

/* Run Code Button */
.run-btn {
    background: #28a745;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 100px;
}

.run-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* Output */
.output-section {
    background: #ffffff;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.output-header {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    color: white;
    padding: 12px 20px;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.output-header span::before {
    content: "▶";
    font-size: 0.8rem;
    opacity: 0.8;
    margin-right: 8px;
}

.output {
    background: #fafbfc;
    color: #2d3748;
    padding: 20px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    min-height: 120px;
    white-space: pre-wrap;
    border: none;
    position: relative;
    overflow-x: auto;
}

.output:empty::before {
    content: "Output will appear here when you run your code...";
    color: #a0aec0;
    font-style: italic;
}

.output.error {
    border-left: 4px solid #f56565;
}

.output.success {
    border-left: 4px solid #48bb78;
}

.output.running {
    border-left: 4px solid #4299e1;
}

/* Enhanced output content styling */
.output-content {
    margin-bottom: 15px;
}

.output-message {
    margin-top: 15px;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.output-message.success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.output-message.error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

.output-message.running {
    background: #bee3f8;
    color: #2a4365;
    border: 1px solid #90cdf4;
}





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

.output:not(:empty) {
    animation: fadeIn 0.3s ease-out;
}

/* Loading animation for running state */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.output.running::after {
    content: "Running...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4a5568;
    font-style: italic;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Responsive output */
@media (max-width: 768px) {
    .output {
        font-size: 12px;
        padding: 15px;
        min-height: 100px;
    }
    
    .output-header {
        padding: 10px 15px;
        font-size: 0.8rem;
    }
}

/* Modals */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    position: relative;
    text-align: center;
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
}

.close:hover {
    color: #495057;
}

.modal h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.completion-stats {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.completion-stats p {
    margin: 5px 0;
    font-weight: 600;
}

.completion-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.btn:hover {
    background: #5a6fd8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .worksheet-selection {
        padding: 20px;
    }
    
    .worksheets-grid {
        grid-template-columns: 1fr;
    }
    
    .problem-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .worksheet-header {
        flex-direction: column;
        text-align: center;
    }
    
    .problem-header {
        flex-direction: column;
        text-align: center;
    }
    
    .completion-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* Code styling */
code {
    background: #f1f3f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.loading-content p {
    color: #6c757d;
    font-size: 1rem;
}

/* Scroll Hint */
.scroll-hint {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    padding: 15px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.scroll-hint.animate {
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.scroll-arrow {
    font-size: 1.5rem;
    font-weight: bold;
}

.scroll-text {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Success/Error states */
.success-message {
    background: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    border: 1px solid #c3e6cb;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    border: 1px solid #f5c6cb;
}

/* Development Banner */
.dev-banner {
    background: linear-gradient(135deg, #ff6b6b, #ffa500);
    color: white;
    text-align: center;
    padding: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.3);
    position: relative;
    z-index: 100;
}

.dev-banner span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Experimental Badge */
.experimental-badge {
    background: linear-gradient(135deg, #ff6b6b, #ffa500);
    color: white;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
    margin-left: 8px;
    display: inline-block;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.3);
}
