/*
|--------------------------------------------------------------------------
| Sidenav V2 — Shared Styles (REALS + HRIS)
|--------------------------------------------------------------------------
|
| All rules scoped under .sidenav-v2 so nothing leaks to the rest of
| the project. Loaded globally from layouts/partials/head.blade.php.
|
*/

/* ══════════════════════════════════════════════════════════
   WIDTH OVERRIDE — widen SB Admin's 15rem → 17rem
   ══════════════════════════════════════════════════════════
   SB Admin Pro defaults:
     flex-basis: 15rem, transform: -15rem, margin-left: -15rem, etc.
   We override every occurrence to 17rem.
*/

/* ── Base (mobile-first — sidenav hidden off-screen) ── */
#layoutSidenav #layoutSidenav_nav {
    flex-basis: 17rem !important;
    flex-shrink: 0;
    transform: translateX(-17rem);
    transition: transform 0.15s ease-in-out;
    z-index: 1038;
}
#layoutSidenav #layoutSidenav_content {
    margin-left: -17rem;
}

/* Mobile: when .sidenav-toggled, slide the 17rem nav into view */
.sidenav-toggled #layoutSidenav #layoutSidenav_nav {
    transform: translateX(0) !important;
}
/* Mobile overlay behind the sidenav — SB Admin's ::before uses
   opacity:0.5 background:#000.  We just need to make sure it shows. */
.sidenav-toggled #layoutSidenav #layoutSidenav_content::before {
    content: "";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1037;
    opacity: 0.5;
    transition: opacity 0.3s ease-in-out;
}

/* ── Desktop (≥992px) ── */
@media (min-width: 992px) {
    #layoutSidenav #layoutSidenav_nav {
        transform: translateX(0);
    }
    #layoutSidenav #layoutSidenav_content {
        margin-left: 0;
        transition: margin 0.15s ease-in-out;
    }
    /* Desktop collapse: push sidenav off + shrink content */
    .sidenav-toggled #layoutSidenav #layoutSidenav_nav {
        transform: translateX(-17rem) !important;
    }
    .sidenav-toggled #layoutSidenav #layoutSidenav_content {
        margin-left: -17rem;
    }
    /* No overlay on desktop */
    .sidenav-toggled #layoutSidenav #layoutSidenav_content::before {
        display: none;
    }
}

/* ── .nav-fixed overrides (fixed position sidenav) ── */
.nav-fixed #layoutSidenav #layoutSidenav_nav {
    width: 17rem !important;
    /* Override SB Admin's .fixed-top which sets right:0 and constrains width */
    right: auto !important;
    left: 0 !important;
}
.nav-fixed #layoutSidenav #layoutSidenav_content {
    padding-left: 17rem;
}

/* ── Mobile padding reset ── */
@media (max-width: 991.98px) {
    .nav-fixed #layoutSidenav #layoutSidenav_content {
        padding-left: 0 !important;
    }
    #layoutSidenav #layoutSidenav_content {
        margin-left: 0 !important;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    /* Ensure sidenav is visible when toggled on mobile */
    .nav-fixed #layoutSidenav #layoutSidenav_nav {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: auto !important;
        width: 17rem !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 1038 !important;
        transform: translateX(-17rem) !important;
        transition: transform 0.15s ease-in-out !important;
    }
    /* Mobile: slide INTO view when body has .sidenav-toggled */
    .sidenav-toggled .nav-fixed #layoutSidenav #layoutSidenav_nav,
    .sidenav-toggled.nav-fixed #layoutSidenav #layoutSidenav_nav,
    body.sidenav-toggled #layoutSidenav #layoutSidenav_nav {
        transform: translateX(0) !important;
    }
    /* Mobile hamburger button — always tappable */
    #sidebarToggle {
        position: relative;
        z-index: 1040;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        cursor: pointer;
    }
}

/* ══════════════════════════════════════════════════════════
   CONTAINER
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e9ecef;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    padding-top: 3.625rem !important; /* match SB Admin's topnav height */
}

