
/*
 * This file is part of Psy Shell.
 *
 * (c) 2012-2023 Justin Hileman
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Psy;

use Psy\ExecutionLoop\ProcessForker;
use Psy\VersionUpdater\GitHubChecker;
use Psy\VersionUpdater\Installer;
use Psy\VersionUpdater\SelfUpdate;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;

if (!\function_exists('Psy\\sh')) {
    /**
     * Command to return the eval-able code to startup PsySH.
     *
     *     eval(\Psy\sh());
     */
    function sh(): string
    {
        if (\version_compare(\PHP_VERSION, '8.0', '<')) {
            return '\extract(\Psy\debug(\get_defined_vars(), isset($this) ? $this : @\get_called_class()));';
        }

        return <<<'EOS'
if (isset($this)) {
    \extract(\Psy\debug(\get_defined_vars(), $this));
} else {
    try {
        static::class;
        \extract(\Psy\debug(\get_defined_vars(), static::class));
    } catch (\Error $e) {
        \extract(\Psy\debug(\get_defined_vars()));
    }
}
EOS;
    }
}

if (!\function_exists('Psy\\debug')) {
    /**
     * Invoke a Psy Shell from the current context.
     *
     * For example:
     *
     *     foreach ($items as $item) {
     *         \Psy\debug(get_defined_vars());
     *     }
     *
     * If you would like your shell interaction to affect the state of the
     * current context, you can extract() the values returned from this call:
     *
     *     foreach ($items as $item) {
     *         extract(\Psy\debug(get_defined_vars()));
     *         var_dump($item); // will be whatever you set $item to in Psy Shell
     *     }
     *
     * Optionally, supply an object as the `$bindTo` parameter. This determines
     * the value `$this` will have in the shell, and sets up class scope so that
     * private and protected members are accessible:
     *
     *     class Foo {
     *         function bar() {
     *             \Psy\debug(get_defined_vars(), $this);
     *         }
     *     }
     *
     * For the static equivalent, pass a class name as the `$bindTo` parameter.
     * This makes `self` work in the shell, and sets up static scope so that
     * private and protected static members are accessible:
     *
     *     class Foo {
     *         static function bar() {
     *             \Psy\debug(get_defined_vars(), get_called_class());
     *         }
     *     }
     *
     * @param array         $vars   Scope variables from the calling context (default: [])
     * @param object|string $bindTo Bound object ($this) or class (self) value for the shell
     *
     * @return array Scope variables from the debugger session
     */
    function debug(array $vars = [], $bindTo = null): array
    {
        echo \PHP_EOL;

        $sh = new Shell();
        $sh->setScopeVariables($vars);

        // Show a couple of lines of call context for the debug session.
        //
        // @todo come up with a better way of doing this which doesn't involve injecting input :-P
        if ($sh->has('whereami')) {
            $sh->addInput('whereami -n2', true);
        }

        if (\is_string($bindTo)) {
            $sh->setBoundClass($bindTo);
        } elseif ($bindTo !== null) {
            $sh->setBoundObject($bindTo);
        }

        $sh->run();

        return $sh->getScopeVariables(false);
    }
}

