<!DOCTYPE html>
<html lang="<?php echo Translator::locale(); ?>" dir="<?php echo Translator::direction(); ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo htmlspecialchars(strip_tags(html_entity_decode(isset($pageTitle) ? $pageTitle : $_siteName, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8'); ?></title>
    <meta name="description" content="<?php echo htmlspecialchars(isset($metaDescription) ? $metaDescription : $_siteDescription); ?>">
    <?php echo SEO::renderHead(get_defined_vars()); ?>
    <?php if (!empty($_siteFavicon)): ?>
    <link rel="icon" href="/uploads/branding/<?php echo htmlspecialchars($_siteFavicon); ?>">
    <?php endif; ?>
    <?php
         
         
         
        $_mediaBase = MediaStorage::mediaUrl(MediaStorage::defaultId());
        if ($_mediaBase) {
            $_mp = parse_url($_mediaBase);
            if (!empty($_mp['host']) && strcasecmp($_mp['host'], $_SERVER['HTTP_HOST'] ?? '') !== 0) {
                echo '    <link rel="preconnect" href="' . htmlspecialchars(($_mp['scheme'] ?? 'https') . '://' . $_mp['host'], ENT_QUOTES) . '" crossorigin>' . "\n";
            }
        }
    ?>
    <link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
    <?php echo ThemeRenderer::renderCSS(); ?>
    
    <link rel="stylesheet" href="/assets/fontawesomepro/css/all.min.css" media="print" onload="this.media='all'">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flag-icons@7.3.2/css/flag-icons.min.css" media="print" onload="this.media='all'">
    <noscript><link rel="stylesheet" href="/assets/fontawesomepro/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flag-icons@7.3.2/css/flag-icons.min.css"></noscript>
    <?php echo $_colorOverrides; ?>
    <script>window._t = <?php echo Translator::jsTranslations(); ?>;window._langPrefix = <?php echo json_encode(Router::langPrefix()); ?>;window._typePrefix = <?php echo json_encode(Router::typePrefix()); ?>;</script>
    <script>(function(){var en=<?= json_encode(!empty($_darkModeEnabled)) ?>,df=<?= json_encode($_darkModeDefault ?? 'light') ?>;if(!en){document.documentElement.setAttribute('data-theme',df);return;}var t=localStorage.getItem('theme');if(!t)t=df;document.documentElement.setAttribute('data-theme',t);})()</script>
    <?php HookSystem::doAction('head.meta'); ?>
    <?php if ($_captchaProvider !== 'none' && $_captchaSiteKey !== ''): ?>
    <?php echo Captcha::scriptTag(); ?>
    <?php endif; ?>