/* ══════════════════════════════════════════════════════════
   PROFILE CARD
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem 0.6rem;
    border-bottom: 1px solid #f0f0f0;
    margin-top: 0;
}
.sidenav-v2 .sv2-profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0061f2 0%, #00b4d8 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    overflow: hidden;
    position: relative;
}
.sidenav-v2 .sv2-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.sidenav-v2 .sv2-profile-info {
    min-width: 0;
    overflow: hidden;
}
.sidenav-v2 .sv2-profile-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #212832;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.sidenav-v2 .sv2-profile-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
}
.sidenav-v2 .sv2-role-badge {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(0, 97, 242, 0.1);
    color: #0061f2;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    line-height: 1.5;
}
.sidenav-v2 .sv2-subsidiary-tag {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(0, 172, 105, 0.1);
    color: #00ac69;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════
   SCROLLABLE MENU
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-menu-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0;
}
.sidenav-v2 .sv2-menu-scroll::-webkit-scrollbar {
    width: 4px;
}
.sidenav-v2 .sv2-menu-scroll::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
    border-radius: 10px;
}
.sidenav-v2 .sv2-menu-scroll::-webkit-scrollbar-track {
    background: transparent;
}

/* ══════════════════════════════════════════════════════════
   SECTION
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-section {
    padding: 0 0.5rem;
    margin-bottom: 0.25rem;
}
.sidenav-v2 .sv2-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #a7aeb8;
    padding: 0.85rem 0.75rem 0.35rem;
    margin: 0;
}

/* ══════════════════════════════════════════════════════════
   COLLAPSIBLE TOGGLE BUTTON
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-collapse-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    margin: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    border-radius: 6px;
    transition: background 0.15s ease;
    min-height: 36px;
}
.sidenav-v2 .sv2-collapse-toggle:hover {
    background: rgba(0, 0, 0, 0.03);
}
.sidenav-v2 .sv2-collapse-toggle:hover .sv2-section-label {
    color: #69707a;
}
.sidenav-v2 .sv2-collapse-toggle .sv2-section-label {
    pointer-events: none;
    padding: 0;
    flex: 1;
    text-align: left;
}
.sidenav-v2 .sv2-collapse-toggle .sv2-chevron {
    width: 14px;
    height: 14px;
    color: #c5ccd6;
    transition: transform 0.25s ease, color 0.15s ease;
    flex-shrink: 0;
    margin-right: 0.5rem;
    pointer-events: none;
}
/* Ensure all child elements of toggle buttons don't intercept clicks */
.sidenav-v2 .sv2-collapse-toggle * {
    pointer-events: none;
}
.sidenav-v2 .sv2-sub-toggle * {
    pointer-events: none;
}
.sidenav-v2 .sv2-collapse-toggle:hover .sv2-chevron {
    color: #69707a;
}
.sidenav-v2 .sv2-collapse-toggle.sv2-open .sv2-chevron {
    transform: rotate(0deg);
}
.sidenav-v2 .sv2-collapse-toggle:not(.sv2-open) .sv2-chevron {
    transform: rotate(-90deg);
}

/* ══════════════════════════════════════════════════════════
   COLLAPSIBLE BODY
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-collapse-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    opacity: 0;
}
.sidenav-v2 .sv2-collapse-body.sv2-expanded {
    max-height: 2000px;
    opacity: 1;
}

/* ══════════════════════════════════════════════════════════
   NAV LINKS
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    margin: 1px 0;
    border-radius: 8px;
    color: #4a515b;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
}
.sidenav-v2 .sv2-link:hover {
    background: #f2f6fc;
    color: #0061f2;
    text-decoration: none;
}
.sidenav-v2 .sv2-link.sv2-active {
    background: rgba(0, 97, 242, 0.08);
    color: #0061f2;
    font-weight: 600;
}
.sidenav-v2 .sv2-link.sv2-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #0061f2;
    border-radius: 0 3px 3px 0;
}

/* ══════════════════════════════════════════════════════════
   LINK ICONS
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}
.sidenav-v2 .sv2-link-icon svg,
.sidenav-v2 .sv2-link-icon .feather {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    color: inherit;
}
.sidenav-v2 .sv2-collapse-toggle .sv2-chevron svg,
.sidenav-v2 .sv2-collapse-toggle .sv2-chevron .feather {
    width: 14px;
    height: 14px;
    color: inherit;
}
.sidenav-v2 .sv2-sub-toggle .sv2-sub-chevron svg,
.sidenav-v2 .sv2-sub-toggle .sv2-sub-chevron .feather {
    width: 12px;
    height: 12px;
    color: inherit;
}
.sidenav-v2 .sv2-link:not(.sv2-active) .sv2-link-icon {
    color: #a7aeb8;
}
.sidenav-v2 .sv2-link.sv2-active .sv2-link-icon {
    color: #0061f2;
}
.sidenav-v2 .sv2-link:hover .sv2-link-icon {
    color: #0061f2;
}

/* ── "Coming Soon" Badge ── */
.sidenav-v2 .sv2-badge-soon {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #f4a100;
    color: #fff;
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    margin-left: auto;
    line-height: 1.6;
}

