/* SelfieSign app shell — the fixed brand header and the nav links bar underneath it.

   This is the one copy. It replaces ~85 lines of near-identical CSS that had been
   pasted into eighteen templates and then drifted apart: six different hashes,
   disagreeing on nav-link font-weight (600 vs 700), on whether .nav-dd-item.current
   existed at all, and on whether the header was an .app-header class or an inline
   style attribute.

   Requires theme.css for the --ds-* tokens and typography.css for --ds-font-sans.

   Pairs with /js/app-shell.js (dropdown toggling + --app-header-h measurement) and
   the Thymeleaf fragment in templates/fragments/app-shell.html. */

/* ===========================================================================
   Header
   =========================================================================== */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    background: var(--ds-brand-gradient);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Brand row. The logo is centred on the row itself, and the optional side controls
   are absolutely positioned out of flow, so the wordmark stays dead-centre in the
   viewport whether or not a page supplies them. */
.app-header-top {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    padding: 0.5rem 1rem;
}

.app-header-slot {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-header-slot.start { left: 1rem; }
.app-header-slot.end { right: 1rem; }

/* ===========================================================================
   Brand lockup
   =========================================================================== */

.ds-logo {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    text-decoration: none;
    color: var(--ds-on-brand);
}

.ds-logo:hover { color: var(--ds-on-brand); }

.ds-logo img {
    height: 48px;
    width: auto;
    object-fit: contain;
    margin-right: -3px;
}

.ds-logo-word {
    font-family: var(--ds-font-sans, Inter, sans-serif);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    /* Explicit rather than inherited: reports.html redefines Bootstrap's .text-white
       to dark slate for its light tables, which used to paint the wordmark black. */
    color: var(--ds-on-brand);
    margin: 0;
    text-transform: none;
}

/* ===========================================================================
   Signing header
   The second shell: full-screen signing, PowerForm fill, the field editors and
   the token/pricing pages. No site nav — these are single-task screens, some of
   them public — but the same brand bar, wordmark and type as .app-header.

   Five pages had their own copy, disagreeing on padding (8px vs 16px), on the
   shadow, and on the wordmark size (24px vs 26px vs 45–50px logos).
   =========================================================================== */

.signing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 12px 24px;
    background: var(--ds-brand-gradient);
    color: var(--ds-on-brand);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

/* Pages whose header holds nothing but the brand lockup. */
.signing-header.centered { justify-content: center; }

.docusign-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--ds-font-sans, Inter, sans-serif);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ds-on-brand);
    text-decoration: none;
}

.docusign-logo:hover { color: var(--ds-on-brand); }

.docusign-logo img {
    height: 48px;
    width: auto;
    object-fit: contain;
    margin-right: -3px;
}

.docusign-logo i { font-size: 28px; }

@media (max-width: 575.98px) {
    .signing-header { padding: 8px 14px; }
    .docusign-logo { font-size: 1.2rem; }
    .docusign-logo img { height: 38px; }
}

/* ===========================================================================
   Header controls — workspace switcher, notification bell, user menu.
   Rendered by the headerControls fragment into .app-header-slot on every
   signed-in page. These used to exist only on the dashboard.
   =========================================================================== */

.app-header-slot .btn-light {
    --bs-btn-bg: rgba(255, 255, 255, 0.95);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: #ffffff;
    --bs-btn-hover-border-color: transparent;
    font-weight: 500;
    white-space: nowrap;
}

/* The workspace switcher is a pill, matching the user chip in the end slot. This
   used to come from dashboard.html's page-level `.btn { border-radius: 999px }`,
   which only ever reached the dashboard's copy of the header — every other page
   drew the same button as a Bootstrap-default rectangle. Shape belongs here. */
.app-header-slot.start > .btn {
    border-radius: 50rem;
    padding: 0.4rem 1rem;
}

/* Bootstrap anchors a dropdown to its nearest positioned ancestor. The slot is
   absolutely positioned, so menus hang off it and stay inside the viewport. */
.app-header-slot .dropdown-menu { z-index: 1050; }

/* Below lg the workspace label and the user's name are the first things to go:
   the bar has to keep the wordmark centred and the controls tappable. */
@media (max-width: 991.98px) {
    .app-header-slot.start .btn span,
    .app-header-slot.end .um-trigger-name { display: none; }
    .app-header-slot.start { left: 0.5rem; }
    .app-header-slot.end { right: 0.5rem; }
}

/* On a phone the absolutely-positioned slots start clipping the centred wordmark
   (at 375px the end slot lands ~4px inside it). Drop out of absolute positioning
   and lay the bar out as a real three-column row instead, so the controls and the
   lockup share the width rather than stacking on top of each other. */
