:root {
    --sidebar-width: 18rem;
    --sidebar-width-collapsed: 80px;
    --sidebar-font: 'Work Sans', 'Noto Sans JP', sans-serif;

    /* Provided Variables */
    --primary-color: #131524;
    --sidebar-text: #FFFFFF;
    /* Renamed to avoid generic 'text' conflict if possible */
    --white: #FFFFFF;
    --sidebar-primary: #9290FF;
    --sidebar-primary-light: #90DEFF;
    --sidebar-primary-hover: #605DFF10;
    --sidebar-background: #19182D;
    --background: #F1F3FF;
    --full-bg: #C7D2DC;
    --text-link: #E6E8F0;
    --exp-btn-background: #1C2035;
    --exp-btn-border: #303651;
    --exp-btn: #F4F6F9;
    --headline: #9FAEE1;
    --cta-background: #1C2035;
    --cta-background-darker: #CFD5FF;
    --cta-background-border: #303651;
    --cta-text: #605DFF1A;
    --neutral: #0C0E19;
    --search-bg: #1C2035;
    --logout: #FA7575;
    --text-lighter: #E6e8f0;
    --headline-text: #F4F6F9;
}

/* Base Body Flex for Sidebar Layout */
body.sidebar-layout {
    display: flex !important;
    flex-direction: row !important;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: var(--cyber-bg);
    /* Use existing cyber bg */
}

/* Mobile responsive adjustment */
@media (max-width: 768px) {
    body.sidebar-layout {
        flex-direction: column;
    }
}

/* Sidebar Styles */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1rem 0;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    display: flex;
    color: var(--white);
    flex-direction: column;
    background: var(--sidebar-background);
    transition: all 0.3s ease-in-out;
    z-index: 1000;
    font-family: var(--sidebar-font);
    font-size: 16px;
    overflow-y: auto;
}

.sidebar-title {
    color: #E0EAFF;
    font-weight: bold;
    font-size: 1.2rem;
    white-space: nowrap;
}

/* Collapsed State */
body.collapsed .sidebar {
    width: var(--sidebar-width-collapsed);
    min-width: var(--sidebar-width-collapsed);
}

body.collapsed .hide {
    display: none !important;
    opacity: 0;
}

/* Top Wrapper */
.sidebar-top-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    margin-bottom: 1rem;
    position: relative;
}

.logo__wrapper {
    display: flex;
    align-items: center;
    color: var(--text-link);
    font-weight: 700;
    text-decoration: none;
    font-size: 1.125rem;
    gap: 1rem;
}

.logo-small {
    height: 2.5rem;
    width: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
}

/* Toggle Button */
.expand-btn {
    display: grid;
    place-items: center;
    cursor: pointer;
    border: 1px solid var(--cta-background-border);
    background: var(--exp-btn-background);
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    transition: 0.3s;
}

.expand-btn svg {
    transform: rotate(-180deg);
    stroke: var(--exp-btn);
    width: 1.25rem;
    height: 1.25rem;
    transition: 0.3s;
}

body.collapsed .expand-btn svg {
    transform: rotate(0deg);
}

/* Search */
.search__wrapper {
    padding: 0 1rem;
    position: relative;
    margin-bottom: 1rem;
}

.search__wrapper input {
    background: var(--search-bg);
    height: 2.5rem;
    width: 100%;
    border-radius: 0.5rem;
    padding: 0 0.5rem 0 2.5rem;
    color: white;
    outline: none;
    border: none;
}

.search__wrapper svg {
    position: absolute;
    top: 50%;
    left: 1.5rem;
    transform: translateY(-50%);
    pointer-events: none;
}

body.collapsed .search__wrapper input {
    padding: 0;
    text-align: center;
    cursor: pointer;
}

