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

:root {
    --primary-color: #f97316;
    --primary-hover: #ea580c;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border: #475569;
    --code-bg: #1e1e1e;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Language Selector */
.language-section,
.input-section,
.llm-section,
.quick-reference,
.examples-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.language-header,
.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.language-header h3,
.input-header h3 {
    color: var(--text-primary);
}

.input-actions {
    display: flex;
    gap: 10px;
}

.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.lang-btn {
    padding: 12px 15px;
    background: var(--surface-light);
    color: var(--text-secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.lang-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.lang-icon {
    font-size: 1.5rem;
}

/* Error Input */
.error-input {
    width: 100%;
    padding: 20px;
    background: var(--code-bg);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    margin-bottom: 15px;
}

.error-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.error-input::placeholder {
    color: #6a6a6a;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(249, 115, 22, 0.4);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-large {
    width: 100%;
    padding: 15px 30px;
    font-size: 1.1rem;
}

.btn-icon {
    font-size: 1.2rem;
}

/* LLM Section */
.llm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.llm-header h3 {
    color: var(--text-primary);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.llm-config {
    margin-top: 15px;
}

.info-banner {
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--info-color);
    border-radius: 6px;
    color: var(--info-color);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.llm-settings {
    display: grid;
    gap: 15px;
}

.form-group {
    display: grid;
    gap: 8px;
}

.form-group label {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.form-control {
    padding: 10px 15px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Results Section */
.results-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.analysis-card,
.explanation-card,
.code-card,
.solution-card,
.prevention-card,
.related-card,
.resources-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.card-header h3 {
    color: var(--text-primary);
    font-size: 1.3rem;
}

.detected-lang {
    padding: 6px 15px;
    background: rgba(249, 115, 22, 0.2);
    color: var(--primary-color);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Error Metadata */
.error-metadata {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.meta-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.meta-value {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.severity-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.severity-badge.critical {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error-color);
}

.severity-badge.high {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
}

.severity-badge.medium {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info-color);
}

.severity-badge.low {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
}

/* Explanation Content */
.explanation-content {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 1rem;
}

.explanation-content p {
    margin-bottom: 15px;
}

.explanation-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.explanation-content li {
    margin-bottom: 8px;
}

.explanation-content code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary-color);
    font-family: 'Consolas', monospace;
}

/* Code Snippet */
.code-snippet {
    background: var(--code-bg);
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    border-left: 4px solid var(--error-color);
}

/* Solutions */
.solutions-container {
    display: grid;
    gap: 20px;
}

.solution-item {
    background: var(--surface-light);
    border-radius: 8px;
    padding: 20px;
    border-left: 4px solid var(--success-color);
}

.solution-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.solution-number {
    width: 30px;
    height: 30px;
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.solution-description {
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.6;
}

.solution-code {
    background: var(--code-bg);
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    margin-top: 10px;
}

.solution-code pre {
    font-family: 'Consolas', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin: 0;
}

/* Prevention */
.prevention-content {
    display: grid;
    gap: 12px;
}

.prevention-tip {
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
    border-left: 3px solid var(--info-color);
}

.prevention-tip-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.prevention-tip-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Related Errors */
.related-errors {
    display: grid;
    gap: 12px;
}

.related-error-item {
    padding: 15px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.related-error-item:hover {
    background: var(--border);
    border-color: var(--primary-color);
}

.related-error-name {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.related-error-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Resources */
.resources-content {
    display: grid;
    gap: 12px;
}

.resource-link {
    padding: 12px 15px;
    background: var(--surface-light);
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    transition: all 0.3s ease;
}

.resource-link:hover {
    background: var(--border);
}

.resource-title {
    color: var(--text-primary);
    font-weight: 600;
}

.resource-arrow {
    color: var(--primary-color);
    font-size: 1.2rem;
}

/* Quick Reference */
.reference-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    border-bottom: 2px solid var(--border);
}

.ref-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.ref-tab:hover {
    color: var(--text-primary);
}

.ref-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.quick-ref-content {
    display: grid;
    gap: 12px;
}

.ref-error-item {
    padding: 15px;
    background: var(--surface-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ref-error-item:hover {
    background: var(--border);
}

.ref-error-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
    font-family: 'Consolas', monospace;
}

.ref-error-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Examples Grid */
.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.example-card {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.example-card:hover {
    background: var(--border);
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(249, 115, 22, 0.3);
}

.example-lang {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(249, 115, 22, 0.2);
    color: var(--primary-color);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.example-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.example-preview {
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.footer-note {
    margin-top: 10px;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .language-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .error-metadata {
        grid-template-columns: 1fr;
    }

    .examples-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}