/* ── External Link (cross-module switch) ── */
.sidenav-v2 .sv2-link-external {
    color: #69707a;
    opacity: 0.85;
}
.sidenav-v2 .sv2-link-external:hover {
    opacity: 1;
    background: #f2f6fc;
    color: #0061f2;
}

/* ══════════════════════════════════════════════════════════
   SWITCH MODULE LINK (footer)
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-switch-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    margin: 0 0 0.25rem;
    border-radius: 8px;
    color: #0061f2;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
    background: rgba(0, 97, 242, 0.06);
    border: 1px solid rgba(0, 97, 242, 0.12);
}
.sidenav-v2 .sv2-switch-link:hover {
    background: rgba(0, 97, 242, 0.12);
    color: #0050cc;
    text-decoration: none;
}
.sidenav-v2 .sv2-switch-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: inherit;
}
.sidenav-v2 .sv2-switch-icon svg {
    width: 16px;
    height: 16px;
}
/* HRIS accent for switch link */
.sidenav-v2--hris .sv2-switch-link {
    color: #00796b;
    background: rgba(0, 121, 107, 0.06);
    border: 1px solid rgba(0, 121, 107, 0.12);
}
.sidenav-v2--hris .sv2-switch-link:hover {
    background: rgba(0, 121, 107, 0.12);
    color: #005d50;
}

/* ══════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-footer {
    flex-shrink: 0;
    border-top: 1px solid #f0f0f0;
    padding: 0.5rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
}
.sidenav-v2 .sv2-footer-user {
    padding: 0.6rem 0.75rem 0.25rem;
}
.sidenav-v2 .sv2-footer-subtitle {
    font-size: 0.7rem;
    color: #69707a;
    margin-bottom: 0.15rem;
}
.sidenav-v2 .sv2-footer-role-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    background: #f2f6fc;
    color: #4a515b;
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    vertical-align: middle;
}
.sidenav-v2 .sv2-footer-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: #212832;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidenav-v2 .sv2-footer-email {
    font-size: 0.72rem;
    color: #a7aeb8;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════════
   MOBILE OPTIMIZATIONS
   ══════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .sidenav-v2 .sv2-profile {
        padding: 0.6rem 0.75rem 0.55rem;
    }
    .sidenav-v2 .sv2-link {
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
    }
    .sidenav-v2 .sv2-section-label {
        font-size: 0.6rem;
    }
    /* Ensure the sidenav is scrollable and interactive on mobile */
    .sidenav-v2 .sv2-menu-scroll {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    /* Prevent sidenav from being cut off on mobile */
    #layoutSidenav_nav .sidenav-v2 {
        height: 100vh !important;
        height: 100dvh !important;
    }
    /* Ensure collapse toggle buttons are clickable on mobile */
    .sidenav-v2 .sv2-collapse-toggle,
    .sidenav-v2 .sv2-sub-toggle {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    /* Mobile: clicking the overlay (content area ::before) closes sidenav */
    .sidenav-toggled #layoutSidenav #layoutSidenav_content::before {
        cursor: pointer;
    }
}

/* ── Ensure feather icons inside v2 don't inherit odd sizes ── */
.sidenav-v2 [data-feather] {
    width: 16px;
    height: 16px;
}

