/* =============================================
   Category Navigator v1.2 — Frontend
   Screenshot-matched sidebar design
   ============================================= */

/* ---- WRAPPER ---- */
.catnav-wrap {
    display: flex;
    background: #fff;
    position: relative;
    font-family: inherit;
}
.catnav-sidebar-right { flex-direction: row-reverse; }

/* =============================================
   SIDEBAR — exactly like screenshot:
   white bg, each item separated by a line,
   bold active item, arrow on right
   ============================================= */
.catnav-sidebar {
    width: 280px;
    min-width: 280px;
    background: #ffffff;
    border-right: 1px solid #e8e8e8;
    flex-shrink: 0;
    /* CRITICAL: overflow must be visible for flyout */
    overflow: visible;
    position: relative;
    z-index: 100;
}
.catnav-sidebar-right .catnav-sidebar {
    border-right: none;
    border-left: 1px solid #e8e8e8;
}

/* ---- CATEGORY ITEM ---- */
.catnav-cat-item {
    position: relative;
    border-bottom: 1px solid #ebebeb;
}
.catnav-cat-item:last-child { border-bottom: none; }

/* ---- CATEGORY BUTTON — screenshot style ---- */
.catnav-cat-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 13px 16px;
    background: none !important;
    border: none;
    border-left: none;
    cursor: pointer;
    text-align: left;
    color: #333333 !important;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    font-family: inherit;
    transition: background .1s, color .1s;
}
.catnav-cat-btn:hover {
    background: #f5f5f5;
    color: #000;
}
/* Active = bold, like screenshot first item */
.catnav-cat-btn.is-active {
    color: #000000;
    font-weight: 700;
    background: transparent;
}

.catnav-cat-label { flex: 1; }

/* Arrow icon on right — only for items with subcategory */
.catnav-arrow {
    font-size: 16px;
    color: #999;
    flex-shrink: 0;
    margin-left: 8px;
    line-height: 1;
    transition: color .15s;
}
.catnav-cat-item:hover .catnav-arrow { color: #333; }

/* Icon (emoji) before label */
.catnav-cat-icon {
    font-size: 15px;
    width: 22px;
    flex-shrink: 0;
    margin-right: 2px;
}

/* =============================================
   FLYOUT — appears to the RIGHT on hover
   ============================================= */
.catnav-flyout {
    position: absolute;
    left: 100%;
    top: -1px;
    min-width: 270px;
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 0 6px 6px 0;
    box-shadow: 4px 6px 20px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: none;
    padding: 4px 0 6px;
}

/* Sidebar-right: flyout goes LEFT */
.catnav-sidebar-right .catnav-flyout {
    left: auto;
    right: 100%;
    border-radius: 6px 0 0 6px;
    box-shadow: -4px 6px 20px rgba(0, 0, 0, 0.12);
}

/* Show on hover */
.catnav-cat-item.has-subs:hover > .catnav-flyout {
    display: block;
}

/* Small triangle pointer */
.catnav-flyout::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 16px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid #d0d0d0;
}
.catnav-flyout::after {
    content: '';
    position: absolute;
    left: -5px;
    top: 17px;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 5px solid #ffffff;
}
.catnav-sidebar-right .catnav-flyout::before {
    left: auto;
    right: -6px;
    border-right: none;
    border-left: 6px solid #d0d0d0;
}
.catnav-sidebar-right .catnav-flyout::after {
    left: auto;
    right: -5px;
    border-right: none;
    border-left: 5px solid #ffffff;
}

.catnav-flyout-head {
    font-size: 11px;
    font-weight: 700;
    color: #aaa;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 8px 14px 6px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 2px;
}

/* Subcategory buttons */
.catnav-sub-btn {
    display: block;
    width: 100%;
    padding: 9px 16px;
    font-size: 13.5px;
    color: #333;
    background: none;
    border: none;
    border-bottom: 1px solid #f5f5f5;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background .1s, color .1s;
}
.catnav-sub-btn:last-child { border-bottom: none; }
.catnav-sub-btn:hover {
    background: #f0f5ff !important;
    color: #0055bb !important;
}

/* =============================================
   CONTENT AREA
   ============================================= */
.catnav-content {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* ---- LOADING OVERLAY ---- */
.catnav-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.90);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.catnav-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #0066cc;
    border-radius: 50%;
    animation: catnav-spin .7s linear infinite;
}
@keyframes catnav-spin { to { transform: rotate(360deg); } }

/* ---- ERROR BOX ---- */
.catnav-error-box {
    margin: 16px;
    padding: 12px 16px;
    background: #fff3f3;
    border: 1px solid #f5c2c2;
    border-radius: 6px;
    color: #c00;
    font-size: 13px;
}

/* ---- TEMPLATE AREA ---- */
.catnav-tpl-area {
    padding: 16px;
    transition: opacity .2s;
}
.catnav-placeholder {
    color: #bbb;
    font-size: 14px;
    padding: 50px 20px;
    text-align: center;
}

/* =============================================
   RESPONSIVE — mobile stack
   ============================================= */
@media (max-width: 768px) {
    .catnav-wrap { flex-direction: column !important; }

    .catnav-sidebar {
        width: 100% !important;
        min-width: 100% !important;
        border-right: none !important;
        border-left: none !important;
        border-bottom: 1px solid #e8e8e8;
        max-height: 300px; 
        overflow-x: visible;
    }

    /* Mobile flyout — drop down below item */
    .catnav-flyout {
        position: static !important;
        width: 100% !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #f5f8ff !important;
        padding-left: 16px;
        display: none;
    }
    .catnav-flyout::before,
    .catnav-flyout::after { display: none; }

    /* On desktop hover rule disabled on mobile */
    .catnav-cat-item.has-subs:hover > .catnav-flyout { display: none; }

    /* JS adds this class on tap */
    .catnav-cat-item.has-subs.mob-open > .catnav-flyout { display: block !important; }
}
