/* nav.css — Mobile bottom navigation bar + utility header responsive behavior.
   Loaded on all authenticated pages between tokens.css and page CSS.
   Mobile-first: bottom nav visible < 992px, hidden on desktop. */

/* ───────── Bottom tab bar ───────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background: var(--surface-1);
    border-top: 1px solid var(--border-soft);
    padding: 4px 4px calc(4px + var(--safe-area-bottom, 0px));
    box-shadow: 0 -8px 24px -8px rgba(15, 23, 42, 0.08);
}

.bottom-nav__item {
    flex: 1;
    background: none;
    border: 0;
    padding: 8px 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--ink-3);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-decoration: none;
    position: relative;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
    transition: color 0.15s ease;
}

.bottom-nav__item i {
    font-size: 20px;
    transition: color 0.15s ease;
}

.bottom-nav__item--active {
    color: var(--primary);
    font-weight: 700;
}

.bottom-nav__item--active i {
    color: var(--primary);
}

.bottom-nav__item--active::before {
    content: '';
    position: absolute;
    inset: 4px 6px;
    border-radius: 8px;
    background: var(--primary-soft);
    z-index: -1;
}

.fab-new-profile {
    position: fixed;
    bottom: calc(64px + var(--safe-area-bottom, 0px) + 16px);
    right: 16px;
    z-index: 1029;
    display: inline-flex;
    align-items: center;
    padding: 12px 20px;
    border-radius: 999px;
    border: 0;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fab-new-profile:active {
    transform: scale(0.95);
}

.fab-new-profile i {
    font-size: 16px;
}

/* ───────── Mobile body spacing ───────── */
.has-bottom-nav {
    padding-bottom: calc(64px + var(--safe-area-bottom, 0px)) !important;
}

/* ───────── Header responsive: hide nav links on mobile ───────── */
.header-nav-links {
    display: none;
}

/* ───────── Desktop: hide bottom nav, show header links ───────── */
@media (min-width: 992px) {
    .bottom-nav {
        display: none;
    }

    .has-bottom-nav {
        padding-bottom: 0 !important;
    }

    .header-nav-links {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
}


/* ───────── Section pill (shared mobile section switcher) ───────── */
.section-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-1);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 8px 14px 8px 12px;
    font-size: var(--fs-base, 14px);
    font-weight: 600;
    color: var(--ink-1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
    transition: background 0.15s ease;
}

.section-pill:hover,
.section-pill:active {
    background: var(--surface-0);
}

.section-pill__icon {
    color: var(--primary);
    font-size: 14px;
}

.section-pill__label {
    font-weight: 600;
    color: var(--ink-1);
    line-height: 1.2;
}

.section-pill__sep {
    color: var(--ink-3);
    font-weight: 400;
    margin: 0 2px;
}

.section-pill__chev {
    color: var(--ink-3);
    font-size: 13px;
    margin-left: 4px;
}

.section-pill--next {
    flex-shrink: 0;
    gap: 4px;
    padding: 8px 10px 8px 12px;
    font-size: var(--fs-sm, 13px);
    font-weight: var(--fw-medium, 500);
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft, color-mix(in srgb, var(--primary) 8%, transparent));
    white-space: nowrap;
    max-width: 40%;
    overflow: hidden;
}
.section-pill--next span {
    overflow: hidden;
    text-overflow: ellipsis;
}
.section-pill--next .bi-chevron-right {
    font-size: 11px;
    flex-shrink: 0;
}

/* ───────── Section sheet (shared mobile bottom sheet) ───────── */
.section-sheet {
    position: fixed;
    inset: 0;
    z-index: 1050;
}

.section-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
}

.section-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface-1);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18);
    transition: transform 0.28s cubic-bezier(0.34, 1.36, 0.64, 1);
}

.section-sheet__handle {
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
    margin: 8px auto 6px;
}

.section-sheet__header {
    padding: 4px 16px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-soft);
}

.section-sheet__title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-1);
}

.section-sheet__close {
    background: transparent;
    border: 0;
    font-size: 20px;
    color: var(--ink-3);
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.section-sheet__close:active {
    background: var(--primary-soft);
}

.section-sheet__body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 24px;
}

.section-sheet__group {
    margin-top: 14px;
}

.section-sheet__group:first-child {
    margin-top: 4px;
}

.section-sheet__group-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
    padding: 8px 4px 6px;
}

.section-sheet__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.section-sheet__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    background: var(--surface-1);
    border: 0;
    border-radius: 10px;
    text-align: left;
    width: 100%;
    font-size: var(--fs-base, 14px);
    color: var(--ink-1);
    cursor: pointer;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.12s ease;
}

.section-sheet__item:active {
    background: var(--primary-soft);
}

.section-sheet__item--active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.section-sheet__item i {
    width: 22px;
    font-size: 16px;
    color: var(--ink-3);
    text-align: center;
}

.section-sheet__item--active i {
    color: var(--primary);
}

.section-sheet__meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-size: 16px;
}

.section-sheet__dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--border-strong);
}

.section-sheet__dot--done {
    background: var(--good);
}

.section-sheet__group-count {
    font-size: 10px;
    font-weight: 500;
    color: var(--ink-3);
    margin-left: auto;
}