if (!\function_exists('Psy\\info')) {
    /**
     * Get a bunch of debugging info about the current PsySH environment and
     * configuration.
     *
     * If a Configuration param is passed, that configuration is stored and
     * used for the current shell session, and no debugging info is returned.
     *
     * @param Configuration|null $config
     *
     * @return array|null
     */
    function info(Configuration $config = null)
    {
        static $lastConfig;
        if ($config !== null) {
            $lastConfig = $config;

            return;
        }

        $prettyPath = function ($path) {
            return $path;
        };

        $homeDir = (new ConfigPaths())->homeDir();
        if ($homeDir && $homeDir = \rtrim($homeDir, '/')) {
            $homePattern = '#^'.\preg_quote($homeDir, '#').'/#';
            $prettyPath = function ($path) use ($homePattern) {
                if (\is_string($path)) {
                    return \preg_replace($homePattern, '~/', $path);
                } else {
                    return $path;
                }
            };
        }

        $config = $lastConfig ?: new Configuration();
        $configEnv = (isset($_SERVER['PSYSH_CONFIG']) && $_SERVER['PSYSH_CONFIG']) ? $_SERVER['PSYSH_CONFIG'] : false;
        if ($configEnv === false && \PHP_SAPI === 'cli-server') {
            $configEnv = \getenv('PSYSH_CONFIG');
        }

        $shellInfo = [
            'PsySH version' => Shell::VERSION,
        ];

        $core = [
            'PHP version'         => \PHP_VERSION,
            'OS'                  => \PHP_OS,
            'default includes'    => $config->getDefaultIncludes(),
            'require semicolons'  => $config->requireSemicolons(),
            'strict types'        => $config->strictTypes(),
            'error logging level' => $config->errorLoggingLevel(),
            'config file'         => [
                'default config file' => $prettyPath($config->getConfigFile()),
                'local config file'   => $prettyPath($config->getLocalConfigFile()),
                'PSYSH_CONFIG env'    => $prettyPath($configEnv),
            ],
            // 'config dir'  => $config->getConfigDir(),
            // 'data dir'    => $config->getDataDir(),
            // 'runtime dir' => $config->getRuntimeDir(),
        ];

        // Use an explicit, fresh update check here, rather than relying on whatever is in $config.
        $checker = new GitHubChecker();
        $updateAvailable = null;
        $latest = null;
        try {
            $updateAvailable = !$checker->isLatest();
            $latest = $checker->getLatest();
        } catch (\Throwable $e) {
        }

        $updates = [
            'update available'       => $updateAvailable,
            'latest release version' => $latest,
            'update check interval'  => $config->getUpdateCheck(),
            'update cache file'      => $prettyPath($config->getUpdateCheckCacheFile()),
        ];

        $input = [
            'interactive mode'  => $config->interactiveMode(),
            'input interactive' => $config->getInputInteractive(),
            'yolo'              => $config->yolo(),
        ];

        if ($config->hasReadline()) {
            $info = \readline_info();

            $readline = [
                'readline available' => true,
                'readline enabled'   => $config->useReadline(),
                'readline service'   => \get_class($config->getReadline()),
            ];

            if (isset($info['library_version'])) {
                $readline['readline library'] = $info['library_version'];
            }

            if (isset($info['readline_name']) && $info['readline_name'] !== '') {
                $readline['readline name'] = $info['readline_name'];
            }
        } else {
            $readline = [
                'readline available' => false,
            ];
        }

        $output = [
            'color mode'       => $config->colorMode(),
            'output decorated' => $config->getOutputDecorated(),
            'output verbosity' => $config->verbosity(),
            'output pager'     => $config->getPager(),
        ];

        $theme = $config->theme();
        // TODO: show styles (but only if they're different than default?)
        $output['theme'] = [
            'compact'      => $theme->compact(),
            'prompt'       => $theme->prompt(),
            'bufferPrompt' => $theme->bufferPrompt(),
            'replayPrompt' => $theme->replayPrompt(),
            'returnValue'  => $theme->returnValue(),
        ];

        $pcntl = [
            'pcntl available' => ProcessForker::isPcntlSupported(),
            'posix available' => ProcessForker::isPosixSupported(),
        ];

        if ($disabledPcntl = ProcessForker::disabledPcntlFunctions()) {
            $pcntl['disabled pcntl functions'] = $disabledPcntl;
        }

        if ($disabledPosix = ProcessForker::disabledPosixFunctions()) {
            $pcntl['disabled posix functions'] = $disabledPosix;
        }

        $pcntl['use pcntl'] = $config->usePcntl();

        $history = [
            'history file'     => $prettyPath($config->getHistoryFile()),
            'history size'     => $config->getHistorySize(),
            'erase duplicates' => $config->getEraseDuplicates(),
        ];

        $docs = [
            'manual db file'   => $prettyPath($config->getManualDbFile()),
            'sqlite available' => true,
        ];

        try {
            if ($db = $config->getManualDb()) {
                if ($q = $db->query('SELECT * FROM meta;')) {
                    $q->setFetchMode(\PDO::FETCH_KEY_PAIR);
                    $meta = $q->fetchAll();

                    foreach ($meta as $key => $val) {
                        switch ($key) {
                            case 'built_at':
                                $d = new \DateTime('@'.$val);
                                $val = $d->format(\DateTime::RFC2822);
                                break;
                        }
                        $key = 'db '.\str_replace('_', ' ', $key);
                        $docs[$key] = $val;
                    }
                } else {
                    $docs['db schema'] = '0.1.0';
                }
            }
        } catch (Exception\RuntimeException $e) {
            if ($e->getMessage() === 'SQLite PDO driver not found') {
                $docs['sqlite available'] = false;
            } else {
                throw $e;
            }
        }

        $autocomplete = [
            'tab completion enabled' => $config->useTabCompletion(),
            'bracketed paste'        => $config->useBracketedPaste(),
        ];

        // Shenanigans, but totally justified.
        try {
            if ($shell = Sudo::fetchProperty($config, 'shell')) {
                $shellClass = \get_class($shell);
                if ($shellClass !== 'Psy\\Shell') {
                    $shellInfo = [
                        'PsySH version' => $shell::VERSION,
                        'Shell class'   => $shellClass,
                    ];
                }

                try {
                    $core['loop listeners'] = \array_map('get_class', Sudo::fetchProperty($shell, 'loopListeners'));
                } catch (\ReflectionException $e) {
                    // shrug
                }

                $core['commands'] = \array_map('get_class', $shell->all());

                try {
                    $autocomplete['custom matchers'] = \array_map('get_class', Sudo::fetchProperty($shell, 'matchers'));
                } catch (\ReflectionException $e) {
                    // shrug
                }
            }
        } catch (\ReflectionException $e) {
            // shrug
        }

        // @todo Show Presenter / custom casters.

        return \array_merge($shellInfo, $core, \compact('updates', 'pcntl', 'input', 'readline', 'output', 'history', 'docs', 'autocomplete'));
    }
}

