/* ==========================================================================
   UI Shell - modern navbar + sidebar
   Loaded after app.min.css so it intentionally overrides the base theme.
   Brand colours are injected as CSS variables by layouts/ui-theme.blade.php
   ========================================================================== */

:root {
    --shell-topbar-h: 70px;
    --shell-sidebar-w: 264px;
    --shell-sidebar-rail: 76px;

    /* Fallbacks - overridden per-customer by layouts/ui-theme.blade.php */
    --shell-brand: #1a4f6e;
    --shell-brand-dark: #123a52;
    --shell-brand-light: #2f83ad;
    --shell-brand-soft: rgba(26, 79, 110, .08);
    --shell-brand-softer: rgba(26, 79, 110, .04);

    --shell-gradient: linear-gradient(120deg, var(--shell-brand-dark) 0%, var(--shell-brand) 48%, var(--shell-brand-light) 100%);

    --shell-ink: #1f2937;
    --shell-ink-muted: #6b7280;
    --shell-line: #e9edf2;
    --shell-radius: 10px;
}

/* ==========================================================================
   Navbar
   ========================================================================== */

#page-topbar {
    background: var(--shell-gradient) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 4px 18px rgba(15, 42, 66, .18);
    border: 0;
}

#page-topbar .navbar-header {
    height: var(--shell-topbar-h);
    padding: 0 18px 0 0;
    gap: 8px;
}

/* --- Brand block: sits directly above the sidebar --- */
.shell-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--shell-topbar-h);
    padding-left: 18px;
    min-width: var(--shell-sidebar-w);
    flex-shrink: 0;
}

/* The logo container: a fixed size whatever the image size, sitting directly
   on the navbar with no surface behind it. The logo scales to fill it without
   distorting - a wide logo spans the full width, a squarer one the full
   height, centred. */
.shell-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 180px;
    height: 50px;
}

.shell-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* --- Sidebar toggle --- */
.shell-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}

.shell-toggle:hover,
.shell-toggle:focus {
    background: rgba(255, 255, 255, .26);
    color: #fff;
    outline: none;
}

.shell-toggle:active {
    transform: scale(.94);
}

/* --- Right-hand actions --- */
.shell-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* Neutralise the base theme flat header buttons inside the gradient bar */
#page-topbar .header-item,
#page-topbar .header-item:hover,
#page-topbar .header-item:focus {
    color: #fff;
    background-color: transparent;
    box-shadow: none !important;
}

#page-topbar .navbar-header .dropdown .show.header-item {
    background-color: rgba(255, 255, 255, .16);
    border-radius: 9px;
}

/* Icon buttons */
.shell-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 19px;
    line-height: 1;
    position: relative;
    text-decoration: none;
    transition: background .18s ease;
}

.shell-icon-btn:hover,
.shell-icon-btn:focus {
    background: rgba(255, 255, 255, .26);
    color: #fff;
    outline: none;
}

.shell-icon-btn i {
    font-size: 19px;
    line-height: 1;
}

/* Notification count */
.shell-icon-btn .shell-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .12);
}

/* Credits pill */
.shell-credits {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 13px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .22);
    color: #fff;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}

.shell-credits i {
    font-size: 15px;
    opacity: .9;
}

.shell-credits strong {
    font-weight: 600;
}

/* Divider between action groups */
.shell-divider {
    width: 1px;
    height: 26px;
    margin: 0 4px;
    background: rgba(255, 255, 255, .22);
    flex-shrink: 0;
}

/* --- User menu --- */
.shell-user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 46px;
    padding: 0 10px 0 5px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    transition: background .18s ease;
}

.shell-user:hover,
.shell-user:focus {
    background: rgba(255, 255, 255, .24);
    color: #fff;
    outline: none;
}

.shell-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    padding: 2px;
    object-fit: cover;
}

/* Name on top, role and company beneath. */
.shell-user .shell-user-meta {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    min-width: 0;
    max-width: 210px;
    line-height: 1.25;
    text-align: left;
}

