/**
 * NowBiz Menu Sections CSS
 *
 * Section-based menu visibility for sidebar navigation.
 * Hides subitems of sections the user is not currently in.
 *
 * @package NowBiz
 * @since 1.1.0
 */

/* ===================================================================
   SECTION-BASED MENU VISIBILITY

   When in a section (CRM, Plan, Marketing, Books), show only that section's
   subitems. Other sections show only their dashboard link.
   =================================================================== */

/* Hide section submenus by default when in a NowBiz app section */
body.nowbiz-app .nowbiz-menu-module-plan > .sub-menu,
body.nowbiz-app .nowbiz-menu-module-crm > .sub-menu,
body.nowbiz-app .nowbiz-menu-module-marketing > .sub-menu,
body.nowbiz-app .nowbiz-menu-module-books > .sub-menu,
body.nowbiz-app .nowbiz-menu-module-onboarding > .sub-menu {
    display: none !important;
    max-height: 0 !important;
    overflow: hidden !important;
}

/* Show onboarding submenu only when onboarding section is active */
body.nowbiz-section-onboarding .nowbiz-menu-module-onboarding > .sub-menu {
    display: block !important;
    max-height: 2000px !important;
    overflow: visible !important;
}

/* Show only the CURRENT section's submenu */
body.nowbiz-section-plan .nowbiz-menu-module-plan > .sub-menu {
    display: block !important;
    max-height: 2000px !important;
    overflow: visible !important;
}

body.nowbiz-section-crm .nowbiz-menu-module-crm > .sub-menu {
    display: block !important;
    max-height: 2000px !important;
    overflow: visible !important;
}

body.nowbiz-section-books .nowbiz-menu-module-books > .sub-menu {
    display: block !important;
    max-height: 2000px !important;
    overflow: visible !important;
}

body.nowbiz-section-marketing .nowbiz-menu-module-marketing > .sub-menu {
    display: block !important;
    max-height: 2000px !important;
    overflow: visible !important;
}

/* On shared pages (like main dashboard), keep all module submenus collapsed */
body.nowbiz-section-shared .nowbiz-menu-module-plan > .sub-menu,
body.nowbiz-section-shared .nowbiz-menu-module-crm > .sub-menu,
body.nowbiz-section-shared .nowbiz-menu-module-marketing > .sub-menu,
body.nowbiz-section-shared .nowbiz-menu-module-books > .sub-menu,
body.nowbiz-section-shared .nowbiz-menu-module-onboarding > .sub-menu {
    display: none !important;
}

/* ===================================================================
   ONBOARDING STEPS STYLING
   =================================================================== */

/* Base onboarding step styling */
.nowbiz-onboarding-step {
    position: relative;
}

.nowbiz-onboarding-step .nowbiz-sidebar__menu-link {
    padding-left: calc(var(--nowbiz-space-4) + var(--nowbiz-space-2));
}

/* Onboarding step icon - default (pending/incomplete) */
.nowbiz-onboarding-step .nowbiz-step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--nowbiz-text-muted);
    background: transparent;
    margin-right: var(--nowbiz-space-2);
    flex-shrink: 0;
    transition: all var(--nowbiz-transition-fast);
}

/* Completed step - green checkmark */
.nowbiz-onboarding-step.nowbiz-step-completed .nowbiz-step-icon {
    border-color: var(--nowbiz-success);
    background: var(--nowbiz-success);
    color: white;
}