if (!\function_exists('Psy\\bin')) {
    /**
     * `psysh` command line executable.
     *
     * @return \Closure
     */
    function bin(): \Closure
    {
        return function () {
            if (!isset($_SERVER['PSYSH_IGNORE_ENV']) || !$_SERVER['PSYSH_IGNORE_ENV']) {
                if (\defined('HHVM_VERSION_ID')) {
                    \fwrite(\STDERR, 'PsySH v0.11 and higher does not support HHVM. Install an older version, or set the environment variable PSYSH_IGNORE_ENV=1 to override this restriction and proceed anyway.'.\PHP_EOL);
                    exit(1);
                }

                if (\PHP_VERSION_ID < 70000) {
                    \fwrite(\STDERR, 'PHP 7.0.0 or higher is required. You can set the environment variable PSYSH_IGNORE_ENV=1 to override this restriction and proceed anyway.'.\PHP_EOL);
                    exit(1);
                }

                if (\PHP_VERSION_ID > 89999) {
                    \fwrite(\STDERR, 'PHP 9 or higher is not supported. You can set the environment variable PSYSH_IGNORE_ENV=1 to override this restriction and proceed anyway.'.\PHP_EOL);
                    exit(1);
                }

                if (!\function_exists('json_encode')) {
                    \fwrite(\STDERR, 'The JSON extension is required. Please install it. You can set the environment variable PSYSH_IGNORE_ENV=1 to override this restriction and proceed anyway.'.\PHP_EOL);
                    exit(1);
                }

                if (!\function_exists('token_get_all')) {
                    \fwrite(\STDERR, 'The Tokenizer extension is required. Please install it. You can set the environment variable PSYSH_IGNORE_ENV=1 to override this restriction and proceed anyway.'.\PHP_EOL);
                    exit(1);
                }
            }

            $usageException = null;
            $shellIsPhar = Shell::isPhar();

            $input = new ArgvInput();
            try {
                $input->bind(new InputDefinition(\array_merge(Configuration::getInputOptions(), [
                    new InputOption('help', 'h', InputOption::VALUE_NONE),
                    new InputOption('version', 'V', InputOption::VALUE_NONE),
                    new InputOption('self-update', 'u', InputOption::VALUE_NONE),

                    new InputArgument('include', InputArgument::IS_ARRAY),
                ])));
            } catch (\RuntimeException $e) {
                $usageException = $e;
            }

            try {
                $config = Configuration::fromInput($input);
            } catch (\InvalidArgumentException $e) {
                $usageException = $e;
            }

            // Handle --help
            if (!isset($config) || $usageException !== null || $input->getOption('help')) {
                if ($usageException !== null) {
                    echo $usageException->getMessage().\PHP_EOL.\PHP_EOL;
                }

                $version = Shell::getVersionHeader(false);
                $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : [];
                $name = $argv ? \basename(\reset($argv)) : 'psysh';

                echo <<<EOL
$version

Usage:
  $name [--version] [--help] [files...]

Options:
  -h, --help            Display this help message.
  -c, --config FILE     Use an alternate PsySH config file location.
      --cwd PATH        Use an alternate working directory.
  -V, --version         Display the PsySH version.

EOL;
                if ($shellIsPhar) {
                    echo <<<EOL
  -u, --self-update     Install a newer version if available.

EOL;
                }
                echo <<<EOL
      --color           Force colors in output.
      --no-color        Disable colors in output.
  -i, --interactive     Force PsySH to run in interactive mode.
  -n, --no-interactive  Run PsySH without interactive input. Requires input from stdin.
  -r, --raw-output      Print var_export-style return values (for non-interactive input)
      --compact         Run PsySH with compact output.
  -q, --quiet           Shhhhhh.
  -v|vv|vvv, --verbose  Increase the verbosity of messages.
      --yolo            Run PsySH without input validation. You don't want this.

EOL;

                exit($usageException === null ? 0 : 1);
            }

            // Handle --version
            if ($input->getOption('version')) {
                echo Shell::getVersionHeader($config->useUnicode()).\PHP_EOL;
                exit(0);
            }

            // Handle --self-update
            if ($input->getOption('self-update')) {
                if (!$shellIsPhar) {
                    \fwrite(\STDERR, 'The --self-update option can only be used with with a phar based install.'.\PHP_EOL);
                    exit(1);
                }
                $selfUpdate = new SelfUpdate(new GitHubChecker(), new Installer());
                $result = $selfUpdate->run($input, $config->getOutput());
                exit($result);
            }

            $shell = new Shell($config);

            // Pass additional arguments to Shell as 'includes'
            $shell->setIncludes($input->getArgument('include'));

            try {
                // And go!
                $shell->run();
            } catch (\Throwable $e) {
                \fwrite(\STDERR, $e->getMessage().\PHP_EOL);

                // @todo this triggers the "exited unexpectedly" logic in the
                // ForkingLoop, so we can't exit(1) after starting the shell...
                // fix this :)

                // exit(1);
            }
        };
    }
}
.is-phone .hide-is-mobile {
	display: none;
}
/* Header menu-nav START */
header .nav-mobile2 {
	float: none;
}

header .nav-mobile2 .fake-select-header-language-chooser {
	float: left;
}

header .nav-mobile1 .nav-button-mobile,
header .nav-mobile2 .nav-button-mobile {
	display: inherit;
}
header .nav-mobile1 .nav-button-mobile-small,
header .nav-mobile2 .nav-button-mobile-small {
	padding: 0 15px;
}
header .nav-mobile2 .nav-button-mobile-small .icon,
header .nav-mobile2 .fake-select-header-language-chooser-small .icon {
	display: none;
}
header .nav-mobile2 .fake-select-header-language-chooser-small {
	margin-left: 0;
}
header .nav-mobile2 .fake-select-header-language-chooser-small .first {
	padding: 0 5px;
}
header .nav-mobile2 .fake-select-header-language-chooser-small .first .text {
	padding: 0;
}
header .nav-mobile1 .fake-select-header-language-chooser .options,
header .nav-mobile2 .fake-select-header-language-chooser .options {
	left: 0;
	right: auto;
}

header .nav-mobile2 .nav-button-mobile {
	margin-right: 5px;
}

header .nav-mobile1 .main-nav,
header .nav-mobile2 .main-nav {
	display: none;
	padding: 0;
	width: 200px;
	position: absolute;
	left: 0;
	top: 47px;
	background: #fff;
	-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;
	-webkit-box-shadow: 3px 3px 5px 0px rgba(184,195,217,0.6);
	-moz-box-shadow: 3px 3px 5px 0px rgba(184,195,217,0.6);
	box-shadow: 3px 3px 5px 0px rgba(184,195,217,0.6);
	border: 1px solid #e6eaf2;
}
header .nav-mobile2 .main-nav {
	position: relative;
	display: block;
	width: 100%;
	top: auto;
}
header .nav-mobile1 .main-nav li,
header .nav-mobile2 .main-nav li {
	width: 100%;
	padding: 0;
	margin: 0;
	border-bottom: 1px solid #e6eaf2;
	position: relative;
}
header .nav-mobile1 .main-nav li:last-child,
header .nav-mobile2 .main-nav li:last-child {
	border-bottom: none;
}
header .nav-mobile1 .main-nav li a,
header .nav-mobile2 .main-nav li a {
	padding: 0 10px;
	display: block;
	font-size: 1.1em;
	line-height: 2.8em;
	color: #49586a;
}
header .nav-mobile1 .main-nav li a:hover,
header .nav-mobile2 .main-nav li a:hover {
	background: #22a4e6;
	color: #fff;
}
header .nav-mobile2 .main-nav li a {
	-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;
}
header .nav-mobile1 .main-nav li a:hover .icon,
header .nav-mobile2 .main-nav li a:hover .icon {
	color: #fff;
}
header .nav-mobile1 .main-nav ul {
	left: -200px; top: 0;
	margin: 0;
}
header .nav-mobile2 .main-nav ul {
	display: none;
	position: relative;
	width: 100%;
	left: 0;
	right: 0;
	top: auto;
	padding-left: 25px;
	box-shadow: none;
	border-top: none;
}
header .nav-mobile2 .main-nav li:hover ul {
	display: none;
}