.shell-user .shell-user-name {
    font-size: 13.5px;
    font-weight: 600;
    color: #fff;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell-user .shell-user-sub {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    max-width: 100%;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, .78);
    white-space: nowrap;
}

.shell-user .shell-user-role {
    flex: none;
}

.shell-user .shell-user-dot {
    flex: none;
    opacity: .65;
}

/* The company is the part that can run long, so it is the part that truncates. */
.shell-user .shell-user-company {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shell-user i.mdi {
    font-size: 16px;
    opacity: .85;
}

/* Dropdown panels hanging off the gradient bar */
#page-topbar .dropdown-menu {
    border: 1px solid var(--shell-line);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 42, 66, .16);
    padding: 6px;
    margin-top: 8px;
}

#page-topbar .dropdown-menu .dropdown-item {
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13.5px;
    color: var(--shell-ink);
}

#page-topbar .dropdown-menu .dropdown-item:hover,
#page-topbar .dropdown-menu .dropdown-item:focus {
    background: var(--shell-brand-soft);
    color: var(--shell-brand);
}

#page-topbar .dropdown-menu .dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, .08);
    color: #ef4444;
}

#page-topbar .dropdown-menu .notification-item {
    border-radius: 8px;
    padding: 10px 12px;
    text-align: left;
}

#page-topbar .dropdown-menu .notification-item:hover {
    background: var(--shell-brand-soft);
}

/* Layouts that render no sidebar at all */
body.shell-no-sidebar .shell-brand {
    min-width: auto;
    padding-right: 6px;
}

body.shell-no-sidebar .shell-toggle {
    display: none;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.vertical-menu {
    width: var(--shell-sidebar-w);
    top: var(--shell-topbar-h);
    background: #fff !important;
    border-right: 1px solid var(--shell-line);
    box-shadow: none;
    transition: transform .26s ease;
}

.shell-nav {
    padding: 16px 12px 28px;
}

.shell-nav-label {
    padding: 0 12px;
    margin: 4px 0 10px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #9aa4b2;
}

.shell-nav-label + .shell-nav-label,
.shell-nav-link + .shell-nav-label,
.shell-submenu + .shell-nav-label {
    margin-top: 18px;
}

/* --- Collapsible section heading (Consumer / Commercial) ---
   Looks like .shell-nav-label but is a real button, so it is reachable by
   keyboard and announces its state. */
.shell-nav-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 4px 12px;
    margin: 4px 0 10px;
    border: none;
    background: none;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #9aa4b2;
    text-align: left;
    cursor: pointer;
    transition: color .16s ease;
}

.shell-nav-link + .shell-nav-section,
.shell-submenu + .shell-nav-section,
.shell-nav-group + .shell-nav-section {
    margin-top: 18px;
}

.shell-nav-section:hover,
.shell-nav-section:focus-visible {
    color: var(--shell-brand);
    outline: none;
}

.shell-nav-section .shell-section-caret {
    font-size: 15px;
    color: #b0b8c4;
    transition: transform .2s ease, color .16s ease;
}

.shell-nav-section:hover .shell-section-caret {
    color: var(--shell-brand);
}

/* Collapsed points the caret right. */
.shell-nav-section[aria-expanded="false"] .shell-section-caret {
    transform: rotate(-90deg);
}

/* --- Nav links --- */
.shell-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 11px;
    margin-bottom: 3px;
    border: 0;
    border-radius: var(--shell-radius);
    background: transparent;
    color: #4a5568;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    text-decoration: none;
    transition: background .16s ease, color .16s ease;
}

.shell-nav-link:hover,
.shell-nav-link:focus {
    background: var(--shell-brand-softer);
    color: var(--shell-brand);
    outline: none;
}

.shell-nav-link i {
    flex-shrink: 0;
    width: 20px;
    font-size: 19px;
    line-height: 1;
    text-align: center;
    color: #8a94a6;
    transition: color .16s ease;
}

.shell-nav-link:hover i {
    color: var(--shell-brand);
}

.shell-nav-link .shell-nav-text {
    flex: 1 1 auto;
    min-width: 0;
}

