/* ═══════════════════════════════════════════════════════════
   NAVIGATION / SIDEBAR  –  nav.css
   Shell (#sidebar width, bg gradient, slide) in payroll.css.
   All #sidebar selectors here beat payroll.css specificity.
═══════════════════════════════════════════════════════════ */

/* ── Logo ── */
#sidebar .nv-logo {
    padding: 22px 20px 14px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    margin-bottom: 8px;
}

#sidebar .nv-logo a {
    display: block;
    text-decoration: none;
}

#sidebar .nv-logo-img {
    display: block;
    width: 210px;
    height: auto;
    max-height: 72px;
    object-fit: contain;
}

/* ── Topbar (navy bar inside #content — mobile only) ── */
.nv-topbar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    margin: 0 -3rem;
    background: linear-gradient(135deg, #002647 0%, #003c62 100%);
    border-bottom: 2px solid #f8b739;
}

/* ── Sidebar backdrop (mobile only) ── */
.nv-backdrop {
    display: none;
}

.nv-topbar-tenant {
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: .3px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nv-topbar-title {
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: .3px;
    color: rgba(255,255,255,.65);
    position: relative;
    padding-left: 13px;
}

/* amber left accent bar */
.nv-topbar-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10%;
    height: 80%;
    width: 3px;
    background: #f8b739;
    border-radius: 2px;
}

.nv-topbar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 8px;
    color: #fff;
    font-size: .9rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}

/* Only apply hover on devices with a real pointer (desktop) */
@media (hover: hover) {
    .nv-topbar-toggle:hover {
        background: rgba(255,255,255,.18);
        border-color: rgba(255,255,255,.3);
    }
}

/* Touch-press feedback for mobile */
.nv-topbar-toggle:active {
    background: rgba(255,255,255,.22);
    border-color: rgba(255,255,255,.35);
}

@media (max-width: 991.98px) {
    /* Topbar: sticky so it stays visible while scrolling */
    .nv-topbar {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 1040;
        /* Match #content pl-5 = 3rem on ≥577px */
        margin: 0 -3rem;
        padding: 10px 20px;
    }

    .nv-topbar-toggle {
        display: flex;
    }

    /* Sidebar drawer — fixed overlay below topbar.
       !important overrides payroll.css bundle rules.
       translateX hides/shows without affecting flex layout. */
    #sidebar {
        position: fixed !important;
        top: 56px !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 300px !important;
        min-width: 0 !important;
        max-width: none !important;
        margin-left: 0 !important;
        z-index: 1050;
        overflow-y: auto;
        border-top-right-radius: 12px;
        transform: translateX(-100%);
        transition: transform .3s ease;
    }
    #sidebar.active {
        transform: translateX(0);
    }

    /* Content + all child wrappers must fill entire viewport on mobile */
    #content {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }
    .table-responsive,
    .dataTables_wrapper,
    .ts-approved-table {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Dark overlay behind sidebar */
    .nv-backdrop {
        display: block;
        position: fixed;
        top: 56px;          /* match sidebar top */
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1045;      /* between content and sidebar */
        background: rgba(0,0,0,.45);
        opacity: 0;
        visibility: hidden;
        transition: opacity .3s, visibility .3s;
        pointer-events: none;
    }
    .nv-backdrop.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Bootstrap modals + backdrops — above sidebar on mobile */
    .modal {
        top: 56px;
        z-index: 1060;
        -webkit-overflow-scrolling: touch;
    }
    .modal-backdrop {
        top: 56px;
        z-index: 1055;
    }

    /* Prevent horizontal scroll caused by sidebar slide */
    .wrapper {
        overflow-x: hidden;
    }
}

/* Phone: pl-5 overridden to 12px in payroll.css */
@media (max-width: 576px) {
    .nv-topbar {
        margin: 0 -12px;
        padding: 10px 12px;
    }
}

/* ── User row ── */
#sidebar .nv-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 11px;
    margin: 0 8px 6px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 12px;
}

#sidebar .nv-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f8b739 0%, #d9922a 100%);
    border: 2px solid rgba(255,255,255,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .5px;
    text-transform: uppercase;
    box-shadow: 0 2px 10px rgba(248,183,57,.45);
}