header .header-content-mobile {
	padding-top: 10px;
}
header .header-content-mobile .logo {
	padding-top: 10px;
	max-width: 100%;
	width: 100%;
	text-align: center;
}
header .header-content-mobile .logo img {
	max-width: 100%;
}

header .header-content-mobile .header-widget {
	width: 100%;
	text-align: center;
	margin-top: 20px;
}
/* Header menu-nav END */

/* Header user-nav START */
header .header-content-mobile .user-menu-small .user-info {
	padding-left: 5px;
}
/* Header user-nav END */


/* Admin menu START */
.is-phone .admin-menu-mobile {
	-webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px;
	border-right: none;
	border-left: none;
	border-top: none !important;
}
.admin-menu-mobile ul:first-child,
.admin-menu-mobile-first ul:first-child {
	width: 100%;
}
.admin-menu-mobile .top,
.admin-menu-mobile-first .top {
	width: 25%;
}
.admin-menu-mobile-first li.top .top-a {
	width: 100%;
	text-align: center;
}
.admin-menu-mobile li.top .top-a {
	width: 100%;
	text-align: center;
	line-height: 1.3em;
	padding: 5px 0;
}
.admin-menu-mobile .top-a .text-short {
	font-size: 0.9em;
	display: block !important;
}
.admin-menu-mobile li.top .top-a .icon {
	margin: 0;
}
.admin-menu-mobile li .sub-menu {
	top: 3.1em;
}
/* Admin menu END */


/* Login Box START */
@media all and (max-width: 830px) {
	.login-box {
		width: 480px;
	}
	.login-box .form {
		width: 100% !important;
	}
	.login-box-wrapper .message,
	.login-box-wrapper .summary {
		display: none;
	}
}
@media all and (max-width: 520px) {
	.login-box {
		padding: 20px;
	}
	.login-box {
		width: 100%;
	}
	.login-box-wrapper {
	}
	.login-box-wrapper .message,
	.login-box-wrapper .summary {
		display: none;
	}
}
@media all and (max-width: 520px) {
	.login-box {
		padding: 0;
	}
}
@media all and (max-width: 330px) {
	.login-box {
		padding: 0;
	}
	.login-box .form {
		padding: 15px;
	}
}
/* Login Box END */

/* Search and "post new ad" button START */
header .nav2-mobile1 {
	text-align: center;
}
header .nav2-mobile1 .clear-mobile1 {
	display: block;
}
.nav2-mobile1 .header-search {
	display: inline-block;
	float: none;
}
.nav2-mobile1 .postnew-button {
	display: inline-block;
	float: none;
	margin-top: 10px;
}
header .nav2-mobile2 .clear-mobile2 {
	display: block;
	clear: both;
}
header .nav2-mobile2 .header-search {
	width: 100%;
}
header .nav2-mobile2 .keyword-box-wrapper {
	padding-bottom: 10px;
}

header .nav2-mobile2 .header-search .fake-select-header-category-chooser {
	margin-right: 0;
}
.is-phone header .header-search .fake-select-header-category-chooser .options {
	right: 0;
	left: auto;
}
/* Search and "post new ad" button END */

/* Loop view START */
.is-phone .items-loop,
.is-phone .user-items {
	background: #fff;
}
.is-phone .items-loop .loop {
	background: #e6eaf2;
	padding: 20px 10px;
	-webkit-border-radius: 7px;
	-moz-border-radius: 7px;
	border-radius: 7px;
}
.is-phone .items-loop .loop .loop-title-bar-container,
.is-phone .user-items .loop .loop-title-bar-container {
	background: #fff;
}
.is-phone .items-loop .loop .loop-title-bar .label,
.is-phone .user-items .loop .loop-title-bar .label {
	display: none;
}
.is-phone .items-loop .loop .item,
.is-phone .user-items .loop .item {
	background: #fff;
	margin: 20px 0;
	padding: 0;
}
.is-phone .items-loop .loop .item .loop-item-details,
.is-phone .items-loop .loop .item .img-link,
.is-phone .items-loop .loop .item .img-link .img,
.is-phone .user-items .loop .item .loop-item-details,
.is-phone .user-items .loop .item .img-link,
.is-phone .user-items .loop .item .img-link .img {
	width: 100%;
}
.is-phone .items-loop .loop .item .img-link .img,
.is-phone .user-items .loop .item .img-link .img {
	margin-bottom: 0;
	border: none;
	-webkit-border-radius: 0px;
	-moz-border-radius: 0px;
	border-radius: 0px;
	-webkit-border-bottom-right-radius: 3px;
	-webkit-border-bottom-left-radius: 3px;
	-moz-border-radius-bottomright: 3px;
	-moz-border-radius-bottomleft: 3px;
	border-bottom-right-radius: 3px;
	border-bottom-left-radius: 3px;
}
.is-phone .items-loop .loop .item .img-link .img:hover,
.is-phone .user-items .loop .item .img-link .img:hover {
	border: none;
}
.is-phone .items-loop .loop .item .loop-item-details,
.is-phone .user-items .loop .item .loop-item-details {
	padding: 15px;
	padding-bottom: 20px;
}
.is-phone .items-loop .loop .item .loop-item-details .entry-text,
.is-phone .user-items .loop .item .loop-item-details .entry-text {
	display: none;
}
/* Loop view END */

