<?php
declare(strict_types=1);

namespace Oscar\MailEngine\ImapClient;

final class InMemoryImapClient implements ImapClientInterface
{
    // ... existing properties ...

    private array $flags = [];
    private array $messages = [];

    public function setFlags(string $uid, FlagSet $flags, string $accountId): bool
    {
        $this->flags[$accountId][$uid] = $flags;
        return true;
    }

    public function move(string $uid, string $targetFolder, string $accountId): bool
    {
        if (!isset($this->messages[$accountId][$uid])) {
            throw new \RuntimeException("Message not found");
        }
        $this->messages[$accountId][$uid]['folder'] = $targetFolder;
        return true;
    }

    public function search(
        string $query,
        SearchFilter $filter,
        string $accountId,
        int $page = 1,
        int $pageSize = 8
    ): MessageList {
        // Return fixture data
        return new MessageList(
            messages: [
                ['id' => '1', 'uid' => '1', 'subject' => 'Test', 'from' => 'test@example.com', 'date' => '2023-01-01', 'hasAttachment' => false],
                ['id' => '2', 'uid' => '2', 'subject' => 'Hello', 'from' => 'hello@example.com', 'date' => '2023-01-02', 'hasAttachment' => true],
            ],
            total: 2,
            page: $page,
            pageSize: $pageSize,
        );
    }

    public function getStorage(string $accountId): StorageStats
    {
        // Return fixture data
        return new StorageStats(
            usedBytes: 1024000,
            totalBytes: 2048000,
            percent: 50,
            breakdown: [
                ['name' => 'Inbox', 'size' => 512000, 'percent' => 50],
                ['name' => 'Sent', 'size' => 256000, 'percent' => 25],
                ['name' => 'Drafts', 'size' => 256000, 'percent' => 25],
            ],
        );
    }

    public function delete(string $uid, string $accountId): bool
    {
        if (!isset($this->messages[$accountId][$uid])) {
            throw new \RuntimeException("Message not found");
        }
        unset($this->messages[$accountId][$uid]);
        return true;
    }

    // ... other existing methods ...
}