/* ── Duplicate icon rules for safety after feather.replace() ── */
.sidenav-v2 .sv2-link-icon svg,
.sidenav-v2 .sv2-link-icon .feather {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    color: inherit;
}
.sidenav-v2 .sv2-collapse-toggle .sv2-chevron svg,
.sidenav-v2 .sv2-collapse-toggle .sv2-chevron .feather {
    width: 14px;
    height: 14px;
    color: inherit;
}
.sidenav-v2 .sv2-sub-toggle .sv2-sub-chevron svg,
.sidenav-v2 .sv2-sub-toggle .sv2-sub-chevron .feather {
    width: 12px;
    height: 12px;
    color: inherit;
}

/* ══════════════════════════════════════════════════════════
   HRIS ACCENT (teal) — add .sidenav-v2--hris on the nav
   ══════════════════════════════════════════════════════════ */
.sidenav-v2--hris .sv2-profile-avatar {
    background: linear-gradient(135deg, #00796b 0%, #26a69a 100%);
}
.sidenav-v2--hris .sv2-role-badge {
    background: rgba(0, 121, 107, 0.1);
    color: #00796b;
}
.sidenav-v2--hris .sv2-link:hover {
    background: #e0f2f1;
    color: #00796b;
}
.sidenav-v2--hris .sv2-link.sv2-active {
    background: rgba(0, 121, 107, 0.08);
    color: #00796b;
}
.sidenav-v2--hris .sv2-link.sv2-active::before {
    background: #00796b;
}
.sidenav-v2--hris .sv2-link.sv2-active .sv2-link-icon,
.sidenav-v2--hris .sv2-link:hover .sv2-link-icon {
    color: #00796b;
}

/* ══════════════════════════════════════════════════════════
   NESTED SUB-CATEGORY (collapsible inside collapsible)
   ══════════════════════════════════════════════════════════ */
.sidenav-v2 .sv2-sub-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    background: none;
    border: none;
    padding: 0.55rem 0.75rem;
    margin: 1px 0;
    border-radius: 8px;
    color: #4a515b;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    transition: all 0.15s ease;
    position: relative;
    font-family: inherit;
    line-height: 1.5;
}
.sidenav-v2 .sv2-sub-toggle:hover {
    background: #f2f6fc;
    color: #0061f2;
}
.sidenav-v2 .sv2-sub-toggle .sv2-sub-chevron {
    width: 12px;
    height: 12px;
    color: #c5ccd6;
    transition: transform 0.25s ease, color 0.15s ease;
    flex-shrink: 0;
    margin-left: auto;
}
.sidenav-v2 .sv2-sub-toggle:hover .sv2-sub-chevron {
    color: #69707a;
}
.sidenav-v2 .sv2-sub-toggle.sv2-open .sv2-sub-chevron {
    transform: rotate(0deg);
}
.sidenav-v2 .sv2-sub-toggle:not(.sv2-open) .sv2-sub-chevron {
    transform: rotate(-90deg);
}
.sidenav-v2 .sv2-sub-toggle:not(.sv2-open) .sv2-link-icon {
    color: #a7aeb8;
}
.sidenav-v2 .sv2-sub-toggle.sv2-open .sv2-link-icon,
.sidenav-v2 .sv2-sub-toggle:hover .sv2-link-icon {
    color: #0061f2;
}
.sidenav-v2 .sv2-sub-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    opacity: 0;
    padding-left: 1rem;
}
.sidenav-v2 .sv2-sub-body.sv2-expanded {
    max-height: 800px;
    opacity: 1;
}

/* HRIS accent for sub-toggle */
.sidenav-v2--hris .sv2-sub-toggle:hover {
    background: #e0f2f1;
    color: #00796b;
}
.sidenav-v2--hris .sv2-sub-toggle.sv2-open .sv2-link-icon,
.sidenav-v2--hris .sv2-sub-toggle:hover .sv2-link-icon {
    color: #00796b;
}

/* ══════════════════════════════════════════════════════════
   MOBILE HEIGHT / SAFE AREA (dvh + safe-area-inset)
   ══════════════════════════════════════════════════════════ */
.nav-fixed #layoutSidenav #layoutSidenav_nav {
    height: 100vh;
    height: 100dvh;
}
.nav-fixed #layoutSidenav #layoutSidenav_nav .sidenav {
    height: 100vh;
    height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sidenav .sidenav-footer {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}
#layoutSidenav #layoutSidenav_content {
    min-height: calc(100vh - 3.625rem);
    min-height: calc(100dvh - 3.625rem);
}
