/* Global Elements CSS for Webgames */
/* AI MUST update this file when introducing new common UI elements like buttons, forms, badges */
/* Badges / Labels */
html {
    overflow-x: hidden;
}

.wg-label {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 3px;
    color: #fff;
    line-height: 1;
    z-index: 3;
    position: absolute;
    top: -5px;
    left: -5px;
}

.wg-label-hot {
    background: linear-gradient(45deg, #ff4757, #ff6b81);
    box-shadow: 0 0 5px rgba(255, 71, 87, 0.5);
}

.wg-label-new {
    background: linear-gradient(45deg, #3eb752, #58d16b);
    box-shadow: 0 0 5px rgba(62, 183, 82, 0.5);
}

/* Forms Elements - Global Synchronized Styles */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
textarea,
select,
.wp-block-search__input {
    background-color: var(--m3-surface-container-high, #2B2F36);
    color: #ffffff;
    border: 1px solid #485460;
    border-radius: 6px;
    padding: 10px 15px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus,
.wp-block-search__input:focus {
    outline: none;
    border-color: var(--m3-primary, #076EFF);
    box-shadow: 0 0 0 1px var(--m3-primary, #076EFF);
}

::placeholder {
    color: var(--m3-on-surface-variant, #C4C7C5);
    opacity: 1;
    /* Override Firefox default opacity */
}

/* Maintain backward compatibility for custom form classes */
.wg-form-control {
    /* Styles are now inherited from the global block above */
}

/* Buttons */
.wg-btn-primary {
    background: #0fb9b1;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.wg-btn-primary:hover {
    background: #2bcbba;
}

.wg-btn-primary:active {
    transform: scale(0.95);
}

/* Dashboard Layout Architecture */
:where(.wp-site-blocks)>* {
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
}

.wg-body-container {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    min-height: calc(100vh - var(--wg-header-height));
    /* Adjust based on header height */
    position: relative;
    overflow-x: clip;
    margin-top: 0 !important;
}

/* Sidebar Template Part Sticky Wrapper (Fallback) */
.wp-block-template-part:has(.wg-sidebar-vertical) {
    z-index: 90;
}

.wg-sidebar-vertical {
    width: 220px;
    flex-shrink: 0;
    transition: margin-left 0.3s ease, width 0.3s ease;
    box-sizing: border-box;
    margin-top: 0 !important;
    position: sticky;
    top: var(--wg-header-height);
    height: calc(100vh - var(--wg-header-height));
    z-index: 90;
}

/* Sidebar Overlay for Mobile */
.wg-sidebar-overlay {
    position: fixed;
    top: var(--wg-header-height);
    left: 0;
    width: 100vw;
    height: calc(100vh - var(--wg-header-height));
    background: rgba(0, 0, 0, 0.5);
    z-index: 98;
    /* Below sidebar's 99 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wg-sidebar-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

.wg-sidebar-inner {
    width: 220px;
    height: 100%;
    background: #111418;
    border-right: 1px solid #1e272e;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.wg-sidebar-scroll-area {
    flex-grow: 1;
    padding: 10px;
}

.wg-sidebar-footer {
    flex-shrink: 0;
    padding-block-end: 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #111418;
    /* Ensure footer has background */
    position: relative;
    z-index: 5;
}

/* Footer navigation - horizontal link layout */
.wg-sidebar-footer .wp-block-navigation__container {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 0;
}

.wg-sidebar-footer .wp-block-navigation-item {
    flex: 0 0 auto;
}

.wg-sidebar-footer .wp-block-navigation-item__label {
    padding-left: 20px;
}

/* Hide footer text gracefully in mini mode */
.wg-sidebar-vertical .wg-sidebar-copyright,
.wg-sidebar-vertical .wp-block-social-links {
    transition: opacity 0.2s, visibility 0.2s;
}

.wg-sidebar-vertical:hover .wg-sidebar-copyright,
.wg-sidebar-vertical:hover .wp-block-social-links {
    opacity: 1;
    visibility: visible;
}

/* Custom Scrollbar for Sidebar */
.wg-sidebar-inner {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color 0.3s ease;
}

.wg-sidebar-inner:hover {
    scrollbar-color: #485460 transparent;
}

.wg-sidebar-inner::-webkit-scrollbar {
    width: 6px;
}

.wg-sidebar-inner::-webkit-scrollbar-track {
    background: transparent;
}

.wg-sidebar-inner::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
}

.wg-sidebar-inner:hover::-webkit-scrollbar-thumb {
    background: #485460;
}

.wg-sidebar-inner::-webkit-scrollbar-thumb:hover {
    background: #a4b0be;
}

/* Base Hidden State (Desktop & Tablet) */
.wg-sidebar-vertical.is-hidden {
    margin-left: -220px;
}

.wg-main-column {
    flex-grow: 1;
    min-width: 0;
    /* Prevents flex children from overflowing */
    padding: 0;
}

/* Sticky Header targeting Template Part */
.wp-block-template-part:has(.wg-top-header) {
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Handle WP Admin Bar (Desktop) */
@media screen and (min-width: 783px) {
    body.admin-bar .wp-block-template-part:has(.wg-top-header) {
        top: 32px;
    }

    body.admin-bar .wg-sidebar-vertical,
    body.admin-bar .wg-sidebar-overlay {
        top: calc(32px + var(--wg-header-height));
        /* 32px admin bar + header */
        height: calc(100vh - (32px + var(--wg-header-height)));
    }
}

/* Handle WP Admin Bar (Mobile & Tablet Portrait) */
@media screen and (max-width: 782px) {

    /* Force Admin bar to be fixed to prevent layout gaps when scrolling */
    #wpadminbar {
        position: fixed !important;
        top: 0 !important;
    }

    body.admin-bar .wp-block-template-part:has(.wg-top-header) {
        top: 46px;
        /* Admin bar height on mobile */
    }

    body.admin-bar .wg-sidebar-vertical,
    body.admin-bar .wg-sidebar-overlay {
        top: calc(46px + var(--wg-header-height));
        height: calc(100vh - (46px + var(--wg-header-height)));
    }
}

/* Category Menu */
.wg-cat-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Adjust spacing for adjacent discover menus */
ul.wg-cat-menu.wg-discover-menu {
    margin-bottom: 0 !important;
}

nav.wp-block-navigation.wg-cat-menu.wg-discover-menu ul.wp-block-navigation__container {
    position: relative;
    margin-top: 16px !important;
    padding-top: 16px !important;
    margin-bottom: 16px !important;
    padding-bottom: 16px !important;
    gap: 0 !important;
}

nav.wp-block-navigation.wg-cat-menu.wg-discover-menu ul.wp-block-navigation__container::before,
nav.wp-block-navigation.wg-cat-menu.wg-discover-menu ul.wp-block-navigation__container::after {
    content: '';
    position: absolute;
    left: 16px;
    right: 16px;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    /* M3 Outline Variant */
}

nav.wp-block-navigation.wg-cat-menu.wg-discover-menu ul.wp-block-navigation__container::before {
    top: 0;
}

nav.wp-block-navigation.wg-cat-menu.wg-discover-menu ul.wp-block-navigation__container::after {
    bottom: 0;
}

/* Ensure Gutenberg flex list items take full width */
.wg-sidebar-vertical .wp-block-navigation-item {
    width: 100%;
}

.wg-sidebar-vertical ul.wg-cat-menu {
    gap: 0 !important;
}


.wg-sidebar-vertical .wg-cat-menu li a,
.wg-sidebar-vertical .wp-block-navigation-item__content {
    display: flex;
    align-items: center;
    padding: 10px;
    gap: 10px;
    color: #E6E1E5 !important;
    /* M3 On-surface variant */
    transition: background 0.2s, color 0.2s;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none !important;
    width: 100%;
}

.wg-sidebar-vertical .wg-cat-menu li a:hover,
.wg-sidebar-vertical .wp-block-navigation-item__content:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    /* M3 State Layer */
    color: #fff !important;
}

.wg-sidebar-vertical .wg-cat-menu li.active a,
.wg-sidebar-vertical .wp-block-navigation-item.current-menu-item>.wp-block-navigation-item__content {
    background: rgba(255, 255, 255, 0.12) !important;
    color: #fff !important;
}

.wg-sidebar-vertical .wg-cat-menu li a .dashicons,
.wg-sidebar-vertical .wp-block-navigation-item__content .dashicons {
    color: #CAC4D0;
    /* M3 Icon color */
    transition: color 0.2s;
}

.wg-sidebar-vertical .wg-cat-menu li a:hover .dashicons,
.wg-sidebar-vertical .wp-block-navigation-item__content:hover .dashicons {
    color: #fff;
}

.wg-sidebar-vertical .wg-cat-menu li.active a .dashicons,
.wg-sidebar-vertical .wp-block-navigation-item.current-menu-item>.wp-block-navigation-item__content .dashicons {
    color: #fff;
}

/* Base Headings */
.wg-sidebar-vertical .wg-cat-heading {
    color: #CAC4D0;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* Breadcrumbs */
.wg-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.wg-breadcrumb-sep {
    margin: 0 8px;
    color: #a4b0be;
    font-size: 14px;
}

.wg-breadcrumb-home {
    color: #ff4757;
    text-decoration: none;
    font-size: 14px;
}

.wg-breadcrumb-home .dashicons {
    font-size: 16px;
    line-height: inherit;
}

.wg-breadcrumb-cat {
    color: #a4b0be;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s;
}

.wg-breadcrumb-cat:hover {
    color: #ff4757;
}

.wg-breadcrumb-current {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

/* Base Icon Wrapper */
.wg-cat-icon-wrapper,
.wg-sidebar-vertical .wp-block-navigation-item .dashicons {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.wg-sidebar-vertical .wg-cat-menu .wg-cat-icon-wrapper img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    /* Ensure image isn't distorted */
}

.wg-sidebar-vertical .wg-cat-menu .wg-cat-icon-wrapper .dashicons {
    width: 24px;
    height: 24px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Unified Sidebar Structure (Desktop & Tablet) */
@media (min-width: 992px) {

    .wg-sidebar-inner,
    .wg-sidebar-scroll-area {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .wg-cat-icon-wrapper,
    .wg-sidebar-vertical .wp-block-navigation-item .dashicons {
        width: 56px;
    }

    .wg-cat-menu li a,
    .wg-sidebar-vertical .wp-block-navigation-item__content {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        padding-left: 0 !important;
        padding-right: 16px !important;
        gap: 0 !important;
        border-radius: 100px !important;
        height: 42px;
        box-sizing: border-box;
    }


}

.wg-sidebar-vertical .wg-cat-heading,
.wg-sidebar-vertical .wg-sidebar-copyright {
    padding-left: 20px;
    padding-right: 20px;
}

.wg-sidebar-copyright,
.wg-sidebar-copyright .wp-block-paragraph {
    font-size: 12px !important;
}

/* Mini Mode: Laptop / Tablet Landscape (992px - 1599px) */
@media (max-width: 1599px) and (min-width: 992px) {
    .wg-sidebar-vertical {
        width: 56px;
    }

    .wg-sidebar-inner {
        width: 56px;
        position: absolute;
        left: 0;
        top: 0;
    }

    /* Hide Text gracefully */
    .wg-sidebar-vertical .wg-cat-text,
    .wg-sidebar-vertical .wp-block-navigation-item__label {
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s, visibility 0.2s;
        white-space: nowrap;
    }

    .wg-sidebar-vertical .wg-cat-heading,
    .wg-sidebar-vertical .wg-sidebar-copyright,
    .wg-sidebar-vertical .wp-block-social-links {
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s, visibility 0.2s;
    }

    /* Expand on Hover */
    .wg-sidebar-vertical:hover .wg-sidebar-inner {
        width: 220px;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .wg-sidebar-vertical:hover .wg-cat-text,
    .wg-sidebar-vertical:hover .wp-block-navigation-item__label,
    .wg-sidebar-vertical:hover .wg-cat_heading,
    .wg-sidebar-vertical:hover .wp-block-social-links {
        opacity: 1;
        visibility: visible;
    }

    /* Override hidden state for mini mode */
    .wg-sidebar-vertical.is-hidden {
        margin-left: -56px;
    }
}

/* Global style for sidebar social links */
.wp-block-social-link a {
    background-color: #2f3542;
    height: 32px;
}

.wg-sidebar-vertical .wp-block-social-links {
    padding-left: 20px;
    margin-block-start: 0.6rem;
}

.wp-block-social-links .wp-social-link a {
    width: 28px;
    height: 28px;
    line-height: 28px;
    border-radius: 50%;
    justify-content: center;
}

/* Mobile Responsive */
@media (max-width: 991px) {
    .wp-block-template-part:has(.wg-sidebar-vertical) {
        position: static;
        height: auto;
    }

    .wg-sidebar-vertical {
        position: fixed;
        left: 0;
        z-index: 99;
        margin-left: -220px;
        width: 220px;
    }

    .wg-sidebar-inner {
        width: 220px;
    }

    .wg-sidebar-vertical.is-mobile-open {
        margin-left: 0;
    }

    .wg-header-center {
        display: none;
        /* Hide search on mobile or make it smaller */
    }
}

/* Back to Top Button */
.wg-btn-back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 45px;
    height: 45px;
    background: linear-gradient(45deg, #ff4757, #ff6b81);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, box-shadow 0.2s ease;
    box-shadow: 0 5px 15px rgba(255, 71, 87, 0.4);
}

.wg-btn-back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.wg-btn-back-to-top:hover {
    box-shadow: 0 5px 20px rgba(255, 71, 87, 0.6);
    transform: translateY(-3px);
}

.wg-btn-back-to-top:active {
    transform: translateY(0);
}

/* Mobile adjust */
@media (max-width: 767px) {
    .wg-btn-back-to-top {
        bottom: 20px;
        right: 20px;
    }
}

/* ==========================================
   GAME SLIDER SECTIONS
   ========================================== */
.wg-slider-section {
    margin-bottom: 0;
    padding-bottom: 0;
}

.wg-section-header {
    display: flex;
    justify-content: flex-start;
    align-items: flex-end;
    /* Align bottom to look natural next to larger text */
    gap: 15px;
    margin-bottom: 15px;
}

.wg-section-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wg-section-title .dashicons {
    color: #ff4757;
}

.wg-section-title img.wg-slider-cat-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
}

.wg-view-more {
    color: #a4b0be;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.wg-view-more:hover {
    color: #ff4757;
}

.wg-view-more .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-top: 2px;
}

/* Horizontal Scroll Container */
.wg-game-slider {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    /* Hide by default in Firefox */
    transition: scrollbar-color 0.3s ease;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 15px;
    /* space for scrollbar */
    cursor: grab;
    user-select: none;
    /* Prevent text selection while dragging */
}

/* Show scrollbar on hover or active (drag) in Firefox */
.wg-game-slider:hover,
.wg-game-slider.active {
    scrollbar-color: #ff4757 #111418;
}

.wg-game-slider.active {
    cursor: grabbing;
    scroll-snap-type: none;
    /* Disable snap for free mode */
}

/* Prevent hover conflicts while dragging without breaking click events */
.wg-game-slider.active .wg-game-card:hover .wg-sidebar-thumb {
    transform: none;
}

.wg-game-slider.active .wg-game-card:hover .wg-sidebar-thumb-container {
    border-color: #232323;
}

.wg-game-slider.active .wg-game-card:hover .wg-sidebar-overlay {
    opacity: 0;
}

/* Prevent native image dragging in sliders */
.wg-game-slider img,
.wg-game-slider a {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* Custom Scrollbar for webkit */
.wg-game-slider::-webkit-scrollbar {
    height: 4px;
}

/* Hide webkit scrollbar by default */
.wg-game-slider::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}

.wg-game-slider::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 10px;
}

/* Show webkit scrollbar on hover or active (drag) */
.wg-game-slider:hover::-webkit-scrollbar-track,
.wg-game-slider.active::-webkit-scrollbar-track {
    background: #111418;
}

.wg-game-slider:hover::-webkit-scrollbar-thumb,
.wg-game-slider.active::-webkit-scrollbar-thumb {
    background: #ff4757;
}

/* Cards inside slider */
.wg-game-slider .wg-game-card {
    flex: 0 0 calc((100% / 6.25) - 15px);
    scroll-snap-align: start;
    min-width: 120px;
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .wg-game-slider .wg-game-card {
        flex: 0 0 calc((100% / 5.25) - 15px);
    }
}

@media (max-width: 992px) {
    .wg-game-slider .wg-game-card {
        flex: 0 0 calc((100% / 4.25) - 15px);
    }
}

@media (max-width: 767px) {
    .wg-game-slider .wg-game-card {
        flex: 0 0 calc((100% / 3.25) - 15px);
    }
}

@media (max-width: 480px) {
    .wg-game-slider .wg-game-card {
        flex: 0 0 calc((100% / 2.25) - 15px);
    }
}

/* Slider specific hover effects (Scale image only) */
.wg-game-slider .wg-game-card {
    transition: none;
    /* Disable general card transition if any */
}

.wg-game-slider .wg-game-card:hover {
    transform: none;
    /* Override player.css global card scale */
    z-index: 10;
}

.wg-game-slider .wg-sidebar-thumb {
    transition: transform 0.3s ease;
}

.wg-game-slider .wg-game-card:hover .wg-sidebar-thumb {
    transform: scale(1.1);
    /* Scale only the image */
}

.wg-game-slider .wg-label {
    top: 6px;
    left: 6px;
}

/* Ẩn các thẻ p tự sinh rỗng do wpautop của WordPress gây ra */
.wg-sidebar-thumb-container p:empty {
    display: none !important;
}

/* Center Ads */
.webgames-under-player-ad {
    text-align: center;
}

/* AJAX Fade Animations */
.wg-fade-content {
    transition: opacity 0.3s ease;
}

.wg-fade-out {
    opacity: 0.3;
}

/* Failsafe to prevent Gutenberg from double-padding wg-box-dark */
.wg-box-dark.has-global-padding {
    padding: 20px !important;
}


.wp-block-comment-content {
    font-size: clamp(0.8rem, 1.5vw + 0.4rem, 0.9rem) !important;
    line-height: 1.6;
    color: var(--wg-text-muted);
}