@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;700&family=Inter:wght@300;400;600;700&display=swap');

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

body {
    font-family: 'Inter', sans-serif;
    background-color: #0f172a;
    color: #f8fafc;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Fix container conflict with Tailwind */
.tw-container {
    width: 100%;
}

@media (min-width: 640px) {
    .tw-container {
        max-width: 640px;
    }
}

@media (min-width: 768px) {
    .tw-container {
        max-width: 768px;
    }
}

@media (min-width: 1024px) {
    .tw-container {
        max-width: 1024px;
    }
}

@media (min-width: 1280px) {
    .tw-container {
        max-width: 1280px;
    }
}

@media (min-width: 1536px) {
    .tw-container {
        max-width: 1536px;
    }
}

header {
    border-bottom: 1px solid #1e293b;
    margin-bottom: 2rem;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #f8fafc;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: #f8fafc;
    text-decoration: none;
    font-weight: 400;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #8b5cf6;
}

.nav-links a.active {
    color: #8b5cf6;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.playground-layout {
    display: flex;
    gap: 1rem;
    height: 600px;
    position: relative;
    min-height: 400px;
    overflow: auto;
}

.editor-container {
    flex-basis: 60%;
    transition: none;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.output-container {
    flex-basis: 40%;
    transition: none;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

/* Vertical layout styles */
.playground-layout.vertical {
    flex-direction: column;
    height: 800px;
    min-height: 600px;
    gap: 1rem;
}

.playground-layout.vertical .editor-container {
    flex-basis: 60%;
    min-height: 200px;
}

.playground-layout.vertical .output-container {
    flex-basis: 40%;
    min-height: 200px;
}

/* Layout toggle button */
.layout-toggle {
    background: #334155;
    color: #f8fafc;
    border: none;
    padding: 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
}

.layout-toggle:hover {
    background: #475569;
}

.playground-container {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.3);
    transition: transform 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.editor-section {
    padding: 1.5rem;
    border-bottom: 1px solid #334155;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.editor-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #f8fafc;
}

#editor {
    flex: 1;
    width: 100%;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #0f172a;
    border-left: 4px solid #8b5cf6;
    font-family: 'Fira Code', monospace;
}

textarea {
    width: 100%;
    height: 400px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    transition: border-color 0.2s;
    background: #fafafa;
}

textarea:focus {
    outline: none;
    border-color: #2563eb;
    background: #fff;
}

.controls {
    padding: 1.5rem;
    background: #1e293b;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.run-button {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.run-button:hover:not(:disabled) {
    background: linear-gradient(90deg, #2563eb, #7c3aed);
    transform: translateY(-2px);
}

.run-button:disabled {
    background: #334155;
    cursor: not-allowed;
    transform: none;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #f8fafc;
}

.status.error {
    color: #ef4444;
}

.status.success {
    color: #22c55e;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f8fafc;
}

.status.error .status-dot {
    background: #ef4444;
}

.status.success .status-dot {
    background: #22c55e;
}

.output-section {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    overflow: hidden;
    border-left: 4px solid #8b5cf6;
    transition: transform 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.output-header {
    padding: 1rem 1.5rem;
    background: #334155;
    border-bottom: 1px solid #475569;
    font-weight: 600;
    color: #f8fafc;
}

#output {
    padding: 1.5rem;
    white-space: pre-wrap;
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #f8fafc;
    background: #0f172a;
    max-width: 90vw;
    scroll-behavior: auto;
    flex: 1;
    overflow-y: auto;
}

.loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #f8fafc;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #334155;
    border-top: 2px solid #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.error-output {
    color: #fca5a5;
    background: #1e293b;
    border-left: 4px solid #ef4444;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
}

.error-message {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #ef4444;
}

.error-location {
    color: #fbbf24;
    margin-bottom: 0.5rem;
    font-family: 'Fira Code', monospace;
}

.error-expected,
.error-found {
    margin-bottom: 0.25rem;
    font-family: 'Fira Code', monospace;
}

.error-expected {
    color: #10b981;
}

.error-found {
    color: #f59e0b;
}

.error-detail {
    margin-bottom: 0.25rem;
    color: #94a3b8;
    font-size: 0.875rem;
}

/* Monaco Editor Dark Theme Customization */
.monaco-editor {
    background: #0f172a !important;
    font-family: 'Fira Code', monospace !important;
}

.monaco-editor .margin {
    background: #0f172a !important;
}

.monaco-editor .monaco-editor-background {
    background: #0f172a !important;
}

.monaco-editor .current-line {
    background: rgba(139, 92, 246, 0.1) !important;
}

/* Syntax highlighting colors to match the main site */
.monaco-editor .mtk1 {
    color: #f8fafc !important;
}

/* default text */
.monaco-editor .mtk5 {
    color: #f472b6 !important;
}

/* keywords */
.monaco-editor .mtk6 {
    color: #86efac !important;
}

/* strings */
.monaco-editor .mtk7 {
    color: #64748b !important;
}

/* comments */
.monaco-editor .mtk8 {
    color: #60a5fa !important;
}

/* types */
.monaco-editor .mtk9 {
    color: #fbbf24 !important;
}

/* functions */
.monaco-editor .mtk10 {
    color: #a78bfa !important;
}

/* numbers */

/* Enhanced Monaco Editor error styling */
.monaco-editor .squiggly-error {
    background: url("data:image/svg+xml,%3csvg width='6' height='3' viewBox='0 0 6 3' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='m0 3 l2 -2 l1 0 l2 2 l1 0' stroke='%23ef4444' fill='none' stroke-width='2'/%3e%3c/svg%3e") repeat-x bottom left;
}

/* Custom error decoration for better visibility */
.monaco-editor .perk-error-decoration {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border: 2px solid #ef4444 !important;
    border-radius: 3px !important;
    animation: errorPulse 2s infinite;
}

@keyframes errorPulse {

    0%,
    100% {
        border-color: #ef4444;
        background-color: rgba(239, 68, 68, 0.15);
    }

    50% {
        border-color: #dc2626;
        background-color: rgba(239, 68, 68, 0.25);
    }
}

/* Make error markers more visible in dark theme */
.monaco-editor.vs-dark .squiggly-error {
    background: url("data:image/svg+xml,%3csvg width='6' height='3' viewBox='0 0 6 3' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='m0 3 l2 -2 l1 0 l2 2 l1 0' stroke='%23ff6b6b' fill='none' stroke-width='2'/%3e%3c/svg%3e") repeat-x bottom left;
}

.monaco-editor.vs-dark .perk-error-decoration {
    background-color: rgba(255, 107, 107, 0.2) !important;
    border: 2px solid #ff6b6b !important;
}

/* Error gutter icons */
.monaco-editor .margin-view-overlays .cgmr {
    background-color: #ef4444 !important;
    border-radius: 50% !important;
    width: 16px !important;
    height: 16px !important;
}

/* Enhanced error tooltips */
.monaco-editor .monaco-hover {
    border: 2px solid #ef4444 !important;
    background: #1e293b !important;
    color: #f8fafc !important;
}

.monaco-editor .monaco-hover .monaco-hover-content {
    color: #ef4444 !important;
    font-weight: 600 !important;
}

@media (max-width: 768px) {
    .container {
        padding: 0.25rem;
    }

    .header-content {
        padding: 0.75rem;
        flex-direction: column;
        gap: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    #editor {
        height: 500px;
    }

    .editor-section {
        padding: 0.75rem;
        border-bottom: 1px solid #334155;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .editor-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.5rem;
    }

    .controls {
        padding: 0.75rem;
        background: #1e293b;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .run-button {
        justify-content: center;
    }

    .nav-links {
        display: none;
    }

    .playground-layout,
    .playground-layout.vertical {
        flex-direction: column;
        height: auto;
        min-height: 400px;
        gap: 0.25rem;
    }

    .editor-container,
    .output-container {
        flex-basis: auto !important;
        min-height: 200px !important;
    }

    .playground-container {
        height: 600px;
        min-height: 500px;
    }

    .output-section {
        height: 300px;
        min-height: 200px;
    }

    .output-header {
        padding: 0.75rem 1rem;
        background: #334155;
        border-bottom: 1px solid #475569;
        font-weight: 600;
        color: #f8fafc;
    }

    #output {
        padding: 0.75rem;
        white-space: pre-wrap;
        font-family: 'Fira Code', monospace;
        font-size: 0.875rem;
        line-height: 1.6;
        color: #f8fafc;
        background: #0f172a;
        max-width: 90vw;
        scroll-behavior: auto;
        flex: 1;
        overflow-y: auto;
    }

    .layout-toggle {
        display: none;
    }
}

/* Offcanvas Menu Styles */
.offcanvas-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background: #1e293b;
    border-left: 1px solid #334155;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: right 0.3s ease;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

.offcanvas-menu.open {
    right: 0;
}

.offcanvas-menu .nav-link {
    color: #f8fafc;
    text-decoration: none;
    font-weight: 400;
    padding: 0.75rem 0;
    border-bottom: 1px solid #334155;
    transition: color 0.2s;
}

.offcanvas-menu .nav-link:hover {
    color: #8b5cf6;
}

.offcanvas-menu .nav-link:last-child {
    border-bottom: none;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999;
}

.menu-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Hide offcanvas menu on desktop */
@media (min-width: 769px) {
    .offcanvas-menu {
        display: none;
    }

    .menu-overlay {
        display: none;
    }
}