/* 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-color: #f8f9fa;
}

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

/* Header styles */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    border-bottom: 1px solid #e9ecef;
}

header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

header p {
    max-width: 800px;
    margin: 0 auto;
    color: #6c757d;
}

/* Main content styles */
main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.code-input {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.code-editor-container {
    width: 100%;
    position: relative;
    margin-bottom: 20px;
    border-radius: 4px;
    overflow: hidden;
}

/* CodeMirror custom styles */
.CodeMirror {
    height: 350px !important;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Make sure the gutter (line numbers) looks good */
.CodeMirror-gutters {
    border-right: 1px solid #ddd;
    background-color: #f7f7f7;
}

/* Highlight the active line */
.CodeMirror-activeline-background {
    background: rgba(232, 242, 254, 0.3);
}

/* Adjust cursor */
.CodeMirror-cursor {
    border-left: 2px solid #333;
}

/* Adjust selection color */
.CodeMirror-selected {
    background: #d7d4f0 !important;
}

#code-editor {
    flex: 1;
    height: 100%;
    padding: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    border: none;
    resize: none;
    line-height: 1.5;
}

#analyze-btn {
    align-self: flex-end;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

#analyze-btn:hover {
    background-color: #45a049;
}

/* Results styles */
.results-container {
    background-color: white;
    border-radius: 4px;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.results-container h2 {
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
}

#loading {
    text-align: center;
    margin: 20px 0;
    font-style: italic;
    color: #6c757d;
}

.hidden {
    display: none;
}

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

.results-header {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.results-header p {
    font-size: 16px;
    color: #2c3e50;
}

.feedback-item {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    align-items: flex-start;
}

/* Category-specific styles */
.syntax_error {
    background-color: #cce5ff;
    border-left: 4px solid #007bff;
}

.runtime_error {
    background-color: #f8d7da;
    border-left: 4px solid #dc3545;
}

.fatal_error {
    background-color: #f8d7da;
    border-left: 4px solid #721c24;
    border-top: 1px solid #f5c6cb;
    border-right: 1px solid #f5c6cb;
    border-bottom: 1px solid #f5c6cb;
}

.potential_error {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
}

.bad_habit {
    background-color: #d1ecf1;
    border-left: 4px solid #17a2b8;
}

.system-message {
    background-color: #e2e3e5;
    border-left: 4px solid #6c757d;
}

/* Category indicator labels */
.category-indicator {
    font-weight: bold;
    margin-right: 5px;
}

.syntax-error-label {
    color: #007bff;
}

.runtime-error-label {
    color: #dc3545;
}

.fatal-error-label {
    color: #721c24;
}

.potential-error-label {
    color: #856404;
}

.bad-habit-label {
    color: #0c5460;
}

/* Category summary dots */
.category-summary {
    list-style: none;
    padding-left: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.category-summary li {
    display: flex;
    align-items: center;
}

.syntax-error-dot, .runtime-error-dot, .fatal-error-dot, .potential-error-dot, .bad-habit-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 5px;
}

.syntax-error-dot {
    background-color: #007bff;
}

.runtime-error-dot {
    background-color: #dc3545;
}

.fatal-error-dot {
    background-color: #721c24;
}

.potential-error-dot {
    background-color: #ffc107;
}

.bad-habit-dot {
    background-color: #17a2b8;
}

.feedback-icon {
    margin-right: 10px;
    font-size: 20px;
    min-width: 24px;
    text-align: center;
}

.feedback-content {
    flex: 1;
}

.feedback-line {
    font-weight: bold;
    margin-bottom: 5px;
}

.feedback-message {
    margin-bottom: 5px;
}

.feedback-source {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
}

/* AI explanation and fix styles */
.ai-help-container {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.feedback-explanation,
.feedback-fix {
    padding: 8px 12px;
    border-radius: 4px;
    background-color: #f8f9fa;
}

.feedback-explanation {
    border-left: 3px solid #17a2b8;
    background-color: #e3f6f9;
}

.feedback-fix {
    border-left: 3px solid #28a745;
    background-color: #e3f9e5;
    margin-top: 5px;
}

.explanation-header,
.fix-header {
    font-weight: bold;
    margin-bottom: 3px;
    font-size: 14px;
}

.explanation-header {
    color: #17a2b8;
}

.fix-header {
    color: #28a745;
}

.explanation-content,
.fix-content {
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
}

/* Code block styling */
.fix-content pre {
    margin: 8px 0;
    padding: 0;
    background: transparent;
}

/* Apply Fix button styling */
.fix-button-container {
    margin-top: 15px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px;
    border-radius: 4px;
    background-color: #f1f9f1;
    border: 1px dashed #28a745;
}

.apply-fix-btn {
    padding: 10px 20px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: block;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 80%;
}

.apply-fix-btn:hover {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.fix-button-label {
    margin-top: 8px;
    font-size: 12px;
    color: #6c757d;
    text-align: center;
}

.fix-content code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    border-radius: 4px;
    padding: 8px !important;
    margin: 0;
    width: 100%;
    display: block;
    overflow-x: auto;
}

/* Labels for BEFORE/AFTER sections */
.fix-content div:first-child {
    font-weight: bold;
    margin-bottom: 4px;
}

/* Space between code blocks */
.fix-content pre + div {
    margin-top: 12px;
    font-weight: bold;
}

/* Footer styles */
footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    color: #6c757d;
}

/* Responsive styles */
@media (min-width: 768px) {
    main {
        flex-direction: row;
    }
    
    .code-input, .results-container {
        flex: 1;
    }
}
