/* CSS Variables */
:root {
    /* Colors */
    --background: hsl(222, 47%, 11%);
    --foreground: hsl(210, 40%, 98%);
    --card: hsl(222, 47%, 14%);
    --card-foreground: hsl(210, 40%, 98%);
    --primary: hsl(199, 89%, 48%);
    --primary-foreground: hsl(222, 47%, 11%);
    --secondary: hsl(217, 33%, 17%);
    --secondary-foreground: hsl(210, 40%, 98%);
    --muted: hsl(217, 33%, 20%);
    --muted-foreground: hsl(215, 20%, 65%);
    --accent: hsl(142, 71%, 45%);
    --accent-foreground: hsl(222, 47%, 11%);
    --destructive: hsl(0, 84%, 60%);
    --border: hsl(217, 33%, 25%);
    --editor-bg: hsl(222, 47%, 8%);
    --output-bg: hsl(222, 47%, 6%);
    --output-success: hsl(142, 71%, 45%);
    --output-error: hsl(0, 84%, 60%);

    /* Fonts */
    --font-ui: 'Inter', sans-serif;
    --font-code: 'JetBrains Mono', monospace;

    /* Spacing */
    --radius: 0.75rem;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(to bottom, hsl(222, 47%, 14%, 0.5), transparent);
    backdrop-filter: blur(8px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, hsl(199, 89%, 48%, 0.1), hsl(142, 71%, 45%, 0.1));
    border: 1px solid hsl(199, 89%, 48%, 0.2);
}

.logo-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--primary);
}

.app-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
}

.gradient-text {
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-subtitle {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin: 0;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    background: hsl(217, 33%, 17%, 0.5);
    border: 1px solid var(--border);
}

.badge-icon {
    width: 1rem;
    height: 1rem;
    color: var(--accent);
}

.badge-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

/* Example Bar */
.example-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    background: hsl(222, 47%, 14%, 0.2);
}

.example-hint {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.example-link {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--primary);
    text-decoration: none;
}

.example-link:hover {
    text-decoration: underline;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    font-family: var(--font-ui);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.dropdown-button:hover {
    background: hsl(217, 33%, 20%);
    border-color: var(--primary);
}

.dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    min-width: 16rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
}

.dropdown-content.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-label {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    color: var(--muted-foreground);
    border-bottom: 1px solid var(--border);
}

.dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid hsl(217, 33%, 25%, 0.3);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--secondary);
}

.dropdown-item-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--foreground);
    display: block;
    margin-bottom: 0.125rem;
}

.dropdown-item-desc {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: hsl(222, 47%, 14%, 0.3);
    border-bottom: 1px solid var(--border);
}

.toolbar-left {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-run {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.btn-run:hover:not(:disabled) {
    background: hsl(199, 89%, 55%);
    box-shadow: 0 0 20px hsl(199, 89%, 48%, 0.3);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--foreground);
}

.btn-secondary:hover:not(:disabled) {
    background: hsl(217, 33%, 20%);
}

.btn-outline {
    background: transparent;
    color: var(--foreground);
}

.btn-outline:hover:not(:disabled) {
    background: var(--secondary);
}

.icon {
    width: 1rem;
    height: 1rem;
}

.chevron {
    width: 0.75rem;
    height: 0.75rem;
    opacity: 0.5;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    min-height: 0;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Editor Panel */
.editor-panel {
    height: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), inset 0 1px 0 hsl(217, 33%, 25%, 0.1);
}

.monaco-container {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    /* Edge-specific fixes */
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

/* Fix Monaco Editor cursor alignment in Chrome and Edge */
.monaco-container * {
    box-sizing: border-box;
}

.monaco-container .monaco-editor,
.monaco-container .monaco-editor * {
    box-sizing: border-box;
    /* Ensure consistent font rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.monaco-container .view-lines {
    box-sizing: border-box;
}

/* Additional Edge-specific fixes */
.monaco-container .view-line {
    box-sizing: border-box;
}

.monaco-container .monaco-editor .view-overlays {
    box-sizing: border-box;
}

.monaco-container .monaco-editor .cursors-layer {
    box-sizing: border-box;
}



/* Legacy code-editor class kept for backwards compatibility */
.code-editor {
    width: 100%;
    height: 100%;
    padding: 1rem;
    background: var(--editor-bg);
    color: var(--foreground);
    font-family: var(--font-code);
    font-size: 0.9375rem;
    line-height: 1.6;
    border: none;
    outline: none;
    resize: none;
    tab-size: 4;
}

.code-editor::selection {
    background: hsl(199, 89%, 48%, 0.3);
}

/* Output Panel */
.output-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), inset 0 1px 0 hsl(217, 33%, 25%, 0.1);
}

.output-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: hsl(217, 33%, 17%, 0.5);
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    font-weight: 500;
}

.output-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
}

.output-content {
    flex: 1;
    background: var(--output-bg);
    padding: 1rem;
    overflow: auto;
}

.output-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted-foreground);
    text-align: center;
}

.empty-icon {
    width: 3rem;
    height: 3rem;
    opacity: 0.3;
    margin-bottom: 0.75rem;
}

.output-empty p {
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

.empty-hint {
    font-size: 0.75rem;
    opacity: 0.7;
}

.output-running {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted-foreground);
}

.loading-dots {
    display: flex;
    gap: 0.25rem;
}

.loading-dots span {
    width: 0.5rem;
    height: 0.5rem;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

#outputText {
    font-family: var(--font-code);
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--foreground);
    margin: 0;
    animation: fadeIn 0.3s ease-out;
}

.error-text {
    font-family: var(--font-code);
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--output-error);
    margin-top: 0.5rem;
}

/* Status Bar */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: hsl(217, 33%, 17%, 0.3);
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--muted-foreground);
}

.status-dot.loading {
    background: var(--primary);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.status-dot.ready {
    background: var(--output-success);
}

.status-text {
    color: var(--muted-foreground);
}

.status-divider {
    color: hsl(215, 20%, 65%, 0.5);
}

.status-info {
    color: var(--muted-foreground);
}

.status-right {
    color: hsl(215, 20%, 65%, 0.7);
}

kbd {
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    color: var(--foreground);
    font-family: var(--font-ui);
    font-size: 0.75rem;
}

/* Status Icons */
.status-icon {
    width: 1rem;
    height: 1rem;
}

.status-success {
    color: var(--output-success);
}

.status-error {
    color: var(--output-error);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: hsl(217, 33%, 30%);
}