body.collapsed .search__wrapper svg {
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Links */
.sidebar-links {
    width: 100%;
    padding: 0 1rem;
    margin-bottom: 1rem;
}

.sidebar-links h2 {
    color: var(--headline);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-links ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0;
}

.sidebar-links li a {
    color: var(--text-link);
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: background 0.2s;
    gap: 1rem;
}

.sidebar-links li a:hover,
.sidebar-links li a.active {
    background: var(--sidebar-primary-hover);
    color: var(--sidebar-primary-light);
}

.sidebar-links li a svg {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip__content {
    visibility: hidden;
    background: var(--primary-color);
    color: white;
    text-align: center;
    border-radius: 4px;
    padding: 5px 10px;
    position: absolute;
    z-index: 1001;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
}

body.collapsed .tooltip:hover .tooltip__content {
    visibility: visible;
    opacity: 1;
}

/* Bottom Profile */
.sidebar__profile {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
}

.avatar__name {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.email {
    font-size: 0.75rem;
    color: var(--text-lighter);
}

/* Main Content Wrapper (To sit beside sidebar) */
.content-wrapper {
    flex-grow: 1;
    padding: 0;
    overflow-y: auto;
    /* Independent scrolling */
    height: 100vh;
    position: relative;
}

/* =========================================
   Fix for Shop Search Filter Layout
   ========================================= */
/* Ensure the first filter row (Darts Machine) shows its label and has proper spacing */
body[data-page-type="shops-list"] .players-search .chips-scroll[aria-label]:first-of-type {
    padding-top: 18px !important;
    margin-top: 16px !important;
}

body[data-page-type="shops-list"] .players-search .chips-scroll[aria-label]:first-of-type::after {
    display: inline-block !important;
}

/* Responsive */
/* Responsive Sidebar Redesign */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        /* top, right, bottom, left -> top:0, bottom:0, left:0 */
        width: fit-content;
        min-width: 240px;
        max-width: 85vw;
        overflow-x: hidden;

        height: 100dvh;
        /* dynamic viewport height */
        transform: translateX(-100%);
        flex-direction: column;
        padding: 1rem 0;
        border-radius: 0 16px 16px 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
        background: var(--sidebar-background);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 10000;
        overflow-y: auto;
    }

    body.mobile-sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Overlay */
    body.mobile-sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(2px);
        z-index: 9999;
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    /* Restore elements hidden in previous mobile design */
    .sidebar-top-wrapper,
    .sidebar__profile,
    .search__wrapper,
    .sidebar-links h2 {
        display: flex;
    }

    .sidebar-links h2 {
        display: block;
    }

    /* Adjust top wrapper for mobile */
    .sidebar-top-wrapper {
        justify-content: flex-start;
        gap: 12px;
    }

    /* Hide the PC collapse button on mobile */
    .expand-btn {
        display: none;
    }

    .sidebar-links {
        padding: 0 1rem;
        margin-bottom: 1rem;
        width: 100%;
    }

    .sidebar-links ul {
        flex-direction: column;
        justify-content: flex-start;
        gap: 0.5rem;
    }

    .sidebar-links li a {
        flex-direction: row;
        padding: 0.75rem 1rem;
        font-size: 1rem;
        gap: 1rem;
        justify-content: flex-start;
    }

    .sidebar-links li a svg {
        margin-bottom: 0;
    }

    .hide {
        display: inline !important;
        /* Show text labels */
    }

    .content-wrapper {
        padding-bottom: 0px;
        /* Remove bottom padding */
    }
}

/* Mobile Toggle Button (Fab / Fixed) */
.mobile-menu-btn {
    display: none;
    /* Hidden on PC */
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 24px;
        left: 24px;
        width: 56px;
        height: 56px;
        background: var(--sidebar-primary);
        color: #fff;
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 10001;
        /* Above sidebar */
        border: none;
        cursor: pointer;
        transition: transform 0.2s, background 0.2s;
    }

    .mobile-menu-btn:active {
        transform: scale(0.95);
    }

    .mobile-menu-btn svg {
        width: 28px;
        height: 28px;
        transition: transform 0.3s;
    }

    /* Transform to Close button when open */
    body.mobile-sidebar-open .mobile-menu-btn {
        background: var(--logout);
        /* Red to indicate Close */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    /* Rotate icon if using specific SVG animation, or just rely on JS swap */
    body.mobile-sidebar-open .mobile-menu-btn svg {
        transform: rotate(90deg);
    }
}