@media (max-width: 575.98px) {
    .app-header-top {
        justify-content: space-between;
        gap: 0.5rem;
    }

    .app-header-slot {
        position: static;
        transform: none;
        flex: 0 0 auto;
    }

    .ds-logo {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 0;
    }

    .ds-logo-word {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-menu-dropdown { min-width: 280px; }
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ds-brand-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-menu-dropdown {
    min-width: 318px;
    padding: 0;
    border: none;
    border-radius: 16px;
    overflow: hidden;
    margin-top: 10px;
    background: #ffffff;
    font-family: var(--ds-font-sans, Inter, sans-serif);
    box-shadow: 0 18px 45px rgba(70, 5, 130, 0.20),
                0 2px 10px rgba(15, 23, 42, 0.08);
}

.um-header {
    background: linear-gradient(135deg, #460582, #7F53CF);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.um-avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1.5px solid rgba(255, 255, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1;
}

.um-identity { min-width: 0; }

.um-name {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.um-role {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

.um-meta {
    padding: 12px 18px 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.um-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.um-meta-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #98a0b3;
}

.um-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.76rem;
    font-weight: 600;
    color: #5b21b6;
    background: #f4efff;
    border: 1px solid #e7dcfa;
    border-radius: 6px;
    padding: 2px 8px;
    white-space: nowrap;
}

/* The workspace-name row reuses the .um-code chip, but a name is prose, not a code: give it
   the UI font and let it truncate instead of forcing the menu wider. */
.um-code-name {
    font-family: inherit;
    font-size: 0.78rem;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.um-section {
    padding: 12px 18px 14px;
}

.um-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #98a0b3;
}

.um-sign-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 74px;
    padding: 10px;
    border: 1px dashed #d9cdf3;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbf9ff, #f4f0fd);
}

.um-sign-preview img {
    max-width: 100%;
    max-height: 54px;
    object-fit: contain;
}

.um-sign-empty {
    font-size: 0.78rem;
    color: #a3a9b8;
}

.um-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 0.83rem;
    font-weight: 600;
    color: #ffffff;
    text-decoration: none;
    background: var(--ds-brand-gradient);
    box-shadow: 0 6px 16px rgba(70, 5, 130, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.um-btn:hover {
    color: #ffffff;
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(70, 5, 130, 0.30);
}

.um-divider {
    height: 1px;
    margin: 0 18px;
    background: #eceaf3;
}

.um-actions { padding: 8px 8px 10px; }

.um-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 10px;
    color: #3f4353;
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.14s ease, color 0.14s ease;
}

.um-item:hover {
    background: #f6f2fe;
    color: #460582;
}

.um-item i {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4efff;
    color: #6d28d9;
    font-size: 0.95rem;
}

/* ===========================================================================
   Nav links bar
   =========================================================================== */

.nav-links-bar {
    background: var(--ds-surface);
    border-top: 1px solid var(--ds-border-strong);
    border-bottom: 1px solid rgba(70, 5, 130, 0.1);
    overflow: visible;
    box-shadow: var(--ds-shadow-sm);
}

.nav-links-scroll {
    display: flex;
    align-items: stretch;
    justify-content: space-evenly;
    overflow: visible;
    width: 100%;
}

.nav-link-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 1;
    padding: 12px 20px;
    font-family: var(--ds-font-sans, Inter, sans-serif);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    outline: none;
    transition: background 0.18s, color 0.18s;
}

.nav-link-item i { font-size: 16px; flex-shrink: 0; }

.nav-link-item .nav-chevron {
    font-size: 11px;
    opacity: 0.65;
    margin-left: 2px;
    transition: transform 0.2s ease;
}

.nav-link-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.8);
}

.nav-link-item.active {
    color: rgba(0, 0, 0, 0.85);
    background: rgba(0, 0, 0, 0.06);
    border-bottom-color: transparent;
}

.nav-link-item.logout-link { color: rgba(245, 101, 101, 0.85); }

.nav-link-item.logout-link:hover {
    background: rgba(239, 68, 68, 0.08);
    color: #f56565;
}

/* ===========================================================================
   Nav dropdowns
   =========================================================================== */

.nav-dropdown {
    position: relative;
    flex: 1;
    display: flex;
    overflow: visible;
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 210px;
    margin: 0;
    padding: 6px 0;
    list-style: none;
    background: var(--ds-surface);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow-lg);
    z-index: 9999;
    display: none;
}

.nav-dropdown-menu.open { display: block; }

.nav-dd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    font-family: var(--ds-font-sans, Inter, sans-serif);
    font-size: 14px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.75);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.14s, color 0.14s;
}

.nav-dd-item i { font-size: 15px; width: 20px; flex-shrink: 0; }

.nav-dd-item:hover {
    background: rgba(0, 0, 0, 0.06);
    color: rgba(0, 0, 0, 0.9);
}

/* The dropdown entry for the page you are already on. */
.nav-dd-item.current {
    color: var(--ds-primary);
    font-weight: 600;
    background: var(--ds-primary-light);
}

.nav-dd-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 4px 0;
}

/* ===========================================================================
   Narrow viewports
   Below the lg breakpoint the six evenly-spread items no longer fit, so the bar
   becomes a horizontal scroller and items shrink to their content.
   =========================================================================== */

@media (max-width: 991.98px) {
    .nav-links-scroll {
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: visible;
        scrollbar-width: none;
    }

    .nav-links-scroll::-webkit-scrollbar { display: none; }

    .nav-link-item {
        flex: 0 0 auto;
        font-size: 15px;
        padding: 12px 14px;
    }

    .nav-dropdown { flex: 0 0 auto; }

    .nav-dropdown-menu {
        left: 0;
        transform: none;
    }
}

@media (max-width: 575.98px) {
    .app-header-top { min-height: 56px; }
    .ds-logo img { height: 38px; }
    .ds-logo-word { font-size: 1.2rem; }
}
