/* ===== NGEMS STICKY MENU CSS ===== */
#ngems-sticky-menu * {
    box-sizing: border-box;
}

#ngems-sticky-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#ngems-sticky-menu a {
    text-decoration: none;
    color: inherit;
}

/* ===== MAIN WRAPPER ===== */
.ngems-sticky-wrapper {
    position: fixed;
    top: 50%;
    z-index: 99999;
    transition: transform 0.3s var(--sticky-transition, cubic-bezier(0.4, 0, 0.2, 1));
    pointer-events: none;
}

.ngems-sticky-wrapper.pos-left {
    left: 0;
    transform: translateY(-50%);
}

/* ===== TOGGLE BUTTON ===== */
.sticky-menu-toggle {
    position: absolute;
    background: var(--sticky-primary, #2563eb);
    color: #fff;
    border: none;
    padding: 14px 18px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s var(--sticky-transition, cubic-bezier(0.4, 0, 0.2, 1));
    display: none !important;
    z-index: 10;
    pointer-events: auto;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    align-items: center;
    gap: 8px;
    min-height: 48px;
    writing-mode: horizontal-tb;
}

.sticky-menu-toggle:hover {
    background: var(--sticky-primary-hover, #1d4ed8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pos-left .sticky-menu-toggle {
    left: 0;
    bottom: 50%;
    transform-origin: left bottom;
    transform: rotate(90deg) translateX(-100%);
    border-radius: 0 0 4px 4px;
}

.is-active .sticky-menu-toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.pos-left.is-active .sticky-menu-toggle {
    transform: rotate(90deg) translateX(-100%) scale(0.8);
}

.sticky-menu-toggle .menu-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sticky-menu-toggle .toggle-text {
    flex-shrink: 0;
}

/* ===== MENU INNER ===== */
.sticky-menu-inner {
    background: var(--sticky-bg, #ffffff);
    width: var(--sticky-width, 180px);
    height: var(--sticky-height, 100vh);
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s var(--sticky-transition, cubic-bezier(0.4, 0, 0.2, 1));
    pointer-events: auto;
    overflow: visible;
}

.pos-left .sticky-menu-inner {
    border-radius: 0 8px 8px 0;
}

/* ===== COLLAPSE BUTTON STYLE ===== */
.sticky-menu-collapse-btn {
    position: absolute;
    top: 50%;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    background: var(--sticky-bg, #ffffff);
    border: 1px solid var(--sticky-border, #e5e7eb);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--sticky-text, #1f2937);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.4s var(--sticky-transition, cubic-bezier(0.4, 0, 0.2, 1));
    z-index: 10002;
    pointer-events: auto;
    padding: 0;
    flex-shrink: 0;
    line-height: 0;
    outline: none;
}

.sticky-menu-collapse-btn:hover {
    background: var(--sticky-primary, #2563eb);
    color: #fff;
    border-color: var(--sticky-primary, #2563eb);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.pos-left .sticky-menu-collapse-btn {
    left: 100%;
    transform: translate(-50%, -50%);
}

.ngems-sticky-wrapper.is-collapsed .sticky-menu-inner {
    transform: translateX(-100%);
}

.is-collapsed.pos-left .sticky-menu-collapse-btn {
    transform: translate(-15%, -50%);
    border-radius: 0 50% 50% 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
}

.is-collapsed .sticky-menu-collapse-btn .collapse-icon {
    transform: rotate(180deg);
}

.is-collapsed .sticky-menu-inner {
    box-shadow: none;
}

/* Fix Admin Bar */
body.admin-bar .ngems-sticky-wrapper {
    top: 32px !important;
    height: calc(100vh - 32px) !important;
    transform: none !important;
}

body.admin-bar .sticky-menu-inner {
    height: calc(100vh - 32px) !important;
    top: 0 !important;
    transform: none;
}

body.admin-bar .is-collapsed .sticky-menu-inner {
    transform: translateX(-100%);
}

@media screen and (max-width: 782px) {
    body.admin-bar .ngems-sticky-wrapper {
        top: 46px !important;
        height: calc(100vh - 46px) !important;
    }
}

@media (max-width: 767px) {
    .sticky-menu-collapse-btn {
        display: none !important;
    }
}

/* ===== HEADER ===== */
.sticky-menu-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--sticky-primary, #2563eb) 0%, var(--sticky-primary-hover, #1d4ed8) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sticky-menu-header h3 {
    margin: 0;
    font-size: 16px;
    color: #fff;
    font-weight: 600;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sticky-menu-header .header-icon {
    width: 20px;
    height: 20px;
}

.sticky-menu-close {
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: all 0.2s ease;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent;
}

.sticky-menu-close:hover {
    transform: rotate(90deg);
}

.sticky-menu-close:hover svg {
    color: #daf59cff;
}

/* ===== BODY ===== */
.sticky-menu-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--sticky-border, #e5e7eb) transparent;
}

.sticky-menu-body::-webkit-scrollbar {
    width: 6px;
}

.sticky-menu-body::-webkit-scrollbar-track {
    background: transparent;
}

.sticky-menu-body::-webkit-scrollbar-thumb {
    background: var(--sticky-border, #e5e7eb);
    border-radius: 3px;
}

.sticky-menu-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===== CATEGORY LIST ===== */
.sticky-cat-list {
    padding: 0 12px;
}

.cat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 6px;
    transition: background 0.2s;
}

.cat-row:hover {
    background: var(--sticky-hover-bg, #f3f4f6);
}

.cat-item a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--sticky-text, #1f2937);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    gap: 8px;
    flex: 1;
}

.cat-item a:hover {
    color: var(--sticky-primary, #2563eb);
    transform: translateX(4px);
}

.cat-item.current-cat > .cat-row {
    background: var(--sticky-hover-bg, #f3f4f6);
    border-left: 3px solid var(--sticky-primary, #2563eb);
}

.cat-item.current-cat > .cat-row a {
    color: var(--sticky-primary, #2563eb);
    font-weight: 700;
}

.cat-item.current-cat .cat-count {
    color: var(--sticky-primary, #2563eb);
    opacity: 0.8;
}

.dev-cat-id {
    font-size: 10px;
    background: #f1f1f1;
    color: #666;
    padding: 2px 4px;
    border-radius: 3px;
    margin-right: 8px;
    cursor: copy;
    font-family: monospace;
    transition: all 0.2s;
    border: 1px solid #ddd;
    user-select: none;
    flex-shrink: 0;
    position: relative;
    z-index: 99;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
}

.dev-cat-id:hover {
    background: var(--sticky-primary, #2563eb);
    color: #fff;
    border-color: var(--sticky-primary, #2563eb);
}

.parent-cat-link {
    font-weight: 600;
}

.toggle-sub {
    width: 40px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--sticky-text-light, #6b7280);
    transition: transform 0.3s var(--sticky-transition, cubic-bezier(0.4, 0, 0.2, 1));
}

.toggle-sub:hover {
    color: var(--sticky-primary, #2563eb);
}

.has-children.is-open > .cat-row .toggle-sub {
    transform: rotate(180deg);
    color: var(--sticky-primary, #2563eb);
}

.cat-count {
    font-size: 12px;
    color: var(--sticky-text-light, #6b7280);
    font-weight: 400;
    margin-left: 5px;
}

/* ===== SUB CATEGORIES ===== */
.sub-cat-list {
    margin-top: 4px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 2px solid var(--sticky-border, #e5e7eb);
    display: none;
}

.sub-cat-list .cat-item {
    margin-bottom: 2px;
}

.child-cat-link {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 400;
}

.child-cat-link .arrow-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.child-cat-link:hover .arrow-icon {
    transform: translateX(3px);
}

.child-cat-link .cat-name {
    flex: 1;
}

/* ===== LOADING STATE ===== */
.sticky-loading {
    padding: 40px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.sticky-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--sticky-border, #e5e7eb);
    border-top-color: var(--sticky-primary, #2563eb);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.sticky-loading p {
    margin: 0;
    color: var(--sticky-text-light, #6b7280);
    font-size: 14px;
}

/* ===== EMPTY STATE ===== */
.sticky-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--sticky-text-light, #6b7280);
    font-size: 14px;
}

/* ===== OVERLAY ===== */
.sticky-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* ===== MOBILE & TABLET: LUÔN ẨN ===== */
@media (max-width: 767px) {
    .ngems-sticky-wrapper {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .hide-on-mobile {
        display: none;
    }

    .sticky-menu-inner {
        width: 90%;
        max-width: 280px;
    }

    .sticky-menu-toggle .toggle-text {
        display: none;
    }
}

/* ===== ADMIN BAR ADJUSTMENT ===== */
body.admin-bar .ngems-sticky-wrapper {
    top: calc(50% + 16px);
}

@media screen and (max-width: 782px) {
    body.admin-bar .ngems-sticky-wrapper {
        top: calc(50% + 23px);
    }
}

@media (max-width: 767px) {
    body.admin-bar .ngems-sticky-wrapper {
        top: 0;
        height: 100vh;
    }

    body.admin-bar .sticky-menu-inner {
        top: 46px;
        height: calc(100vh - 46px);
    }
}

@media screen and (max-width: 600px) {
    body.admin-bar .sticky-menu-inner {
        top: 0;
        height: 100vh;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .ngems-sticky-wrapper,
    .sticky-menu-inner,
    .sticky-menu-toggle,
    .sticky-menu-overlay,
    .cat-item a {
        transition: none;
    }
}

/* ===== PRINT ===== */
@media print {
    .ngems-sticky-wrapper {
        display: none;
    }
}