#sidebar .nv-username {
    flex: 1;
    font-size: .82rem;
    font-weight: 600;
    color: rgba(255,255,255,.82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

#sidebar .nv-logout-btn {
    flex-shrink: 0;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 7px;
    color: rgba(255,255,255,.75);
    padding: 5px 10px;
    cursor: pointer;
    font-size: .82rem;
    line-height: 1;
    transition: background .15s, color .15s, border-color .15s;
}

#sidebar .nv-logout-btn:hover {
    background: rgba(220,38,38,.25);
    color: #fca5a5;
    border-color: rgba(220,38,38,.45);
}

/* ── Nav menu ── */
#sidebar .nv-menu {
    list-style: none;
    padding: 4px 0 8px;
    margin: 0;
}

#sidebar .nv-item {
    margin: 1px 0;
}

/* Floating rounded links — beats payroll.css #sidebar ul li a */
#sidebar .nv-link {
    display: flex;
    align-items: center;
    margin: 0 10px;
    padding: 10px 14px;
    border-radius: 10px;
    color: rgba(255,255,255,.68);
    text-decoration: none;
    font-size: .9rem;
    border-bottom: none;
    transition: background .15s, color .15s;
    position: relative;
}

#sidebar .nv-link:hover,
#sidebar .nv-link:focus {
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.95);
    text-decoration: none;
}

/* Active item — amber filled pill */
#sidebar .nv-item.active > .nv-link {
    background: rgba(248,183,57,.16);
    color: #f8b739;
    font-weight: 600;
    border-left: none;
    padding-left: 14px;
}

/* Section divider label */
#sidebar .nv-section-label {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: rgba(255,255,255,.28);
    padding: 14px 24px 4px;
}

/* Submenu chevron */
#sidebar .nv-has-submenu {
    padding-right: 36px;
}

#sidebar .nv-has-submenu::after {
    content: "›";
    position: absolute;
    right: 14px;
    font-size: 1rem;
    opacity: .45;
    transition: transform .2s;
    line-height: 1;
}

#sidebar .nv-has-submenu[aria-expanded="true"]::after {
    transform: rotate(90deg);
}

/* ── Submenu — tree line style ── */
/* .submenu class kept for payroll.js setNavigation() */
#sidebar .nv-submenu {
    list-style: none;
    margin: 2px 10px 4px 28px;
    padding: 4px 0 2px 14px;
    border-left: 1.5px solid rgba(248,183,57,.22);
}

#sidebar .nv-subitem {
    margin: 1px 0;
}

#sidebar .nv-sublink {
    display: block;
    padding: 7px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,.52);
    text-decoration: none;
    font-size: .85rem;
    border-bottom: none;
    transition: background .15s, color .15s;
}

#sidebar .nv-sublink:hover,
#sidebar .nv-sublink:focus {
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.88);
    text-decoration: none;
}

#sidebar .nv-subitem.active > .nv-sublink {
    color: #f8b739;
    background: rgba(248,183,57,.1);
}

/* ── Account / contract section ── */
#sidebar .nv-account {
    margin: 8px 10px 0;
    padding: 14px 16px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 12px;
}

#sidebar .nv-account-name {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: rgba(255,255,255,.7);
    margin-bottom: 10px;
    line-height: 1.4;
    word-break: break-word;
}

#sidebar .nv-contract-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 13px;
    background: linear-gradient(135deg, #f8b739 0%, #d9922a 100%);
    border: none;
    border-radius: 9px;
    color: #002647;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .15s, box-shadow .15s;
    text-align: left;
    box-shadow: 0 2px 10px rgba(248,183,57,.35);
    box-sizing: border-box;
}

#sidebar .nv-contract-btn:hover {
    opacity: .9;
    box-shadow: 0 4px 16px rgba(248,183,57,.5);
}

/* ── Content area — fills space right of sidebar on desktop ── */
#content {
    flex: 1;
    min-width: 0;        /* prevents flex item from overflowing */
    overflow-x: hidden;
}

/* ── Footer ── */
#sidebar .nv-footer {
    padding: 12px 20px 18px;
}

#sidebar .nv-footer p {
    font-size: .7rem;
    color: rgba(255,255,255,.25);
    margin: 0;
    text-align: center;
}