/* Loop view2 START */
.is-phone .items-loop .loop .item2,
.is-phone .user-items .loop .item2 {
	width: 100%;
	margin: 10px 0;
	background: #fff;
}
.is-phone .loop .item2.highlighted-item {
	background: #22a4e6;
}
/* Loop view2 END */

/* Sidebar START */
.is-phone .mobile-sidebar .sortable-fields {
/*	padding-top: 20px;
	padding-left: 10px;*/
	padding: 10px;
	width: 100%;
	float: left;
}
.is-phone .mobile-sidebar .sortable-fields .sortable {
	/*margin: 3px 0;*/
}
.is-phone .mobile-sidebar .sortable-fields .sortable h4 {
	cursor: pointer;
	-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;
	border: 1px solid #cfd6e6;
	line-height: 2.7em;
	padding: 0 10px;
	margin-bottom: 5px;
}
.is-phone .mobile-sidebar .sortable-fields .sortable h4:hover {
	border: 1px solid #22a4e6;
	background: #f5f7fa;
}

.is-phone .mobile-sidebar .sortable-fields .sortable.active-sortable-field {
	-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;
	border: 1px solid #cfd6e6;
	margin-bottom: 5px;
}
.is-phone .mobile-sidebar .sortable-fields .sortable.active-sortable-field h4 {
	border-color: transparent;
}

.is-phone .mobile-sidebar .sortable-fields .sortable li {
	list-style: none;
}
.is-phone .mobile-sidebar .sortable-fields .sortable li a{
	line-height: 2em;
}
.is-phone .mobile-sidebar .sortable-fields .sortable .hide-sortable-in-mobile {
	padding-bottom: 10px;
	padding-left: 10px;
	display: none;
	width: 100%;
	float: left;
}
.is-phone .mobile-sidebar .sortable-fields .sortable .icon-show-in-mobile {
	display: inline-block;
}
.is-phone .mobile-sidebar .sortable-fields .sortable .sorting-icon-mobile {
	padding-right: 4px;
	color: #22a4e6;
}
.is-phone .mobile-sidebar .sortable-fields .sortable .show-more-filters {
	display: none;
}
.is-phone .mobile-sidebar .above-sidebar-all-pages,
.is-phone .mobile-sidebar .under-sidebar-all-pages {
	width: 100%;
	text-align: center;
}
/* Sidebar END */

/* Pagination START */
.is-phone .pagination-wrapper {
	background: #fff;
}
.is-phone .pagination-wrapper .pagination .page-numbers {
	padding: 4px 12px;
}
/* Pagination END */



/* Post new ad page START */
.is-phone.page-template-user-post-new-ad .nav2,
.is-phone.page-template-user-post-new-ad footer {
	display: none;
}
.is-phone.page-template-user-post-new-ad .content {
	padding: 0;
}
.is-phone .post-new-ad .ad-step-wrapper {
	padding: 0;
	font-size: 1em;
	overflow: hidden;
}
.is-phone .post-new-ad .for-desktop {
	display: none;
}
.is-phone .post-new-ad .for-mobile {
	display: inherit;
}
.is-phone .post-new-ad .ad-step,
.is-phone .post-new-ad .steps .step {
	width: 100% !important;
}
.is-phone .post-new-ad .steps .step2 {
	padding-bottom: 20px;
}
.is-phone .post-new-ad .selected-category .selected-category-bold {
	display: block;
}
.is-phone .post-new-ad .selected-category .form-label .change-category {
	padding: 10px 0;
}
.is-phone .post-new-ad .selected-category .form-input .change-category {
	display: none;
}
.is-phone .post-new-ad .selected-category .form-label,
.is-phone .post-new-ad .selected-category .form-input,
.is-phone .post-new-ad .generated-form-fields .form-label,
.is-phone .post-new-ad .generated-form-fields .form-input {
/*.is-phone .post-new-ad .generated-form-fields .form-fields-group {*/
	width: 100% !important;
}
/* Post new ad page END */

/* Item page START */
.is-phone .item-page .entry .item-details,
.is-phone .item-page .entry .item-details3,
.is-phone .item-page .entry .seller-and-report,
.is-phone .item-page .entry .item-images {
	width: 100%;
	margin: 0;
}
.is-phone .item-page .entry .item-details3 {
	border: none;
}
.single.is-phone .content {
	padding: 0;
}
.is-phone .item-page .page-section {
	padding: 10px;
}
.is-phone .item-page .entry {
	padding-top: 30px;
}
.is-phone .item-page .edit-ad-menu {
	-webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px;
	border-right: none;
	border-left: none;
}
.is-phone .item-page .edit-ad-menu .edit-ad-buttons {
	width: 100%;
}
.is-phone .item-page .edit-ad-menu .edit-ad-buttons .for-admin,
.is-phone .item-page .edit-ad-menu .edit-ad-buttons .for-user {
	padding: 10px 0;
}
.is-phone .item-page .edit-ad-menu .edit-ad-buttons .for-admin {
	width: 16.666%;
}
.is-phone .item-page .edit-ad-menu .edit-ad-buttons .for-user {
	width: 20%;
}
.is-phone .item-page .edit-ad-menu .edit-ad-buttons .for-admin .text,
.is-phone .item-page .edit-ad-menu .edit-ad-buttons .for-user .text {
	font-size: 0.8em;
}
.is-phone .item-page .edit-ad-menu .stats {
	width: 100%;
	padding-top: 5px;
	padding-bottom: 5px;
	border-top: 1px solid #e6eaf2;
}
.is-phone .item-page .edit-ad-menu .one-stat {
	width: 25%;
	font-size: 0.9em;
}
.is-phone .item-page .entry .item-conditions {
	height: auto;
	padding-top: 20px;
}
.is-phone .item-page .entry .item-details {
	padding: 0;
}
.is-phone .item-page .entry .seller-and-report {
	/*display: none;*/
	width: 100%;
	background: #f5f7fa;
	padding: 10px;
	border: none;
	margin: 10px 0;
	-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;
}
.is-phone .item-page .entry .seller-and-report-mobile {
	display: inherit;
}
.is-phone .item-page .entry .seller-info {
	padding: 0;
	/*padding-bottom: 20px;*/
	text-align: center;
}
.is-phone .item-page .entry .seller-info .seller-link {
	text-align: left;
	display: inline-block;
}
.is-phone .item-page .entry .seller-info .seller-link .member-since {
	white-space: nowrap;
	width: 100%;
	text-align: center;
	display: inline-block;
}
.is-phone .item-page .entry .seller-info .phone-number {
	display: inline-block;
}
.is-phone .item-page .entry .seller-info .save-print-report {
	display: inline-block;
}