/* Active page */
.shell-nav-link.is-active {
    background: var(--shell-brand-soft);
    color: var(--shell-brand);
    font-weight: 600;
}

.shell-nav-link.is-active i {
    color: var(--shell-brand);
}

/* --- Collapsible groups --- */
.shell-nav-link .shell-caret {
    flex-shrink: 0;
    width: auto;
    font-size: 17px;
    color: #b0b8c4;
    transition: transform .2s ease, color .16s ease;
}

.shell-nav-link[aria-expanded="true"] {
    background: var(--shell-brand-softer);
    color: var(--shell-brand);
}

.shell-nav-link[aria-expanded="true"] i {
    color: var(--shell-brand);
}

.shell-nav-link[aria-expanded="true"] .shell-caret {
    transform: rotate(180deg);
}

.shell-submenu {
    list-style: none;
    margin: 2px 0 6px;
    padding: 0 0 0 30px;
    position: relative;
}

.shell-submenu::before {
    content: "";
    position: absolute;
    left: 20px;
    top: 4px;
    bottom: 8px;
    width: 1px;
    background: var(--shell-line);
}

.shell-submenu .shell-sublink {
    display: block;
    padding: 8px 12px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: #5a6475;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background .16s ease, color .16s ease;
}

.shell-submenu .shell-sublink:hover,
.shell-submenu .shell-sublink:focus {
    background: var(--shell-brand-softer);
    color: var(--shell-brand);
    outline: none;
}

.shell-submenu .shell-sublink.is-active {
    background: var(--shell-brand-soft);
    color: var(--shell-brand);
    font-weight: 600;
}

/* --- Scrollbar --- */
.vertical-menu .simplebar-scrollbar::before {
    background: #c7ced8;
}

.vertical-menu .shell-scroll {
    scrollbar-width: thin;
    scrollbar-color: #c7ced8 transparent;
}

.vertical-menu .shell-scroll::-webkit-scrollbar {
    width: 6px;
}

.vertical-menu .shell-scroll::-webkit-scrollbar-thumb {
    background: #c7ced8;
    border-radius: 3px;
}

/* ==========================================================================
   Collapse / responsive behaviour
   ========================================================================== */

.main-content {
    margin-left: var(--shell-sidebar-w);
    transition: margin-left .26s ease;
}

/* --- Collapsed: a narrow icon rail, not a hidden sidebar ---
   The destinations stay on screen as icons so the sidebar can be put away
   without losing track of what is available. Each link keeps a title
   attribute, which the browser shows on hover. */
body.shell-sidebar-hidden .vertical-menu {
    width: var(--shell-sidebar-rail);
    transform: none;
}

body.shell-sidebar-hidden .main-content {
    margin-left: var(--shell-sidebar-rail);
}

body.shell-sidebar-hidden .shell-nav {
    padding-left: 0;
    padding-right: 0;
}

/* Icon only, centred. */
body.shell-sidebar-hidden .shell-nav-link {
    justify-content: center;
    gap: 0;
    padding: 11px 0;
    margin-left: 8px;
    margin-right: 8px;
}

body.shell-sidebar-hidden .shell-nav-link i {
    width: auto;
    font-size: 20px;
}

body.shell-sidebar-hidden .shell-nav-text,
body.shell-sidebar-hidden .shell-nav-link .shell-caret,
body.shell-sidebar-hidden .shell-nav-link .shell-lock,
body.shell-sidebar-hidden .shell-nav-section > span,
body.shell-sidebar-hidden .shell-nav-section .shell-section-caret {
    display: none;
}

/* A section heading becomes a divider: the words will not fit, but the
   grouping is still worth showing. */
body.shell-sidebar-hidden .shell-nav-section {
    justify-content: center;
    height: 1px;
    padding: 0;
    margin: 14px 16px;
    background: var(--shell-line);
    pointer-events: none;
}

/* The first divider would sit against the top of the rail. */
body.shell-sidebar-hidden .shell-nav > .shell-nav-section:first-child {
    display: none;
}

