/* ============================================
   Code Editor / Playground Styles
   ============================================ */

.playground-section {
    margin: 40px 0;
}

.playground-container {
    background: var(--surface, #1a1a2e);
    border: 1px solid var(--border, #2a2a4a);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease;
}

.playground-container:hover {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
}

/* Toolbar */
.playground-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .playground-toolbar {
    background: linear-gradient(135deg, #f0f0f5 0%, #e8e8f0 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.playground-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.playground-lang-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.playground-lang-badge.go {
    background: rgba(0, 173, 216, 0.15);
    color: #00ADD8;
}

.playground-lang-badge.python {
    background: rgba(55, 118, 171, 0.15);
    color: #3776AB;
}

.playground-lang-badge.php {
    background: rgba(119, 123, 180, 0.15);
    color: #777BB4;
}

.playground-lang-badge.javascript {
    background: rgba(247, 223, 30, 0.15);
    color: #F7DF1E;
}

[data-theme="light"] .playground-lang-badge.javascript {
    color: #b8a900;
}

.playground-lang-badge.elixir {
    background: rgba(107, 70, 193, 0.15);
    color: #9B59B6;
}

.playground-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

[data-theme="light"] .playground-status {
    color: rgba(0, 0, 0, 0.4);
}

.playground-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.playground-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.playground-btn-run {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.playground-btn-run:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4);
}

.playground-btn-run:active {
    transform: translateY(0);
}

.playground-btn-run.running {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    pointer-events: none;
}

.playground-btn-reset {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .playground-btn-reset {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.playground-btn-reset:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

[data-theme="light"] .playground-btn-reset:hover {
    background: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.8);
}

/* Editor Area */
.playground-editor-wrapper {
    position: relative;
    min-height: 200px;
}

.playground-editor {
    width: 100%;
    min-height: 200px;
    padding: 16px 20px;
    background: #1e1e1e;
    color: #d4d4d4;
    border: none;
    outline: none;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    resize: vertical;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}

[data-theme="light"] .playground-editor {
    background: #fafafa;
    color: #383a42;
}

.playground-editor:focus {
    outline: none;
}

.playground-editor::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .playground-editor::placeholder {
    color: rgba(0, 0, 0, 0.25);
}

/* Line numbers gutter */
.playground-line-numbers {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 44px;
    background: rgba(0, 0, 0, 0.2);
    padding-top: 16px;
    text-align: right;
    padding-right: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.2);
    user-select: none;
    line-height: 1.7;
    overflow: hidden;
}

[data-theme="light"] .playground-line-numbers {
    background: rgba(0, 0, 0, 0.04);
    color: rgba(0, 0, 0, 0.25);
}

/* Output Panel */
.playground-output-wrapper {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .playground-output-wrapper {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.playground-output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.15);
    cursor: pointer;
    user-select: none;
}

[data-theme="light"] .playground-output-header {
    background: rgba(0, 0, 0, 0.03);
}

.playground-output-header h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

[data-theme="light"] .playground-output-header h4 {
    color: rgba(0, 0, 0, 0.5);
}

.playground-output-content {
    padding: 16px 20px;
    min-height: 60px;
    max-height: 250px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #d4d4d4;
    background: #0d0d0d;
}

[data-theme="light"] .playground-output-content {
    background: #f5f5f5;
    color: #383a42;
}

.playground-output-content pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.playground-output-content .output-success {
    color: #22c55e;
}

.playground-output-content .output-error {
    color: #ef4444;
}

.playground-output-content .output-info {
    color: #60a5fa;
    font-style: italic;
}

/* Loading Spinner */
.playground-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: playground-spin 0.6s linear infinite;
}

@keyframes playground-spin {
    to { transform: rotate(360deg); }
}

/* Execution time badge */
.playground-exec-time {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.playground-exec-time.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Section Header */
.playground-section .formula-category-header {
    position: relative;
}

.playground-section .formula-category-header::after {
    content: "INTERACTIVE";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 4px 12px;
    border-radius: 20px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .playground-toolbar {
        flex-direction: column;
        gap: 10px;
        padding: 10px 14px;
    }

    .playground-toolbar-left,
    .playground-toolbar-right {
        width: 100%;
        justify-content: center;
    }

    .playground-btn {
        flex: 1;
        justify-content: center;
    }

    .playground-editor {
        font-size: 0.8rem;
        padding: 12px 14px;
        min-height: 160px;
    }

    .playground-output-content {
        font-size: 0.8rem;
        padding: 12px 14px;
    }

    .playground-section .formula-category-header::after {
        display: none;
    }
}

/* Scrollbar Styles */
.playground-editor::-webkit-scrollbar,
.playground-output-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.playground-editor::-webkit-scrollbar-track,
.playground-output-content::-webkit-scrollbar-track {
    background: transparent;
}

.playground-editor::-webkit-scrollbar-thumb,
.playground-output-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.playground-editor::-webkit-scrollbar-thumb:hover,
.playground-output-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

[data-theme="light"] .playground-editor::-webkit-scrollbar-thumb,
[data-theme="light"] .playground-output-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .playground-editor::-webkit-scrollbar-thumb:hover,
[data-theme="light"] .playground-output-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}