.is-phone .item-page .edit-entry-content {
	width: 100% !important;
	padding: 40px 0;
}
.is-phone .item-page .buy-upgrades .ad-needs-payment-section {
	padding: 0;
	padding-top: 20px;
}
.is-phone .item-page .buy-upgrades .ad-needs-payment-section .payment-products {
	width: 100% !important;
	padding: 12px 0;
}
.is-phone .item-page .buy-upgrades .ad-needs-payment-section .payment-products .payment-buttons {
	padding: 0;
}

.is-phone .item-page .entry .swiper-container {
	display: block;
	clear: both;
	margin: 0 -10px;
	background: #f5f7fa;
	padding: 15px 0;
}
.is-phone .item-page .entry .swiper-container .swiper-pagination {
}
.is-phone .item-page .entry .swiper-container .swiper-slide {
	width: 100%;
	text-align: center;
}
.is-phone .item-page .entry .swiper-container .swiper-button-disabled {
	display: none;
}
.is-phone .item-page .entry .item-images {
	display: none;
}

.is-phone .item-page .entry .seller-info .phone-number {
	margin-top: 20px;
}

.is-phone .item-page .entry .item-specifications .specification {
	width: 33.33% !important;
	overflow: hidden;
}
.is-phone .item-page .entry .item-specifications .specification.pc-100 {
	width: 100% !important;
}
.is-phone .private-message-form {
	padding-bottom: 30px;
}
/* Item page END */


/* Settings pages START */
.is-phone.page-template-admin-site-settings .content,
.is-phone.page-template-user-edit-account .content,
.is-phone.page-template-admin-ad-management .content,
.is-phone.page-template-admin-email-settings .content,
.is-phone.page-template-admin-payment-settings .content,
.is-phone.page-template-admin-private-messages-settings .content,
.is-phone.page-template-admin-form-builder-settings .content,
.is-phone.page-template-admin-category-settings .content,
.is-phone.page-template-admin-user-settings .content,
.is-phone.page-template-admin-ad-settings .content,
.is-phone.page-template-admin-language-settings .content,
.is-phone.page-template-user-private-messages-inbox .content,
.is-phone.page-template-admin-demo-data .content,
.is-phone.page-template-admin-auto-classifieds .content {
	padding-top: 0;
}
.is-phone.page-template-admin-site-settings .settings-page,
.is-phone.page-template-admin-ad-management .settings-page,
.is-phone.page-template-admin-email-settings .settings-page,
.is-phone.page-template-admin-payment-settings .settings-page,
.is-phone.page-template-admin-private-messages-settings .settings-page,
.is-phone.page-template-admin-user-settings .settings-page,
.is-phone.page-template-admin-form-builder-settings .settings-page {
	width: 100% !important;
}
.is-phone.page-template-admin-site-settings .settings-page .form-styling .form-label,
.is-phone.page-template-admin-site-settings .settings-page .form-styling .form-input,
.is-phone.page-template-user-edit-account .settings-page .form-styling .form-label,
.is-phone.page-template-user-edit-account .settings-page .form-styling .form-input,
.is-phone.page-template-admin-ad-management .settings-page .form-styling .form-label,
.is-phone.page-template-admin-ad-management .settings-page .form-styling .form-input,
.is-phone.page-template-admin-ad-settings .settings-page .form-styling .form-label,
.is-phone.page-template-admin-ad-settings .settings-page .form-styling .form-input,
.is-phone.page-template-admin-user-settings .settings-page .form-styling .form-label,
.is-phone.page-template-admin-user-settings .settings-page .form-styling .form-input,
.is-phone.page-template-admin-email-settings .settings-page .form-styling .form-label,
.is-phone.page-template-admin-email-settings .settings-page .form-styling .form-input,
.is-phone.page-template-admin-payment-settings .settings-page .form-styling .form-label,
.is-phone.page-template-admin-payment-settings .settings-page .form-styling .form-input,
.is-phone.page-template-admin-private-messages-settings .settings-page .form-styling .form-label,
.is-phone.page-template-admin-private-messages-settings .settings-page .form-styling .form-input,
.is-phone.page-template-admin-auto-classifieds .settings-page .form-styling .form-label,
.is-phone.page-template-admin-auto-classifieds .settings-page .form-styling .form-input {
	width: 100%;
}

.is-phone .settings-page.edit-account {
	padding: 20px 10px;
}
.is-phone.page-template-admin-form-builder-settings .form-builder {
	padding: 0 10px;
}
.is-phone.page-template-admin-category-settings .edit-categories {
	padding: 0 10px;
}
.is-phone.page-template-admin-category-settings .edit-categories .cat-list,
.is-phone.page-template-admin-category-settings .edit-categories .add-cat {
	width: 100% !important;
}
.is-phone.page-template-admin-category-settings .edit-categories .add-cat {
	padding: 0;
	padding-top: 30px;
}
.is-phone.page-template-admin-category-settings .edit-categories .all-icons .icon-list {
	padding: 0 10px;
}
.is-phone.page-template-admin-category-settings .edit-categories .all-icons .top-frame {
	padding-bottom: 10px;
}