/* A collapsed section still hides its links, which would leave the rail with
   an unexplained gap, so everything shows while the sidebar is a rail. */
body.shell-sidebar-hidden .shell-nav-group {
    display: block !important;
    height: auto !important;
}

/* Nested submenus cannot open inside 76px; the script expands the sidebar
   first, so they are simply not drawn here. */
body.shell-sidebar-hidden .shell-submenu {
    display: none !important;
}

/* --- Rail tooltip ---
   ui-shell.js keeps one of these on <body> and positions it against the
   hovered icon. It lives outside the sidebar because the scroll container
   would clip it, which is also why the placement is in script rather than a
   ::after on the link. */
.shell-tip {
    position: fixed;
    z-index: 1050;
    transform: translateY(-50%);
    padding: 7px 12px;
    border-radius: 8px;
    background: #1f2937;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    /* Short labels sit on one line anyway; wrapping is here for the locked
       entries, whose tip explains that the feature needs requesting. */
    white-space: normal;
    max-width: 240px;
    width: max-content;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .26);
    transition: opacity .12s ease;
}

.shell-tip.is-visible {
    opacity: 1;
    visibility: visible;
}

/* Arrow pointing back at the icon. */
.shell-tip::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    width: 0;
    height: 0;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #1f2937;
}

/* The base theme pins the footer to a hard-coded 250px - keep it with the sidebar. */
.footer {
    left: var(--shell-sidebar-w);
    transition: left .26s ease;
}

body.shell-sidebar-hidden .footer {
    left: var(--shell-sidebar-rail);
}

body.shell-no-sidebar .footer {
    left: 0;
}

.shell-backdrop {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    background: rgba(15, 32, 48, .42);
}

@media (max-width: 991.98px) {
    .shell-brand {
        min-width: auto;
        padding-left: 12px;
    }

    .shell-logo {
        width: 150px;
        height: 44px;
    }

    /* The base theme hides the sidebar below 992px - drive it from the toggle instead */
    .vertical-menu {
        display: block;
        transform: translateX(-100%);
        z-index: 1003;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .footer {
        left: 0;
    }

    body.shell-sidebar-open .vertical-menu {
        transform: translateX(0);
        box-shadow: 0 12px 40px rgba(15, 42, 66, .22);
    }

    body.shell-sidebar-open .shell-backdrop {
        display: block;
    }

    /* The user name itself is governed by the d-none/d-md-inline-block utilities. */
    .shell-credits {
        display: none;
    }

    .shell-divider {
        display: none;
    }
}

@media (max-width: 575.98px) {
    #page-topbar .navbar-header {
        padding-right: 8px;
        gap: 4px;
    }

    .shell-brand {
        padding-left: 8px;
    }

    .shell-logo {
        width: 116px;
        height: 38px;
    }

    .shell-actions {
        gap: 2px;
    }

    .shell-toggle,
    .shell-icon-btn {
        width: 34px;
        height: 34px;
        font-size: 17px;
    }

    .shell-icon-btn i {
        font-size: 17px;
    }

    .shell-user {
        height: 36px;
        padding: 0 6px 0 4px;
        gap: 4px;
    }

    .shell-user img {
        width: 28px;
        height: 28px;
    }
}

/* ==========================================================================
   Locked nav entries - features the company or role does not have. They stay
   visible and lead to /feature/{key} instead of the real screen.
   ========================================================================== */

.shell-nav-link.is-locked {
    color: #9aa4b2;
}

.shell-nav-link.is-locked i:first-child {
    color: #b6bec9;
}

.shell-nav-link.is-locked:hover,
.shell-nav-link.is-locked:focus {
    background: var(--shell-brand-softer);
    color: var(--shell-brand);
}

.shell-nav-link.is-locked:hover i:first-child {
    color: var(--shell-brand);
}

.shell-nav-link .shell-lock {
    flex-shrink: 0;
    width: auto;
    margin-left: auto;
    font-size: 14px;
    color: #c2c9d4;
    transition: color .16s ease;
}

.shell-nav-link.is-locked:hover .shell-lock {
    color: var(--shell-brand);
}