.nowbiz-onboarding-step.nowbiz-step-completed .nowbiz-step-icon::before {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

/* Pending step - numbered circle */
.nowbiz-onboarding-step.nowbiz-step-pending .nowbiz-step-icon {
    border-color: var(--nowbiz-text-muted);
}

/* Numbered step icons */
.nowbiz-onboarding-step .step-icon-number {
    border: none;
    background: transparent;
}

.nowbiz-onboarding-step .step-icon-number text {
    font-family: var(--nowbiz-font-sans);
}

/* Current step - highlighted */
.nowbiz-onboarding-step.current-menu-item .nowbiz-step-icon,
.nowbiz-onboarding-step.nowbiz-step-current .nowbiz-step-icon {
    border-color: var(--nowbiz-primary);
    background: var(--nowbiz-primary);
}

.nowbiz-onboarding-step.nowbiz-step-current .nowbiz-step-icon::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

/* Step 12 - Hidden until steps 1-11 complete (sidebar menu item only) */
/* Must target li.menu-item specifically to avoid affecting page content */
.nowbiz-sidebar__menu li.menu-item.nowbiz-onboarding-step-12.nowbiz-step-locked {
    display: none !important;
}

/* Onboarding section header */
.nowbiz-menu-onboarding-header {
    font-size: var(--nowbiz-text-xs);
    font-weight: var(--nowbiz-font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--nowbiz-text-muted);
    padding: var(--nowbiz-space-3) var(--nowbiz-space-4) var(--nowbiz-space-2);
    margin-top: var(--nowbiz-space-2);
}

/* ===================================================================
   TOP NAV - LOGIN/LOGOUT VISIBILITY
   =================================================================== */

/* Hide Login link when logged in */
body.logged-in .nowbiz-login-link {
    display: none !important;
}

/* Hide Logout link when logged out */
body:not(.logged-in) .nowbiz-logout-link {
    display: none !important;
}

/* Hide NowBiz Suite dropdown for logged-out users */
body:not(.logged-in) .nowbiz-suite-dropdown {
    display: none !important;
}

/* ===================================================================
   TOP NAV DROPDOWN STYLING
   =================================================================== */

/* Top nav dropdown container */
.nowbiz-topnav .menu-item-has-children {
    position: relative;
}

/* Hide dropdown by default */
.nowbiz-topnav .menu-item-has-children > .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--nowbiz-bg-elevated);
    border: var(--nowbiz-border-width) solid var(--nowbiz-border-color);
    border-radius: var(--nowbiz-radius-md);
    box-shadow: var(--nowbiz-shadow-lg);
    padding: var(--nowbiz-space-2) 0;
    z-index: var(--nowbiz-z-dropdown);
    list-style: none;
    margin: 0;
}

/* Show dropdown on hover */
.nowbiz-topnav .menu-item-has-children:hover > .sub-menu {
    display: block;
}

/* Dropdown items */
.nowbiz-topnav .sub-menu li {
    margin: 0;
    list-style: none;
}

.nowbiz-topnav .sub-menu a {
    display: block;
    padding: var(--nowbiz-space-2) var(--nowbiz-space-4);
    color: var(--nowbiz-text-primary);
    text-decoration: none;
    font-size: var(--nowbiz-text-sm);
    transition: all var(--nowbiz-transition-fast);
}

.nowbiz-topnav .sub-menu a:hover {
    background: var(--nowbiz-bg-hover);
    color: var(--nowbiz-primary);
}

/* Dropdown arrow indicator */
.nowbiz-topnav .menu-item-has-children > a::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: var(--nowbiz-space-2);
    vertical-align: middle;
    border-top: 4px solid currentColor;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
}

/* ===================================================================
   SECTION HEADER STYLING
   =================================================================== */

/* Module section headers (dashboard links) */
.nowbiz-menu-section-header > a {
    font-weight: var(--nowbiz-font-semibold) !important;
}

/* Add visual separator before each section */
.nowbiz-menu-module-onboarding,
.nowbiz-menu-module-plan,
.nowbiz-menu-module-crm,
.nowbiz-menu-module-marketing,
.nowbiz-menu-module-books {
    border-top: var(--nowbiz-border-width) solid var(--nowbiz-border-light);
    margin-top: var(--nowbiz-space-2);
    padding-top: var(--nowbiz-space-2);
}

/* First section doesn't need top border */
.nowbiz-sidebar__menu > li:first-child,
.nowbiz-sidebar .menu > li:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* ===================================================================
   DARK MODE SUPPORT
   =================================================================== */

[data-theme="dark"] .nowbiz-onboarding-step.nowbiz-step-completed .nowbiz-step-icon {
    background: var(--nowbiz-success);
    border-color: var(--nowbiz-success);
}

[data-theme="dark"] .nowbiz-topnav .sub-menu {
    background: var(--nowbiz-bg-elevated);
    border-color: var(--nowbiz-border-color);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .nowbiz-onboarding-step.nowbiz-step-completed .nowbiz-step-icon {
        background: var(--nowbiz-success);
        border-color: var(--nowbiz-success);
    }

    :root:not([data-theme="light"]) .nowbiz-topnav .sub-menu {
        background: var(--nowbiz-bg-elevated);
        border-color: var(--nowbiz-border-color);
    }
}

/* ===================================================================
   MOBILE RESPONSIVE
   =================================================================== */

@media (max-width: 767px) {
    /* Onboarding steps more compact on mobile */
    .nowbiz-onboarding-step .nowbiz-step-icon {
        width: 16px;
        height: 16px;
    }
}