/* Sheet transitions */
.section-sheet--enter { transition: opacity 0.2s ease; }
.section-sheet--enter-start { opacity: 0; }
.section-sheet--enter-start .section-sheet__panel { transform: translateY(100%); }
.section-sheet--enter-end { opacity: 1; }
.section-sheet--enter-end .section-sheet__panel { transform: translateY(0); }
.section-sheet--leave { transition: opacity 0.2s ease; }
.section-sheet--leave-start { opacity: 1; }
.section-sheet--leave-end { opacity: 0; }

[data-bs-theme="dark"] .section-sheet__backdrop {
    background: rgba(0, 0, 0, 0.6);
}

[data-bs-theme="dark"] .section-sheet__panel {
    background: var(--surface-2);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .section-sheet__header {
    border-bottom-color: var(--border-soft);
}

/* ───────── Dark mode ───────── */
[data-bs-theme="dark"] .bottom-nav {
    background: var(--surface-1);
    border-top-color: var(--border-soft);
    box-shadow: 0 -8px 24px -8px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .fab-new-profile {
    box-shadow: 0 4px 14px 0 rgba(129, 140, 248, 0.25);
}

[data-bs-theme="dark"] .chip-rail {
    background: rgba(129, 140, 248, 0.07);
}

[data-bs-theme="dark"] .chip-rail__chip--active {
    background: var(--surface-2);
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ───────── Chip rail (horizontal insight pills) ───────── */
.chip-rail-wrap {
    padding: 0 12px 12px;
    overflow: hidden;
}

.chip-rail {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px;
    background: rgba(99, 102, 241, 0.06);
    border-radius: 10px;
}

.chip-rail::-webkit-scrollbar {
    display: none;
}

.chip-rail__chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: 7px;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: var(--fw-medium);
    color: var(--ink-3);
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.12s ease, color 0.12s ease;
}

.chip-rail__chip:active {
    background: var(--primary-soft);
}

.chip-rail__chip--active {
    background: var(--surface-3);
    color: var(--primary);
    font-weight: var(--fw-bold);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chip-rail__chip--active .chip-rail__dot {
    border-color: var(--primary);
}

.chip-rail__chip--active .chip-rail__dot--done {
    background: var(--primary);
    border-color: var(--primary);
}

.chip-rail__count {
    font-size: 0.7em;
    opacity: 0.7;
    margin-left: 2px;
}

.chip-rail__chip--success {
    background: var(--bs-success-bg-subtle, #d1e7dd);
    color: var(--bs-success-text-emphasis, #0a3622);
    border-color: var(--bs-success-bg-subtle, #d1e7dd);
}
.chip-rail__chip--warning {
    background: var(--bs-warning-bg-subtle, #fff3cd);
    color: var(--bs-warning-text-emphasis, #664d03);
    border-color: var(--bs-warning-bg-subtle, #fff3cd);
}
.chip-rail__chip--danger {
    background: var(--bs-danger-bg-subtle, #f8d7da);
    color: var(--bs-danger-text-emphasis, #58151c);
    border-color: var(--bs-danger-bg-subtle, #f8d7da);
}
.chip-rail__chip--secondary {
    background: var(--bs-secondary-bg-subtle, #e2e3e5);
    color: var(--bs-secondary-text-emphasis, #41464b);
    border-color: var(--bs-secondary-bg-subtle, #e2e3e5);
}

.chart-about summary::-webkit-details-marker { display: none; }
.chart-about[open] summary .bi-chevron-down { transform: rotate(180deg); }
.chart-about summary:hover { background: var(--bs-tertiary-bg) !important; }

.chip-rail__dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--border-strong);
    flex-shrink: 0;
}

.chip-rail__dot--done {
    background: var(--good);
}

/* ───────── Desktop: Section rail (left sidebar) ───────── */
@media (min-width: 992px) {
    .section-layout {
        display: flex;
        gap: 0;
    }

    .section-rail {
        width: 240px;
        flex-shrink: 0;
        position: sticky;
        top: 1rem;
        align-self: flex-start;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
        padding: 0.75rem;
        margin-top: 1rem;
    }

    .section-rail__group-label {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 10px;
        letter-spacing: 0.08em;
        font-weight: var(--fw-bold);
        text-transform: uppercase;
        color: var(--ink-3);
        padding: 10px 8px 6px;
    }

    .section-rail__group-count {
        font-size: 9px;
        font-weight: var(--fw-medium);
        color: var(--ink-3);
        margin-left: auto;
    }

    .section-rail__item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 10px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 13px;
        color: var(--ink-1);
        border: 0;
        background: transparent;
        width: 100%;
        text-align: left;
        font-family: inherit;
        transition: background 0.12s ease;
    }

    .section-rail__item:hover {
        background: var(--surface-0);
    }

    .section-rail__item--active {
        background: var(--primary-soft);
        color: var(--primary);
        font-weight: var(--fw-bold);
    }

    .section-rail__item i {
        color: var(--ink-3);
        font-size: 14px;
        width: 18px;
        text-align: center;
    }

    .section-rail__item--active i {
        color: var(--primary);
    }

    .section-rail__dot {
        width: 6px;
        height: 6px;
        border-radius: 999px;
        background: var(--border-strong);
        margin-left: auto;
        flex-shrink: 0;
    }

    .section-rail__dot--done {
        background: var(--good);
    }

    .section-rail__main {
        flex: 1;
        min-width: 0;
    }
}
