/* ============================================
   Component Playground Styles
   ============================================ */

/* Playground Modal Overrides */
.modal.playground-active .modal-content {
    max-width: 1400px;
    max-height: 95vh;
    height: 90vh;
}

/* Modal Header with Playground Toggle */
.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.playground-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.playground-toggle-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--primary);
    color: var(--primary);
}

.playground-toggle-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.playground-toggle-btn i {
    font-size: 0.9rem;
}

/* Playground Layout */
.playground-container {
    display: none;
    flex-direction: column;
    height: calc(100% - 70px); /* Subtract header height */
    overflow: hidden;
}

.modal.playground-active .playground-container {
    display: flex;
}

.modal.playground-active .code-tabs,
.modal.playground-active .code-container {
    display: none;
}

/* Playground Preview Area */
.playground-preview {
    height: 250px;
    min-height: 200px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.playground-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(circle at center, transparent 0%, var(--bg-secondary) 100%),
        linear-gradient(90deg, transparent 49.5%, var(--border-color) 49.5%, var(--border-color) 50.5%, transparent 50.5%),
        linear-gradient(0deg, transparent 49.5%, var(--border-color) 49.5%, var(--border-color) 50.5%, transparent 50.5%);
    background-size: 100% 100%, 24px 24px, 24px 24px;
    opacity: 0.4;
}

.playground-preview-content {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Playground Editors */
.playground-editors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    min-height: 300px;
    overflow: hidden;
}

.playground-editor-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
}

.playground-editor-pane:last-child {
    border-right: none;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
}

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

.editor-header-left i {
    color: var(--primary);
}

.editor-header-left span {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.editor-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.editor-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.editor-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--primary);
    color: var(--primary);
}

.editor-btn.copy-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.editor-btn.reset-btn:hover {
    background: var(--warning);
    border-color: var(--warning);
    color: white;
}

/* Code Editor Textarea */
.code-editor-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 250px;
}

.code-editor {
    width: 100%;
    height: 100%;
    min-height: 250px;
    padding: 1rem;
    background: var(--bg-primary);
    border: none;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 2;
}

.code-editor:focus {
    background: var(--bg-secondary);
    box-shadow: inset 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.code-editor::placeholder {
    color: var(--text-muted);
}

/* Line numbers effect with left border */
.code-editor {
    border-left: 3px solid var(--primary);
    padding-left: 1.25rem;
}

/* Scrollbar styling for editors */
.code-editor::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.code-editor::-webkit-scrollbar-track {
    background: var(--bg-card);
}

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

.code-editor::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Status Bar */
.playground-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.status-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: var(--transition);
}

.status-actions button:hover {
    color: var(--primary);
}

/* Responsive */
@media (max-width: 900px) {
    .playground-editors {
        grid-template-columns: 1fr;
    }
    
    .playground-editor-pane {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        min-height: 200px;
    }
    
    .playground-editor-pane:last-child {
        border-bottom: none;
    }
    
    .modal.playground-active .modal-content {
        height: 95vh;
    }
    
    .playground-preview {
        height: 200px;
        min-height: 150px;
    }
}

/* Animation for mode switch */
.modal-content {
    transition: max-width 0.3s ease, max-height 0.3s ease;
}

/* Hide regular preview when playground is active */
.modal.playground-active .modal-preview {
    display: none;
}