.is-phone.page-template-admin-payment-settings .payment-settings .settings-form .upgrade {
	background: #f5f7fa;
}

.is-phone.page-template-user-private-messages-inbox .inbox {
	padding: 0 10px;
}
.is-phone.page-template-user-private-messages-inbox .messages-wrapper,
.is-phone.page-template-user-private-messages-inbox .conversation-wrapper {
	width: 100% !important;
	padding: 0;
}
/* Settings pages END */

/* Inbox page START */
.is-phone .inbox {
	padding-top: 20px !important;
}
.is-phone .inbox .messages-wrapper {
	margin-bottom: 20px;
}
.is-phone .inbox .messages-inbox {
	height: auto !important;
	max-height: 350px;
}
.is-phone .inbox .messages .messages-inbox .no-messages {
	font-size: 1.3em;
	color: #49586a;
}
.is-phone .inbox .messages-inbox .no-messages .icon {
	display: none;
}
.is-phone .inbox .messages-inbox .one-message .item-img .clear20 {
	height: 10px;
}
.is-phone .inbox .messages-inbox .one-message .item-img .img {
	width: 110px;
	float: right;
}
/* Inbox page END */

/* Author page START */
.is-phone.author .content {
	background: #e6eaf2;
	padding: 20px 10px;
}
.is-phone .author-page {
	width: 100%;
}
.is-phone .author-page .loop-title-bar {
	background: #fff;
}
.is-phone .author-page .user-items {
	background: #e6eaf2;
}
.is-phone .author-page .user-items .loop-title-bar h3 span.text {
	display: none;
}
.is-phone .author-page .loop {
	padding: 0;
}
.is-phone .author-page .user-items-wrapper2 {
	margin: 0;
}
.is-phone .author-page .user-items-wrapper2 .user-items {
	padding: 0;
}
.is-phone .author-page .user-items-wrapper2 .user-items .item .item-meta {
	padding-top: 10px;
}
.is-phone .author-page .seller-and-reviews {
	width: 100%;
	margin: 0;
}
.is-phone .author-page .seller-and-reviews .seller-and-reviews-inner-wrapper {
	/*background: #fff;*/
	/*padding: 10px;*/
}
.is-phone .author-page .seller-and-reviews .seller-info {
	/*background: #fff;*/
	padding: 10px;
}
.is-phone .author-page .author-page .latest-reviews {
	background: none;
}
.is-phone .author-page .seller-and-reviews-mobile {
	/*background: #fff;*/
	margin: 0;
	margin-bottom: 20px;
	display: inherit;
}
.is-phone .author-page .author-reviews-section {
	margin-top: 20px;
	padding: 10px;
	background: #fff;
}
.is-phone .author-page .author-reviews-section h3 {
	text-align: center;
	margin-bottom: 10px;
}
.is-phone .author-page .author-reviews-section .review {
	border-color: #22a4e6;
}
.is-phone .author-page .author-reviews-section .review .seller-reply {
	border: 1px solid #e6eaf2;
}
.is-phone .author-page .add-user-review {
	background: #fff;
	padding: 10px;
	margin-top: 20px;
}
.is-phone .author-page {}
.is-phone .author-page {}
.is-phone .author-page {}
/* Author page END */

/* Blog page START */
.is-phone .theme-blog {
	padding: 20px 10px;
}

.is-phone .comments-section .comments-list-all {
	width: 100%;
}
.is-phone .comments-section .comments-list-all .comment-textarea-wrapper .label {
	width: 100%;
}
/* Blog page END */