</head>
<?php $_currentPath = rtrim(strtok($_SERVER['REQUEST_URI'] ?? '/', '?'), '/') ?: '/'; ?>
<body class="cols-<?php echo isset($_videosPerRow) ? (int) $_videosPerRow : 5; ?> cat-<?php echo isset($_categoriesPerRow) ? (int) $_categoriesPerRow : 5; ?> perf-<?php echo isset($_performersPerRow) ? (int) $_performersPerRow : 5; ?> channel-<?php echo isset($_channelsPerRow) ? (int) $_channelsPerRow : 5; ?><?php if (isset($_cardThumbnailHover) && !$_cardThumbnailHover): ?> no-thumb-hover<?php endif; ?> title-lines-<?php echo isset($_cardTitleLines) ? (int) $_cardTitleLines : 1; ?> alb-<?php echo isset($_albumsPerRow) ? (int) $_albumsPerRow : 5; ?> alb-title-<?php echo isset($_albumCardTitleLines) ? (int) $_albumCardTitleLines : 2; ?><?php if (isset($_albumCardHover) && !$_albumCardHover): ?> alb-no-hover<?php endif; ?> <?php echo ThemeRenderer::bodyClass(); ?>">

    <?php if (!empty($_topbarEnabled) && (!empty($_topbarText) || !empty($_topbarLinks))): ?>
    <?php
         
        $tbTextStyle = '';
        if (!empty($_topbarTextBold)) $tbTextStyle .= 'font-weight:bold;';
        if (!empty($_topbarTextItalic)) $tbTextStyle .= 'font-style:italic;';
        $tbLinkStyle = '';
        if (!empty($_topbarLinkBold)) $tbLinkStyle .= 'font-weight:bold;';
        if (!empty($_topbarLinkItalic)) $tbLinkStyle .= 'font-style:italic;';
        if (!empty($_topbarLinkUnderline)) $tbLinkStyle .= 'text-decoration:underline;';
    ?>
    <style>
    .topbar{background:var(--topbar-bg, var(--bg-card));color:var(--topbar-text, var(--text));}
    <?php if (!empty($_topbarBgColor)): ?>:root{--topbar-bg:<?= htmlspecialchars($_topbarBgColor) ?>;}<?php endif; ?>
    <?php if (!empty($_topbarTextColor)): ?>:root{--topbar-text:<?= htmlspecialchars($_topbarTextColor) ?>;}<?php endif; ?>
    <?php if (!empty($_topbarDarkBgColor)): ?>[data-theme="dark"]{--topbar-bg:<?= htmlspecialchars($_topbarDarkBgColor) ?>;}<?php endif; ?>
    <?php if (!empty($_topbarDarkTextColor)): ?>[data-theme="dark"]{--topbar-text:<?= htmlspecialchars($_topbarDarkTextColor) ?>;}<?php endif; ?>
    <?php if (!empty($_topbarHoverTextColor)): ?>.topbar__link:hover{color:<?= htmlspecialchars($_topbarHoverTextColor) ?> !important;opacity:1}<?php endif; ?>
    <?php if (!empty($_topbarLinkHoverUnderline)): ?>.topbar__link:hover{text-decoration:underline}<?php endif; ?>
    <?php if (!empty($_topbarDarkHoverTextColor)): ?>[data-theme="dark"] .topbar__link:hover{color:<?= htmlspecialchars($_topbarDarkHoverTextColor) ?> !important;opacity:1}<?php endif; ?>
    </style>
    <div class="topbar">
        <div class="container topbar__inner">
            <?php if (!empty($_topbarText)): ?>
                <span class="topbar__text"<?php if ($tbTextStyle) echo ' style="' . $tbTextStyle . '"'; ?>><?php echo htmlspecialchars($_topbarText); ?></span>
            <?php endif; ?>
            <?php if (!empty($_topbarLinks)): ?>
                <?php foreach ($_topbarLinks as $tl): ?>
                    <?php $tbUrl = $tl['url']; if (!preg_match('#^(https?:|/|\#)#i', $tbUrl)) { $tbUrl = '#'; } ?>
                    <a href="<?php echo htmlspecialchars($tbUrl); ?>" class="topbar__link" target="_blank" rel="noopener noreferrer"<?php if ($tbLinkStyle) echo ' style="' . $tbLinkStyle . '"'; ?>><?php if (!empty($tl['icon'])): ?><i class="fa-solid fa-<?php echo htmlspecialchars($tl['icon']); ?>"></i> <?php endif; ?><?php echo htmlspecialchars($tl['text']); ?></a>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
    </div>
    <?php endif; ?>

    <header class="header sticky" id="siteHeader">
        
        <div class="header-mid">
            <div class="container header-mid__inner">
                <div class="header__logo-group">
                    <button type="button" class="header__scroll-burger" id="scrollBurger" aria-label="<?php echo htmlspecialchars(__('simply_menu'), ENT_QUOTES); ?>">
                        <svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="2" y1="6" x2="22" y2="6"></line><line x1="2" y1="12" x2="22" y2="12"></line><line x1="2" y1="18" x2="22" y2="18"></line></svg>
                    </button>
                    <a href="<?php echo url('/'); ?>" class="header__logo">
                    <?php if (!empty($_siteLogo) && !empty($_siteLogoDark)): ?>
                        <img src="/uploads/branding/<?php echo htmlspecialchars($_siteLogo); ?>" alt="<?php echo htmlspecialchars($_siteName); ?>" class="header__logo-img header__logo-light">
                        <img src="/uploads/branding/<?php echo htmlspecialchars($_siteLogoDark); ?>" alt="<?php echo htmlspecialchars($_siteName); ?>" class="header__logo-img header__logo-dark">
                    <?php elseif (!empty($_siteLogo)): ?>
                        <img src="/uploads/branding/<?php echo htmlspecialchars($_siteLogo); ?>" alt="<?php echo htmlspecialchars($_siteName); ?>" class="header__logo-img header__logo-only">
                    <?php else: ?>
                        <?php echo htmlspecialchars($_siteName); ?>
                    <?php endif; ?>
                </a>
                </div>

                <?php if ($_menuSearch): ?>
                <div class="header-mid__center">
                    <form class="header__search" action="<?php echo url('/search'); ?>" method="GET">
                        <i class="fa-solid fa-magnifying-glass"></i>
                        <input type="text" name="q" placeholder="<?php echo __('search_placeholder'); ?>" value="<?php echo htmlspecialchars(is_string($_GET['q'] ?? null) ? $_GET['q'] : ''); ?>">
                        <button type="submit" class="header__search-btn" aria-label="<?php echo __('search_placeholder'); ?>"><i class="fa-solid fa-magnifying-glass"></i></button>
                    </form>
                </div>
                <?php endif; ?>

                <div class="header__actions">
                    <div class="udd" id="uddWrap">
                        <button type="button" class="udd__trigger<?php echo $_user ? ' udd__trigger--auth' : ''; ?>" id="uddTrigger" aria-label="<?php echo htmlspecialchars(__('simply_account_menu'), ENT_QUOTES); ?>" aria-expanded="false" aria-haspopup="true">
                            <i class="fa-solid fa-circle-user"></i>
                        </button>
                        <div class="udd__dropdown" id="uddDropdown" role="menu">
                            <?php if ($_user): ?>
                            <div class="udd__header">
                                <div class="udd__avatar"><i class="fa-solid fa-circle-user"></i></div>
                                <span class="udd__username"><?php echo htmlspecialchars(ucfirst($_user['username'])); ?></span>
                            </div>
                            <div class="udd__section">
                                <a href="<?php echo url('/profile'); ?>" class="udd__link" role="menuitem"><i class="fa-light fa-user"></i><?php echo __('my_profile'); ?></a>
                                <a href="<?php echo url('/profile'); ?>?tab=favorites" class="udd__link" role="menuitem"><i class="fa-light fa-heart"></i><?php echo __('my_favorites'); ?></a>
                                <a href="<?php echo url('/profile'); ?>?tab=history" class="udd__link" role="menuitem"><i class="fa-light fa-clock-rotate-left"></i><?php echo __('watch_history'); ?></a>
                            </div>
                            <?php elseif ($_registrationEnabled): ?>
                            <div class="udd__header">
                                <div class="udd__avatar"><i class="fa-light fa-circle-user"></i></div>
                                <span class="udd__username"><?php echo __('welcome'); ?></span>
                            </div>
                            <div class="udd__section udd__auth-buttons">
                                <button type="button" class="udd__btn udd__btn--primary" onclick="document.getElementById('uddWrap').classList.remove('open');authModal('login')"><?php echo __('log_in'); ?></button>
                                <button type="button" class="udd__btn udd__btn--outline" onclick="document.getElementById('uddWrap').classList.remove('open');authModal('register')"><?php echo __('sign_up'); ?></button>
                            </div>
                            <?php endif; ?>
                            <?php if (!empty($_darkModeEnabled)): ?>
                            <div class="udd__section udd__row">
                                <i class="fa-light fa-circle-half-stroke"></i>
                                <span class="udd__row-label"><?php echo __('appearance'); ?></span>
                                <div class="udd__seg" id="uddThemeSeg">
                                    <button type="button" class="udd__seg-btn" data-theme-val="light" aria-label="<?php echo __('light_mode'); ?>"><i class="fa-light fa-sun-bright"></i></button>
                                    <button type="button" class="udd__seg-btn" data-theme-val="dark" aria-label="<?php echo __('dark_mode'); ?>"><i class="fa-light fa-moon-stars"></i></button>
                                    <span class="udd__seg-indicator"></span>
                                </div>
                            </div>
                            <?php endif; ?>
                            <?php if (count($_availableLangs) > 1): ?>
                            <div class="udd__section">
                                <div class="udd__section-label"><?php echo __('language'); ?></div>
                                <div class="udd__lang-grid">
                                    <?php foreach ($_availableLangs as $lang): ?>
                                    <a href="<?php echo htmlspecialchars(Router::switchLangUrl($lang['code'])); ?>" class="udd__lang-item<?php echo $lang['code'] === $_locale ? ' active' : ''; ?>" role="menuitem">
                                        <span class="fi fi-<?php echo Translator::flagCode($lang['code']); ?> fis udd__flag"></span>
                                        <span><?php echo htmlspecialchars($lang['native_name']); ?></span>
                                    </a>
                                    <?php endforeach; ?>
                                </div>
                            </div>
                            <?php endif; ?>
                            <?php if ($_user): ?>
                            <div class="udd__section udd__section--logout">
                                <a href="<?php echo url('/logout'); ?>" class="udd__link udd__link--danger" role="menuitem"><i class="fa-light fa-arrow-right-from-bracket"></i><?php echo __('logout'); ?></a>
                            </div>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>

                <div class="header__mobile-icons">
                    <button class="header__burger" aria-label="<?php echo htmlspecialchars(__('simply_menu'), ENT_QUOTES); ?>" type="button">
                        <i class="fa-light fa-bars"></i>
                    </button>
                </div>
            </div>
        </div>

        
        <nav class="header-nav<?php echo ($_navStyle ?? 'default') === 'full' ? ' header-nav--full' : ''; ?>">
            <div class="<?php echo ($_navStyle ?? 'default') === 'full' ? 'header-nav__inner' : 'container header-nav__inner'; ?>">
                <?php
                    $vtypeLabels = Video::typeLabels();
                    $vtypeIcons = [
                        'hetero'  => '<i class="fa-solid fa-mars-and-venus"></i>',
                        'gay'     => '<i class="fa-solid fa-mars-double"></i>',
                        'hentai'  => '<i class="fa-solid fa-heart"></i>',
                    ];
                ?>
                <?php foreach ($_menuItems as $mi): ?>
                    <?php if (($mi['widget'] ?? '') === 'vtype_switcher' && $_showVideoTypeSwitch): ?>
                        <div class="header__nav-dropdown vtype-dd">
                            <a href="#" class="vtype-dd__trigger">
                                <span class="vtype-dd__icon vtype-dd__icon--<?php echo htmlspecialchars($_activeVideoType); ?>"><?php echo $vtypeIcons[$_activeVideoType] ?? ''; ?></span>
                                <?php echo htmlspecialchars($vtypeLabels[$_activeVideoType] ?? $_activeVideoType); ?>
                                <i class="fa-solid fa-chevron-down nav-chevron"></i>
                            </a>
                            <div class="header__nav-submenu">
                                <?php foreach ($_availableVideoTypes as $vt): ?>
                                <a href="<?php echo htmlspecialchars(Router::switchTypeUrl($vt)); ?>" class="<?php echo $vt === $_activeVideoType ? 'active' : ''; ?>" data-vtype="<?php echo htmlspecialchars($vt); ?>" data-switch-url="<?php echo htmlspecialchars(Router::switchTypeUrl($vt)); ?>">
                                    <span class="vtype-dd__icon vtype-dd__icon--<?php echo htmlspecialchars($vt); ?>"><?php echo $vtypeIcons[$vt] ?? ''; ?></span>
                                    <?php echo htmlspecialchars($vtypeLabels[$vt] ?? $vt); ?>
                                </a>
                                <?php endforeach; ?>
                            </div>
                        </div>
                    <?php elseif (empty($mi['widget'])): ?>
                    <?php
                    $miActive = in_array($_template, $mi['templates'] ?? []);
                    if (!$miActive && !empty($mi['children'])) {
                        foreach ($mi['children'] as $_ch) {
                            if (!empty($_ch['url']) && (rtrim($_ch['url'], '/') ?: '/') === $_currentPath) { $miActive = true; break; }
                        }
                    }
                    $miIcon = !empty($mi['icon']) ? '<i class="fa-solid fa-' . htmlspecialchars($mi['icon']) . ' nav-icon"></i> ' : '';
                    ?>
                    <?php if (($mi['id'] ?? '') === 'categories' && !empty($_megaMenuPopular) && ($mi['mega_menu'] ?? true)): ?>
                        <div class="header__nav-dropdown header__nav-dropdown--mega">
                            <a href="<?php echo htmlspecialchars($mi['url']); ?>" class="<?php echo $miActive ? 'active' : ''; ?>">
                                <?php echo $miIcon; ?><?php echo htmlspecialchars($mi['label']); ?>
                                <i class="fa-solid fa-chevron-down nav-chevron"></i>
                            </a>
                            <div class="header__mega-menu">
                                <div class="mega-menu__wrap">
                                    <div class="mega-menu__sidebar">
                                        <h3 class="mega-menu__title"><?php echo htmlspecialchars(mb_strtoupper($mi['label'])); ?></h3>
                                        <nav class="mega-menu__nav">
                                            <?php if (!empty($_megaMenuCtrActive)): ?>
                                            <a href="#" class="mega-menu__nav-link active" onclick="return false">
                                                <i class="fa-solid fa-fire-flame-curved mega-menu__nav-icon"></i>
                                                <?php echo htmlspecialchars(__('simply_mega_trending_popular')); ?>
                                            </a>
                                            <?php else: ?>
                                            <a href="#" class="mega-menu__nav-link active" onclick="return false">
                                                <i class="fa-solid fa-star mega-menu__nav-icon"></i>
                                                <?php echo htmlspecialchars(__('simply_mega_most_popular')); ?>
                                            </a>
                                            <?php endif; ?>
                                            <a href="<?php echo htmlspecialchars($mi['url']); ?>" class="mega-menu__nav-link" aria-label="<?php echo htmlspecialchars(__('simply_mega_see_more_aria')); ?>">
                                                <i class="fa-solid fa-grid-2 mega-menu__nav-icon"></i>
                                                <?php echo htmlspecialchars(__('simply_mega_see_more')); ?>
                                                <i class="fa-solid fa-arrow-right mega-menu__nav-arrow"></i>
                                            </a>
                                        </nav>
                                    </div>
                                    <div class="mega-menu__content<?php echo empty($_megaMenuCtrActive) ? ' mega-menu__content--2rows' : ''; ?>">
                                        <?php if (!empty($_megaMenuTrending) && !empty($_megaMenuCtrActive)): ?>
                                        <h4 class="mega-menu__heading"><?php echo htmlspecialchars(__('simply_mega_top_trending')); ?></h4>
                                        <div class="mega-menu__grid">
                                            <?php foreach ($_megaMenuTrending as $_mc):
                                                $_mcName = htmlspecialchars($_mc['name']);
                                                $_mcHref = url('/category/' . htmlspecialchars($_mc['slug']));
                                                $_mcVc = (int)($_mc['video_count'] ?? 0);
                                                $_mcThumb = '';
                                                if (!empty($_mc['thumbnail'])) {
                                                    $_mcThumb = str_starts_with($_mc['thumbnail'], 'http') ? $_mc['thumbnail'] : '/uploads/thumbnails/' . $_mc['thumbnail'];
                                                } elseif (!empty($_mc['best_video_folder'])) {
                                                    $_mcThumb = VideoAsset::thumbUrlFromFolder($_mc['best_video_folder'], true, $_mc['best_video_storage_id'] ?? null);
                                                }
                                            ?>
                                            <a href="<?php echo $_mcHref; ?>" class="mega-menu__item">
                                                <?php if ($_mcThumb !== ''): ?>
                                                    <img src="<?php echo htmlspecialchars($_mcThumb); ?>" alt="<?php echo $_mcName; ?>" loading="lazy">
                                                <?php else: ?>
                                                    <div class="mega-menu__placeholder"><?php echo strtoupper(mb_substr($_mc['name'], 0, 1)); ?></div>
                                                <?php endif; ?>
                                                <?php if ($_mcVc > 0): ?><span class="mega-menu__count"><?php echo Format::number($_mcVc); ?></span><?php endif; ?>
                                                <span class="mega-menu__name"><?php echo $_mcName; ?></span>
                                            </a>
                                            <?php endforeach; ?>
                                        </div>
                                        <?php endif; ?>

                                        <h4 class="mega-menu__heading<?php echo (!empty($_megaMenuTrending) && !empty($_megaMenuCtrActive)) ? ' mega-menu__heading--spaced' : ''; ?>"><?php echo htmlspecialchars(__('simply_mega_most_popular')); ?></h4>
                                        <div class="mega-menu__grid">
                                            <?php foreach ($_megaMenuPopular as $_mc):
                                                $_mcName = htmlspecialchars($_mc['name']);
                                                $_mcHref = url('/category/' . htmlspecialchars($_mc['slug']));
                                                $_mcVc = (int)($_mc['video_count'] ?? 0);
                                                $_mcThumb = '';
                                                if (!empty($_mc['thumbnail'])) {
                                                    $_mcThumb = str_starts_with($_mc['thumbnail'], 'http') ? $_mc['thumbnail'] : '/uploads/thumbnails/' . $_mc['thumbnail'];
                                                } elseif (!empty($_mc['best_video_folder'])) {
                                                    $_mcThumb = VideoAsset::thumbUrlFromFolder($_mc['best_video_folder'], true, $_mc['best_video_storage_id'] ?? null);
                                                }
                                            ?>
                                            <a href="<?php echo $_mcHref; ?>" class="mega-menu__item">
                                                <?php if ($_mcThumb !== ''): ?>
                                                    <img src="<?php echo htmlspecialchars($_mcThumb); ?>" alt="<?php echo $_mcName; ?>" loading="lazy">
                                                <?php else: ?>
                                                    <div class="mega-menu__placeholder"><?php echo strtoupper(mb_substr($_mc['name'], 0, 1)); ?></div>
                                                <?php endif; ?>
                                                <?php if ($_mcVc > 0): ?><span class="mega-menu__count"><?php echo Format::number($_mcVc); ?></span><?php endif; ?>
                                                <span class="mega-menu__name"><?php echo $_mcName; ?></span>
                                            </a>
                                            <?php endforeach; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php elseif (!empty($mi['children'])): ?>
                        <div class="header__nav-dropdown">
                            <a href="<?php echo htmlspecialchars($mi['url']); ?>"<?php if (($mi['target'] ?? '_self') === '_blank'): ?> target="_blank" rel="noopener noreferrer"<?php endif; ?> class="<?php echo $miActive ? 'active' : ''; ?>">
                                <?php echo $miIcon; ?><?php echo htmlspecialchars($mi['label']); ?>
                                <i class="fa-solid fa-chevron-down nav-chevron"></i>
                            </a>
                            <div class="header__nav-submenu">
                                <?php foreach ($mi['children'] as $child): ?>
                                    <?php if (($child['widget'] ?? '') === 'vtype_switcher' && $_showVideoTypeSwitch): ?>
                                        <?php foreach ($_availableVideoTypes as $vt): ?>
                                        <a href="<?php echo htmlspecialchars(Router::switchTypeUrl($vt)); ?>" class="<?php echo $vt === $_activeVideoType ? 'active' : ''; ?>" data-vtype="<?php echo htmlspecialchars($vt); ?>" data-switch-url="<?php echo htmlspecialchars(Router::switchTypeUrl($vt)); ?>">
                                            <span class="vtype-dd__icon vtype-dd__icon--<?php echo htmlspecialchars($vt); ?>"><?php echo $vtypeIcons[$vt] ?? ''; ?></span>
                                            <?php echo htmlspecialchars($vtypeLabels[$vt] ?? $vt); ?>
                                        </a>
                                        <?php endforeach; ?>
                                    <?php elseif (empty($child['widget'])): ?>
                                    <?php $childIcon = !empty($child['icon']) ? '<i class="fa-solid fa-' . htmlspecialchars($child['icon']) . ' nav-icon"></i> ' : ''; ?>
                                    <a href="<?php echo htmlspecialchars($child['url']); ?>"<?php if (($child['target'] ?? '_self') === '_blank'): ?> target="_blank" rel="noopener noreferrer"<?php endif; ?> class="<?php echo (!empty($child['url']) && (rtrim($child['url'], '/') ?: '/') === $_currentPath) ? 'active' : ''; ?>"><?php echo $childIcon; ?><?php echo htmlspecialchars($child['label']); ?></a>
                                    <?php endif; ?>
                                <?php endforeach; ?>
                            </div>
                        </div>
                    <?php else: ?>
                        <a href="<?php echo htmlspecialchars($mi['url']); ?>"<?php if (($mi['target'] ?? '_self') === '_blank'): ?> target="_blank" rel="noopener noreferrer"<?php endif; ?> class="<?php echo $miActive ? 'active' : ''; ?>"><?php echo $miIcon; ?><?php echo htmlspecialchars($mi['label']); ?></a>
                    <?php endif; ?>
                    <?php endif; ?>
                <?php endforeach; ?>
            </div>
        </nav>
    </header>

    <?php if (!Ads::isHomepageLanding() && !Ads::isWatchPage()) Ads::zone('header_banner'); ?>

    
    <div class="scroll-sidebar" id="scrollSidebar">
        <div class="scroll-sidebar__backdrop" id="scrollSidebarBackdrop"></div>
        <div class="scroll-sidebar__panel">
            <div class="scroll-sidebar__header">
                <span class="scroll-sidebar__title"><?php echo __('menu'); ?></span>
                <button type="button" class="scroll-sidebar__close" id="scrollSidebarClose" aria-label="<?php echo htmlspecialchars(__('simply_close'), ENT_QUOTES); ?>">
                    <i class="fa-solid fa-xmark"></i>
                </button>
            </div>
            <?php if ($_showVideoTypeSwitch): ?>
            <div class="scroll-sidebar__vtype">
                <?php
                $vtypeColors = ['hetero' => '#4a90d9', 'gay' => '#b44adb', 'hentai' => '#e84393'];
                foreach ($_availableVideoTypes as $vt):
                    $isActive = $vt === $_activeVideoType;
                    $color = $vtypeColors[$vt] ?? 'var(--primary)';
                ?>
                <a href="<?php echo htmlspecialchars(Router::switchTypeUrl($vt)); ?>" class="scroll-sidebar__vtype-pill<?php echo $isActive ? ' active' : ''; ?>" data-vtype="<?php echo htmlspecialchars($vt); ?>" data-switch-url="<?php echo htmlspecialchars(Router::switchTypeUrl($vt)); ?>" style="--pill-color:<?php echo $color; ?>">
                    <span class="scroll-sidebar__vtype-icon"><?php echo $vtypeIcons[$vt] ?? ''; ?></span>
                    <span><?php echo htmlspecialchars($vtypeLabels[$vt] ?? $vt); ?></span>
                </a>
                <?php endforeach; ?>
            </div>
            <?php endif; ?>
            <nav class="scroll-sidebar__links">
                <?php foreach ($_menuItems as $mi): ?>
                    <?php if (($mi['widget'] ?? '') === 'vtype_switcher'): ?>
                        <?php   ?>
                    <?php elseif (empty($mi['widget'])): ?>
                    <?php
                    $sIcon = !empty($mi['icon']) ? '<i class="fa-solid fa-' . htmlspecialchars($mi['icon']) . ' nav-icon"></i> ' : '';
                    $sActive = in_array($_template, $mi['templates'] ?? []);
                    if (!$sActive && !empty($mi['children'])) {
                        foreach ($mi['children'] as $_ch) {
                            if (!empty($_ch['url']) && (rtrim($_ch['url'], '/') ?: '/') === $_currentPath) { $sActive = true; break; }
                        }
                    }
                    ?>
                    <a href="<?php echo htmlspecialchars($mi['url']); ?>"<?php if (($mi['target'] ?? '_self') === '_blank'): ?> target="_blank" rel="noopener noreferrer"<?php endif; ?> class="<?php echo $sActive ? 'active' : ''; ?>"><?php echo $sIcon; ?><?php echo htmlspecialchars($mi['label']); ?></a>
                    <?php if (!empty($mi['children'])): ?>
                        <?php foreach ($mi['children'] as $child):
                            $cIcon = !empty($child['icon']) ? '<i class="fa-solid fa-' . htmlspecialchars($child['icon']) . ' nav-icon"></i> ' : '';
                        ?>
                            <a href="<?php echo htmlspecialchars($child['url']); ?>"<?php if (($child['target'] ?? '_self') === '_blank'): ?> target="_blank" rel="noopener noreferrer"<?php endif; ?> class="scroll-sidebar__child <?php echo (!empty($child['url']) && (rtrim($child['url'], '/') ?: '/') === $_currentPath) ? 'active' : ''; ?>"><?php echo $cIcon; ?><?php echo htmlspecialchars($child['label']); ?></a>
                        <?php endforeach; ?>
                    <?php endif; ?>
                    <?php endif; ?>
                <?php endforeach; ?>
            </nav>
        </div>
    </div>

    <div class="mobile-nav" id="mobileNav">
        <div class="mobile-nav__backdrop" id="mobileNavBackdrop"></div>
        <div class="mobile-nav__panel">
            
            <div class="mobile-nav__user">
                <?php if ($_user): ?>
                <div class="mobile-nav__avatar"><i class="fa-solid fa-circle-user"></i></div>
                <div class="mobile-nav__user-info">
                    <span class="mobile-nav__user-name"><?php echo htmlspecialchars(ucfirst($_user['username'])); ?></span>
                </div>
                <button type="button" class="mobile-nav__close" id="mobileNavClose" aria-label="<?php echo htmlspecialchars(__('simply_close'), ENT_QUOTES); ?>"><i class="fa-light fa-xmark"></i></button>
                <?php else: ?>
                <div class="mobile-nav__user-info" style="flex:1">
                    <span class="mobile-nav__user-name"><?php echo htmlspecialchars($_siteName); ?></span>
                </div>
                <button type="button" class="mobile-nav__close" id="mobileNavClose" aria-label="<?php echo htmlspecialchars(__('simply_close'), ENT_QUOTES); ?>"><i class="fa-light fa-xmark"></i></button>
                <?php endif; ?>
            </div>

            
            <?php if ($_menuSearch): ?>
            <div class="mobile-nav__search-wrap">
                <form class="mobile-nav__search" action="<?php echo url('/search'); ?>" method="GET">
                    <i class="fa-light fa-magnifying-glass"></i>
                    <input type="text" name="q" placeholder="<?php echo __('search_placeholder'); ?>" value="<?php echo htmlspecialchars(is_string($_GET['q'] ?? null) ? $_GET['q'] : ''); ?>">
                </form>
            </div>
            <?php endif; ?>

            
            <?php if ($_showVideoTypeSwitch): ?>
            <div class="mobile-nav__vtype">
                <?php
                $vtypeColorsMob = ['hetero' => '#4a90d9', 'gay' => '#b44adb', 'hentai' => '#e84393'];
                foreach ($_availableVideoTypes as $vt):
                    $isActiveMob = $vt === $_activeVideoType;
                    $colorMob = $vtypeColorsMob[$vt] ?? 'var(--primary)';
                ?>
                <a href="<?php echo htmlspecialchars(Router::switchTypeUrl($vt)); ?>" class="mobile-nav__vtype-pill<?php echo $isActiveMob ? ' active' : ''; ?>" data-vtype="<?php echo htmlspecialchars($vt); ?>" data-switch-url="<?php echo htmlspecialchars(Router::switchTypeUrl($vt)); ?>" style="--pill-color:<?php echo $colorMob; ?>">
                    <span class="mobile-nav__vtype-icon"><?php echo $vtypeIcons[$vt] ?? ''; ?></span>
                    <span><?php echo htmlspecialchars($vtypeLabels[$vt] ?? $vt); ?></span>
                </a>
                <?php endforeach; ?>
            </div>
            <?php endif; ?>

            
            <nav class="mobile-nav__links">
                <div class="mobile-nav__section-label"><?php echo __('menu'); ?></div>
                <?php foreach ($_menuItems as $mi): ?>
                    <?php if (($mi['widget'] ?? '') === 'vtype_switcher'): ?>
                        <?php   ?>
                    <?php elseif (empty($mi['widget'])): ?>
                    <?php
                    $mIcon = !empty($mi['icon']) ? '<i class="fa-light fa-' . htmlspecialchars($mi['icon']) . ' mobile-nav__icon"></i>' : '<i class="fa-light fa-circle mobile-nav__icon" style="font-size:6px"></i>';
                    $mActive = in_array($_template, $mi['templates'] ?? []);
                    if (!$mActive && !empty($mi['children'])) {
                        foreach ($mi['children'] as $_ch) {
                            if (!empty($_ch['url']) && (rtrim($_ch['url'], '/') ?: '/') === $_currentPath) { $mActive = true; break; }
                        }
                    }
                    ?>
                    <a href="<?php echo htmlspecialchars($mi['url']); ?>"<?php if (($mi['target'] ?? '_self') === '_blank'): ?> target="_blank" rel="noopener noreferrer"<?php endif; ?> class="<?php echo $mActive ? 'active' : ''; ?>"><?php echo $mIcon; ?><?php echo htmlspecialchars($mi['label']); ?></a>
                    <?php if (!empty($mi['children'])): ?>
                        <?php foreach ($mi['children'] as $child):
                            $cIcon = !empty($child['icon']) ? '<i class="fa-light fa-' . htmlspecialchars($child['icon']) . ' mobile-nav__icon"></i>' : '';
                        ?>
                            <a href="<?php echo htmlspecialchars($child['url']); ?>"<?php if (($child['target'] ?? '_self') === '_blank'): ?> target="_blank" rel="noopener noreferrer"<?php endif; ?> class="mobile-nav__child <?php echo (!empty($child['url']) && (rtrim($child['url'], '/') ?: '/') === $_currentPath) ? 'active' : ''; ?>"><?php echo $cIcon; ?><?php echo htmlspecialchars($child['label']); ?></a>
                        <?php endforeach; ?>
                    <?php endif; ?>
                    <?php endif; ?>
                <?php endforeach; ?>
            </nav>

            
            <div class="mobile-nav__links">
                <div class="mobile-nav__section-label"><?php echo __('account'); ?></div>
                <?php if ($_user): ?>
                    <a href="<?php echo url('/profile'); ?>"><i class="fa-light fa-user mobile-nav__icon"></i><?php echo __('my_profile'); ?></a>
                    <a href="<?php echo url('/profile'); ?>?tab=favorites"><i class="fa-light fa-heart mobile-nav__icon"></i><?php echo __('my_favorites'); ?></a>
                    <a href="<?php echo url('/profile'); ?>?tab=history"><i class="fa-light fa-clock-rotate-left mobile-nav__icon"></i><?php echo __('watch_history'); ?></a>
                    <a href="<?php echo url('/logout'); ?>" class="mobile-nav__logout"><i class="fa-light fa-arrow-right-from-bracket mobile-nav__icon"></i><?php echo __('logout'); ?></a>
                <?php elseif ($_registrationEnabled): ?>
                    <a href="#" onclick="authModal('login');document.getElementById('mobileNav').classList.remove('open');document.body.style.overflow='';return false;"><i class="fa-light fa-right-to-bracket mobile-nav__icon"></i><?php echo __('login'); ?></a>
                    <a href="#" onclick="authModal('register');document.getElementById('mobileNav').classList.remove('open');document.body.style.overflow='';return false;"><i class="fa-light fa-user-plus mobile-nav__icon"></i><?php echo __('sign_up'); ?></a>
                <?php endif; ?>
            </div>

            
            <div class="mobile-nav__bottom">
                <?php if (!empty($_darkModeEnabled)): ?>
                <button type="button" class="mobile-nav__toggle-row" id="themeToggleMobile" aria-label="<?php echo htmlspecialchars(__('simply_toggle_dark_mode'), ENT_QUOTES); ?>">
                    <i class="fa-light fa-moon-stars header__theme-icon--light"></i>
                    <i class="fa-light fa-sun-bright header__theme-icon--dark"></i>
                    <span class="header__theme-icon--light"><?php echo __('dark_mode'); ?></span>
                    <span class="header__theme-icon--dark"><?php echo __('light_mode'); ?></span>
                </button>
                <?php endif; ?>
                <?php if (count($_availableLangs) > 1): ?>
                <?php
                $_curLang = $_availableLangs[0];
                foreach ($_availableLangs as $_l) {
                    if ($_l['code'] === $_locale) { $_curLang = $_l; break; }
                }
                ?>
                <details class="mobile-nav__lang" id="mobileLangPicker">
                    <summary class="mobile-nav__lang-toggle">
                        <span class="fi fi-<?php echo Translator::flagCode($_curLang['code']); ?> fis header__flag"></span>
                        <span class="mobile-nav__lang-current"><?php echo htmlspecialchars($_curLang['native_name']); ?></span>
                        <i class="fa-solid fa-chevron-down mobile-nav__lang-caret"></i>
                    </summary>
                    <div class="mobile-nav__lang-panel">
                        <?php if (count($_availableLangs) > 10): ?>
                        <input type="search" class="mobile-nav__lang-search" data-lang-filter autocomplete="off"
                               placeholder="<?php echo htmlspecialchars(__('search_placeholder'), ENT_QUOTES); ?>"
                               aria-label="<?php echo htmlspecialchars(__('language'), ENT_QUOTES); ?>">
                        <?php endif; ?>
                        <div class="mobile-nav__lang-list">
                            <?php foreach ($_availableLangs as $lang): ?>
                            <a href="<?php echo htmlspecialchars(Router::switchLangUrl($lang['code'])); ?>"
                               class="mobile-nav__lang-item<?php echo $lang['code'] === $_locale ? ' active' : ''; ?>"
                               data-lang-match="<?php echo htmlspecialchars(mb_strtolower($lang['native_name'] . ' ' . ($lang['name'] ?? '') . ' ' . $lang['code']), ENT_QUOTES); ?>"<?php echo $lang['code'] === $_locale ? ' aria-current="true"' : ''; ?>>
                                <span class="fi fi-<?php echo Translator::flagCode($lang['code']); ?> fis header__flag"></span>
                                <span class="mobile-nav__lang-label"><?php echo htmlspecialchars($lang['native_name']); ?></span>
                                <i class="fa-solid fa-check mobile-nav__lang-check"></i>
                            </a>
                            <?php endforeach; ?>
                        </div>
                        <p class="mobile-nav__lang-empty" hidden data-empty-label="<?php echo htmlspecialchars(__('no_results_for'), ENT_QUOTES); ?>"></p>
                    </div>
                </details>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <main class="container">
        <?php echo $content; ?>
    </main>

    <?php Ads::zone('footer_banner'); ?>

    <footer class="footer <?php echo 'footer__cols-' . count($_footerColumns); ?>">
        <div class="container">
            <div class="footer__inner">
                <?php foreach ($_footerColumns as $ftCol): ?>
                <div class="footer__col <?php echo in_array($ftCol['type'], ['navigation','pages','custom_links','badges','social']) ? 'footer__links' : ''; ?>">
                    <?php switch ($ftCol['type']):
                        case 'logo':
                            $ftLogoH = (int) ($ftCol['logo_height'] ?? 32);
                        ?>
                            <div class="footer__logo">
                                <?php if (!empty($ftCol['logo'])): ?>
                                    <img src="/uploads/branding/<?php echo htmlspecialchars($ftCol['logo']); ?>" alt="<?php echo htmlspecialchars($ftCol['site_name'] ?? $_siteName); ?>" style="height:<?php echo $ftLogoH; ?>px;max-width:200px;object-fit:contain;">
                                <?php else: ?>
                                    <?php echo htmlspecialchars($ftCol['site_name'] ?? $_siteName); ?>
                                <?php endif; ?>
                            </div>
                            <?php if ($ftCol['show_description'] ?? true): ?>
                            <p class="footer__desc"><?php echo htmlspecialchars($ftCol['description'] ?: $_siteDescription); ?></p>
                            <?php endif; ?>
                            <?php break;

                        case 'navigation': ?>
                            <?php if ($ftCol['title']): ?><h4><?php echo htmlspecialchars($ftCol['title']); ?></h4><?php endif; ?>
                            <?php
                            $navFilter = $ftCol['nav_items'] ?? [];
                            foreach ($_menuItems as $mi):
                                if (!empty($navFilter) && !in_array($mi['id'] ?? '', $navFilter, true)) continue;
                            ?>
                                <a href="<?php echo htmlspecialchars($mi['url']); ?>"><?php echo htmlspecialchars($mi['label']); ?></a>
                            <?php endforeach; ?>
                            <?php
                             
                            foreach ($ftCol['custom_links'] ?? [] as $_ncl):
                                $nclLabel = $_ncl['label'] ?? '';
                                 
                                if (!empty($_ncl['_translations']['label'][$_locale ?? ''])) {
                                    $nclLabel = $_ncl['_translations']['label'][$_locale];
                                }
                            ?>
                                <a href="<?php echo htmlspecialchars($_ncl['url'] ?? ''); ?>"><?php echo htmlspecialchars($nclLabel); ?></a>
                            <?php endforeach; ?>
                            <?php break;

                        case 'pages': ?>
                            <?php if ($ftCol['title']): ?><h4><?php echo htmlspecialchars($ftCol['title']); ?></h4><?php endif; ?>
                            <?php if (!empty($ftCol['pages'])): ?>
                                <?php foreach ($ftCol['pages'] as $pg): ?>
                                    <a href="<?php echo url('/' . htmlspecialchars($pg['slug'])); ?>"><?php echo htmlspecialchars($pg['title']); ?></a>
                                <?php endforeach; ?>
                            <?php endif; ?>
                            <?php break;

                        case 'custom_links': ?>
                            <?php if ($ftCol['title']): ?><h4><?php echo htmlspecialchars($ftCol['title']); ?></h4><?php endif; ?>
                            <?php if (!empty($ftCol['links'])): ?>
                                <?php foreach ($ftCol['links'] as $link): ?>
                                    <a href="<?php echo htmlspecialchars($link['url']); ?>" target="_blank" rel="noopener noreferrer"><?php echo htmlspecialchars($link['label']); ?></a>
                                <?php endforeach; ?>
                            <?php endif; ?>
                            <?php break;

                        case 'badges': ?>
                            <?php if ($ftCol['title']): ?><h4><?php echo htmlspecialchars($ftCol['title']); ?></h4><?php endif; ?>
                            <div class="footer__badges">
                                <?php
                                $allBadgeIcons = FooterConfig::badgeIcons();
                                foreach ($ftCol['badges'] ?? [] as $badge):
                                    $icon = $badge['icon'] ?? '';
                                    $label = $badge['label'] ?? '';
                                    if ($label !== '' && isset($allBadgeIcons[$icon])): ?>
                                    <div class="footer__badge">
                                        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><?php echo $allBadgeIcons[$icon]['svg']; ?></svg>
                                        <span><?php echo htmlspecialchars($label); ?></span>
                                    </div>
                                <?php endif; endforeach; ?>
                            </div>
                            <?php break;

                        case 'text': ?>
                            <?php if ($ftCol['title']): ?><h4><?php echo htmlspecialchars($ftCol['title']); ?></h4><?php endif; ?>
                            <div class="footer__text"><?php echo htmlspecialchars($ftCol['content'] ?? ''); ?></div>
                            <?php break;

                        case 'social': ?>
                            <?php if ($ftCol['title']): ?><h4><?php echo htmlspecialchars($ftCol['title']); ?></h4><?php endif; ?>
                            <?php if (!empty($ftCol['links'])): ?>
                            <div class="footer__social footer__social--wrap">
                                <?php
                                $socialSvgs = [
                                    'twitter'   => '<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>',
                                    'instagram' => '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="20" rx="5" ry="5"></rect><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"></path><line x1="17.5" y1="6.5" x2="17.51" y2="6.5"></line></svg>',
                                    'reddit'    => '<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 1 1.108-.701zM9.25 12C8.561 12 8 12.562 8 13.25c0 .687.561 1.248 1.25 1.248.687 0 1.248-.561 1.248-1.249 0-.688-.561-1.249-1.249-1.249zm5.5 0c-.687 0-1.248.561-1.248 1.25 0 .687.561 1.248 1.249 1.248.688 0 1.249-.561 1.249-1.249 0-.687-.562-1.249-1.25-1.249zm-5.466 3.99a.327.327 0 0 0-.231.094.33.33 0 0 0 0 .463c.842.842 2.484.913 2.961.913.477 0 2.105-.056 2.961-.913a.361.361 0 0 0 .029-.463.33.33 0 0 0-.464 0c-.547.533-1.684.73-2.512.73-.828 0-1.979-.196-2.512-.73a.326.326 0 0 0-.232-.095z"/></svg>',
                                    'telegram'  => '<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0 12 12 0 0 0 11.944 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.479.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/></svg>',
                                    'discord'   => '<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z"/></svg>',
                                ];
                                $socialLabels = ['twitter' => 'Twitter', 'instagram' => 'Instagram', 'reddit' => 'Reddit', 'telegram' => 'Telegram', 'discord' => 'Discord'];
                                foreach ($ftCol['links'] as $sKey => $sUrl): if (isset($socialSvgs[$sKey])): ?>
                                    <a href="<?php echo htmlspecialchars($sUrl); ?>" target="_blank" rel="noopener noreferrer" aria-label="<?php echo $socialLabels[$sKey]; ?>">
                                        <?php echo $socialSvgs[$sKey]; ?>
                                    </a>
                                <?php endif; endforeach; ?>
                            </div>
                            <?php endif; ?>
                            <?php break;

                    endswitch; ?>
                </div>
                <?php endforeach; ?>
            </div>

            <?php
            $ftBottom = $_footerBottom ?? [];
            $showCopyright = $ftBottom['show_copyright'] ?? true;
            $showDisclaimer = $ftBottom['show_disclaimer'] ?? true;
            $showSocial = $ftBottom['show_social'] ?? true;
            ?>
            <?php if ($showCopyright || $showDisclaimer || ($showSocial && !empty($_socialLinks))): ?>
            <div class="footer__bottom">
                <?php if ($showDisclaimer): ?>
                    <p class="footer__disclaimer"><?php
                        $customDisclaimer = $ftBottom['disclaimer_text'] ?? '';
                        echo $customDisclaimer !== '' ? htmlspecialchars($customDisclaimer) : __('adults_only');
                    ?></p>
                <?php endif; ?>
                <?php if ($showCopyright): ?>
                    <span class="footer__copyright"><?php
                        $customCopyright = $ftBottom['copyright_text'] ?? '';
                        if ($customCopyright !== '') {
                            echo htmlspecialchars($customCopyright);
                        } else {
                            echo '&copy; ' . date('Y') . ' ' . htmlspecialchars($_siteName) . '. ' . __('all_rights_reserved');
                        }
                    ?></span>
                <?php endif; ?>
                <?php if ($showSocial && !empty($_socialLinks)): ?>
                <div class="footer__social">
                    <?php if (!empty($_socialLinks['twitter'])): ?>
                    <a href="<?php echo htmlspecialchars($_socialLinks['twitter']); ?>" target="_blank" rel="noopener noreferrer" aria-label="Twitter">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
                    </a>
                    <?php endif; ?>
                    <?php if (!empty($_socialLinks['instagram'])): ?>
                    <a href="<?php echo htmlspecialchars($_socialLinks['instagram']); ?>" target="_blank" rel="noopener noreferrer" aria-label="Instagram">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="20" rx="5" ry="5"></rect><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"></path><line x1="17.5" y1="6.5" x2="17.51" y2="6.5"></line></svg>
                    </a>
                    <?php endif; ?>
                    <?php if (!empty($_socialLinks['reddit'])): ?>
                    <a href="<?php echo htmlspecialchars($_socialLinks['reddit']); ?>" target="_blank" rel="noopener noreferrer" aria-label="Reddit">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 1 1.108-.701zM9.25 12C8.561 12 8 12.562 8 13.25c0 .687.561 1.248 1.25 1.248.687 0 1.248-.561 1.248-1.249 0-.688-.561-1.249-1.249-1.249zm5.5 0c-.687 0-1.248.561-1.248 1.25 0 .687.561 1.248 1.249 1.248.688 0 1.249-.561 1.249-1.249 0-.687-.562-1.249-1.25-1.249zm-5.466 3.99a.327.327 0 0 0-.231.094.33.33 0 0 0 0 .463c.842.842 2.484.913 2.961.913.477 0 2.105-.056 2.961-.913a.361.361 0 0 0 .029-.463.33.33 0 0 0-.464 0c-.547.533-1.684.73-2.512.73-.828 0-1.979-.196-2.512-.73a.326.326 0 0 0-.232-.095z"/></svg>
                    </a>
                    <?php endif; ?>
                    <?php if (!empty($_socialLinks['telegram'])): ?>
                    <a href="<?php echo htmlspecialchars($_socialLinks['telegram']); ?>" target="_blank" rel="noopener noreferrer" aria-label="Telegram">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0 12 12 0 0 0 11.944 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.479.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/></svg>
                    </a>
                    <?php endif; ?>
                    <?php if (!empty($_socialLinks['discord'])): ?>
                    <a href="<?php echo htmlspecialchars($_socialLinks['discord']); ?>" target="_blank" rel="noopener noreferrer" aria-label="Discord">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z"/></svg>
                    </a>
                    <?php endif; ?>
                </div>
                <?php endif; ?>
            </div>
            <?php endif; ?>
            <div class="footer__powered" style="text-align:center;padding:12px 16px 2px;font-size:12px;opacity:.55;">
                <?php echo htmlspecialchars(__('simply_powered_by')); ?> <a href="https://tubepress.io" target="_blank" rel="nofollow" style="color:inherit;font-weight:600;text-decoration:none;">TubePress</a>
            </div>
        </div>
    </footer>

    <?php if (!$_user && $_registrationEnabled): ?>
    
    <div class="auth-modal" id="authModal" data-csrf="<?php echo htmlspecialchars(Router::csrfToken()); ?>" data-lang-prefix="<?php echo htmlspecialchars(Router::langPrefix()); ?>" data-captcha-provider="<?php echo htmlspecialchars($_captchaProvider); ?>" data-captcha-site-key="<?php echo htmlspecialchars($_captchaSiteKey); ?>" data-captcha-on-register="<?php echo $_captchaOnRegister ? '1' : '0'; ?>">
        <div class="auth-modal__backdrop"></div>
        <div class="auth-modal__card">
            <button type="button" class="auth-modal__close" aria-label="<?php echo htmlspecialchars(__('simply_close'), ENT_QUOTES); ?>">
                <i class="fa-solid fa-xmark"></i>
            </button>

            <div class="auth-modal__header">
                <?php if (!empty($_siteLogo) && !empty($_siteLogoDark)): ?>
                    <div class="auth-modal__logo">
                        <img src="/uploads/branding/<?php echo htmlspecialchars($_siteLogo); ?>" alt="<?php echo htmlspecialchars($_siteName); ?>" class="auth-modal__logo-light">
                        <img src="/uploads/branding/<?php echo htmlspecialchars($_siteLogoDark); ?>" alt="<?php echo htmlspecialchars($_siteName); ?>" class="auth-modal__logo-dark">
                    </div>
                <?php elseif (!empty($_siteLogo)): ?>
                    <div class="auth-modal__logo">
                        <img src="/uploads/branding/<?php echo htmlspecialchars($_siteLogo); ?>" alt="<?php echo htmlspecialchars($_siteName); ?>">
                    </div>
                <?php else: ?>
                    <div class="auth-modal__icon">
                        <i class="fa-light fa-circle-user"></i>
                    </div>
                <?php endif; ?>
                <div class="auth-modal__subtitle"><?php echo __('sign_in_subtitle'); ?></div>
            </div>

            <div class="auth-tabs">
                <button type="button" class="auth-tabs__btn active" data-tab="login"><?php echo __('log_in'); ?></button>
                <button type="button" class="auth-tabs__btn" data-tab="register"><?php echo __('sign_up'); ?></button>
            </div>

            <div class="auth-modal__body">
                <div class="auth-msg" id="authMsg"></div>

                
                <div class="auth-panel active" id="panel-login">
                    <form id="formLogin" autocomplete="on">
                        <div class="form-group">
                            <label for="login_id"><?php echo __('email_or_username'); ?></label>
                            <input type="text" id="login_id" name="login" required autocomplete="username" placeholder="<?php echo __('email_or_username'); ?>">
                        </div>
                        <div class="form-group">
                            <label for="login_pw"><?php echo __('password'); ?></label>
                            <input type="password" id="login_pw" name="password" required autocomplete="current-password">
                        </div>
                        <button type="submit" class="btn-submit"><?php echo __('log_in'); ?></button>
                    </form>
                    <a href="#" class="auth-forgot-link" onclick="authSwitchTab('forgot');return false;"><?php echo __('forgot_password'); ?></a>
                </div>

                
                <div class="auth-panel" id="panel-register">
                    <form id="formRegister" autocomplete="on">
                        <div class="form-group">
                            <label for="reg_username"><?php echo __('username'); ?></label>
                            <input type="text" id="reg_username" name="username" required autocomplete="username">
                        </div>
                        <div class="form-group">
                            <label for="reg_email"><?php echo __('email'); ?></label>
                            <input type="email" id="reg_email" name="email" required autocomplete="email" placeholder="<?php echo __('email'); ?>">
                        </div>
                        <div class="form-group">
                            <label for="reg_pw"><?php echo __('password'); ?></label>
                            <input type="password" id="reg_pw" name="password" required autocomplete="new-password">
                        </div>
                        <div class="form-group">
                            <label for="reg_pw2"><?php echo __('confirm_password'); ?></label>
                            <input type="password" id="reg_pw2" name="password_confirm" required autocomplete="new-password">
                        </div>
                        <?php if ($_captchaOnRegister && $_captchaProvider === 'v2'): ?>
                        <div class="g-recaptcha" data-sitekey="<?php echo htmlspecialchars($_captchaSiteKey); ?>" data-theme="<?php echo htmlspecialchars(Captcha::theme()); ?>" style="margin:8px 0;transform:scale(0.9);transform-origin:0 0;"></div>
                        <?php elseif ($_captchaOnRegister && $_captchaProvider === 'turnstile'): ?>
                        <div class="cf-turnstile" data-sitekey="<?php echo htmlspecialchars($_captchaSiteKey); ?>" data-theme="<?php echo htmlspecialchars(Captcha::theme()); ?>" style="margin:8px 0;"></div>
                        <?php endif; ?>
                        <button type="submit" class="btn-submit"><?php echo __('create_account'); ?></button>
                    </form>
                </div>

                
                <div class="auth-panel" id="panel-forgot">
                    <p class="auth-panel__desc"><?php echo __('forgot_password_desc'); ?></p>
                    <form id="formForgot" autocomplete="on">
                        <div class="form-group">
                            <label for="forgot_email"><?php echo __('email'); ?></label>
                            <input type="email" id="forgot_email" name="email" required autocomplete="email" placeholder="<?php echo __('email'); ?>">
                        </div>
                        <button type="submit" class="btn-submit"><?php echo __('send_reset_link'); ?></button>
                    </form>
                    <a href="#" class="auth-forgot-link" onclick="authSwitchTab('login');return false;">&larr; <?php echo __('back_to_login'); ?></a>
                </div>
            </div>
        </div>
    </div>
    <?php endif; ?>

    <?php Ads::zone('mobile_sticky'); ?>
    <?php Ads::popunder(); ?>
    <?php Ads::interstitial(); ?>
    <?php Ads::push(); ?>

    <?php echo ThemeRenderer::renderJS(); ?>
    <?php HookSystem::doAction('footer.scripts'); ?>
</body>
</html>