@media all and (max-width: 1400px) {
	.admin-menu {
		margin-right: 0px;
	}
	.all {
		padding: 0 10px;
	}
	header .header-content {
		padding-left: 10px;
		padding-right: 10px;
	}
	.sidebar {
		/*padding-left: 10px;*/
	}
	.sidebar .categories ul li a {
		padding-left: 0;
	}
}
@media all and (max-width: 1350px) {
	.item-page .item-images {
		float: left;
		width: 500px;
		margin-left: -100%;
		height: 400px;
	}
	.item-page .item-details {
		margin-left: 500px;
	}
}
@media all and (max-width: 1250px) {
	.item-page .item-images {
		width: 450px;
		height: 400px;
	}
	.item-page .item-details {
		margin-left: 450px;
	}

		.item-page .item-details3 {
		margin-right: 300px;
	}
	.item-page .seller-and-report {
		width: 300px;
		margin-left: -300px;
	}

	.settings-page, .theme-documentation {
		width: 100% !important;
	}

	.author-page .seller-and-reviews {
		width: 300px;
	}
	.author-page .user-items-wrapper2 {
		margin-left: 300px;
	}
}
@media all and (max-width: 1170px) {
		.content {
		margin-left: 270px;
	}
	.sidebar {
		width: 270px;
	}
}
@media all and (max-width: 1100px) {
	.author-page.change-account-type-page .choose-user-type-plans .user-type-column .column-icon,
	.author-page.change-account-type-page .choose-user-type-plans .user-type-column .column-benefits {
		float: none;
		width: 100%;
	}
	.author-page.change-account-type-page .choose-user-type-plans .user-type-column .column-icon {
		padding: 30px 0 0 0;
	}
	.author-page.change-account-type-page .choose-user-type-plans .user-type-column .column-icon img {
		max-width: 200px;
	}
}
@media all and (max-width: 1070px) {
	.item-page .item-images {
		width: 300px;
		height: 350px;
	}
	.item-page .item-details {
		margin-left: 300px;
	}

		.item-page .item-details3 {
		margin-right: 270px;
	}
	.item-page .seller-and-report {
		width: 270px;
		margin-left: -270px;
	}

	.author-page .seller-and-reviews {
		width: 270px;
	}
	.author-page .user-items-wrapper2 {
		margin-left: 270px;
	}
}
@media all and (max-width: 1000px) {
	.loop .item2 {
		width: 50%;
	}

	.author-page.change-account-type-page .choose-user-type-plans .user-type-column.user-type-column-personal {
		padding-right: 10px;
	}
	.author-page.change-account-type-page .choose-user-type-plans .user-type-column.user-type-column-business {
		padding-left: 10px;
	}
}
@media all and (max-width: 970px) {
	.language-settings .language-edit-buttons {
		width: 100%;
		padding-top: 10px;
		text-align: center;
	}
	.language-settings .language-edit-buttons .round-corners-button {
		float: none;
		display: inline-block;
	}
}
@media all and (max-width: 900px) {
		.all {
		padding: 0;
	}
	.content {
		margin-left: 250px;
	}
	.sidebar {
		width: 250px;
	}

	.content {
		margin: 0;
		border: none;
		padding: 0px;
	}
	.sidebar {
		margin: 0;
		width: 100%;
	}
	.admin-menu {
		margin-right: 0;
	}

	.author-page {
		display: table;
	}
	.author-page .user-items-wrapper {
		display: table-footer-group;
		float: none;
	}
	.author-page .seller-and-reviews {
		display: table-header-group;
		float: none;
	}
	.author-page .seller-and-reviews .seller-info {
		background: #fff
	}
	.author-page .seller-and-reviews .latest-reviews {
		padding: 0;
		padding-bottom: 40px;
	}
}
@media all and (max-width: 700px) {
	.report-ad-popup {
		width: 100%;
	}

	.author-page.change-account-type-page .choose-user-type-plans .user-type-column.user-type-column-personal,
	.author-page.change-account-type-page .choose-user-type-plans .user-type-column.user-type-column-business {
		width: 100%;
		padding: 10px 0;
	}
	.author-page.change-account-type-page .choose-user-type-plans .user-type-column .column-icon {
		float: right;
		width: 50%;
		padding-left: 10px;
	}
	.author-page.change-account-type-page .choose-user-type-plans .user-type-column .column-icon img {
		max-width: 100%;
	}
	.author-page.change-account-type-page .choose-user-type-plans .user-type-column .column-benefits {
		float: left;
		width: 50%;
	}

	.post-form .uploaded-images .one-img {
		width: 33.3%;
	}
}
@media all and (max-width: 550px) {
	.is-phone .inbox .conversation .conversation-history .reply {
		margin-bottom: 25px;
		width: 100% !important;
	}
	.is-phone .inbox .conversation .conversation-history .reply .reply-text {
		width: 80% !important;
	}
	.is-phone .inbox .conversation .conversation-history .reply.reply-sent .reply-text {
		float: right;
	}
	.is-phone .inbox .conversation .conversation-history .reply.reply-received .reply-text {
		float: left;
	}

	.is-phone .inbox .conversation .conversation-history .reply .reply-text .pm-image-wrapper {
		width: 25%;
	}

	.is-phone .inbox .conversation .write-reply .uploaded-images-queue .pm-image-wrapper {
		width: 20%;
	}
	.author-page .author-reviews-section .review-text-wrapper .seller-detailed-reviews {
		float: none;
		width: 100%;
		margin: 0;
		padding-bottom: 20px;
	}

	.is-phone .language-settings .add-new-language .add-new-language-form .form-label,
	.is-phone .language-settings .add-new-language .add-new-language-form .form-input {
		width: 100%;
	}
}
@media all and (max-width: 520px) {
	.is-phone .item-page .entry .item-specifications {
		padding: 0;
	}
	.is-phone .item-page .entry .item-specifications .specification {
		width: 50% !important;
		overflow: hidden;
	}

	.post-form .uploaded-images .one-img {
		width: 50%;
	}
}
@media all and (max-width: 480px) {
	footer .dolce-footer-link {
		position: relative;
		margin: 0 auto;
		margin-top: 20px;
	}
}
@media all and (max-width: 470px) {
	.report-ad-popup .form-input,
	.report-ad-popup .form-label {
		width: 100%;
	}
	.report-ad-popup {
		padding: 10px;
	}
	.report-ad-popup form {
		overflow: auto;
	}
	.report-ad-popup .formseparator {
		height: 10px;
	}
}
@media all and (max-width: 450px) {
	.page-404 .title-404 {
		font-size: 8em;
	}

	.is-phone .inbox .conversation .conversation-history .reply .reply-text .pm-image-wrapper {
		width: 33.33%;
	}
}
@media all and (max-width: 420px) {
	.is-phone .inbox .messages .messages-inbox .one-message {
		padding: 10px 0;
	}
	.is-phone .inbox .messages .messages-inbox .message-text {
		margin-right: 0;
		padding-right: 10px;
	}
	.is-phone .inbox .messages .messages-inbox .item-img {
		float: none;
		width: auto;
		margin: 0;
		padding-right: 10px;
	}

	.is-phone .inbox .conversation .write-reply .uploaded-images-queue .pm-image-wrapper {
		width: 25%;
	}
}
@media all and (max-width: 350px) {
	.is-phone .item-page .entry .item-specifications .specification {
		width: 100% !important;
	}

	.is-phone .inbox .conversation .conversation-history .reply .reply-text .pm-image-wrapper {
		width: 50%;
	}
}
@media all and (max-width: 320px) {
	.is-phone .inbox .conversation .write-reply .uploaded-images-queue .pm-image-wrapper {
		width: 33.33%;
	}
}
@media all and (max-width: 300px) {
	.page-404 .title-404 {
		font-size: 6em;
	}
}
@media all and (max-width: 200px) {
	.page-404 .title-404 {
		font-size: 4em;
	}
}