/* Product Weight Selection System - application styles (Bootstrap 5.3 base). */

body {
    background-color: var(--bs-body-bg);
}

.skip-link {
    position: absolute;
    top: .5rem;
    left: .5rem;
    z-index: 1100;
    padding: .5rem 1rem;
    background: var(--bs-body-bg);
    border: 2px solid var(--bs-primary);
}

/* ---------------------------------------------------------------- layout: top bar + sidebar */

:root {
    --app-sidebar-width: 248px;
    --app-sidebar-bg: #172033;
    --app-sidebar-text: #c3cad8;
    --app-sidebar-muted: #7d889c;
    --app-sidebar-hover: rgba(255, 255, 255, .06);
    --app-sidebar-active: rgba(59, 130, 246, .16);
    --app-accent: #3b82f6;
    --app-topbar-height: 3.75rem;
}

.app-body {
    background-color: #f5f7fa;
}

.icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-lg {
    width: 1.4rem;
    height: 1.4rem;
}

.app-topbar {
    min-height: var(--app-topbar-height);
    z-index: 1030;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.btn-icon {
    padding: .35rem;
    line-height: 1;
    color: var(--bs-body-color);
    border: 0;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: var(--bs-body-color);
}

.app-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: .55rem;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
}

.app-brand-title {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: .01em;
    line-height: 1.1;
}

.app-brand-sub {
    font-size: .72rem;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: .6rem;
    border: 1px solid transparent;
    padding: .25rem .5rem;
}

.user-menu-btn:hover,
.user-menu-btn[aria-expanded="true"] {
    background-color: var(--bs-tertiary-bg);
    border-color: var(--bs-border-color);
}

.small-xs {
    font-size: .72rem;
}

.user-menu {
    min-width: 15rem;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    background-color: #dbeafe;
    color: #1e40af;
    font-weight: 700;
    font-size: .9rem;
    flex: 0 0 auto;
}

.avatar-sm {
    width: 1.85rem;
    height: 1.85rem;
    font-size: .8rem;
    background-color: rgba(255, 255, 255, .12);
    color: #fff;
}

.app-shell {
    display: flex;
    /* fill the window between the top bar and the footer */
    min-height: calc(100vh - var(--app-topbar-height) - 2.6rem);
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
}

/* Sidebar: fixed column from 992px; below that an off-canvas panel opened from the top bar. */
.app-sidebar {
    flex: 0 0 auto;
}

.app-sidebar-panel {
    background-color: var(--app-sidebar-bg) !important;
    color: var(--app-sidebar-text);
}

@media (min-width: 992px) {
    .app-sidebar {
        width: var(--app-sidebar-width);
        background-color: var(--app-sidebar-bg);
    }

    .app-sidebar-panel {
        position: sticky;
        top: var(--app-topbar-height);
        height: calc(100vh - var(--app-topbar-height));
        overflow-y: auto;
    }

    .app-sidebar-panel .offcanvas-body {
        height: 100%;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar-panel {
        --bs-offcanvas-width: 280px;
    }
}

.side-nav {
    padding: .75rem .75rem 1rem;
}

.side-section {
    margin: 1.1rem .75rem .4rem;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--app-sidebar-muted);
}

.side-section:first-child {
    margin-top: .35rem;
}

.side-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .75rem;
    margin-bottom: .15rem;
    border-radius: .5rem;
    color: var(--app-sidebar-text);
    text-decoration: none;
    font-size: .925rem;
    transition: background-color .15s, color .15s;
}

.side-link:hover {
    background-color: var(--app-sidebar-hover);
    color: #fff;
}

.side-link.active {
    background-color: var(--app-sidebar-active);
    color: #fff;
    font-weight: 600;
}

.side-link.active::before {
    content: "";
    position: absolute;
    left: -.75rem;
    top: .45rem;
    bottom: .45rem;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background-color: var(--app-accent);
}

.side-link.active .icon {
    color: #93c5fd;
}

.side-link:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 1px;
}

.side-footer {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .85rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .85rem;
    color: #e5e9f0;
}

.side-footer-role {
    font-size: .72rem;
    color: var(--app-sidebar-muted);
}

/* Visible keyboard focus everywhere. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--bs-primary);
    outline-offset: 2px;
}

.login-page {
    background-color: var(--bs-tertiary-bg);
    min-height: 100vh;
}

.permission-list li {
    display: inline-block;
    margin: 0 .5rem .5rem 0;
    padding: .2rem .6rem;
    border-radius: 1rem;
    background: var(--bs-secondary-bg);
    font-size: .875rem;
}

/* ---------------------------------------------------------------- classification browser */

.weights-table {
    min-width: 760px;
}

.weights-table .col-seg { width: 4.5rem; }
.weights-table .col-code { width: 8rem; white-space: nowrap; }
.weights-table .col-level { width: 8.5rem; white-space: nowrap; }
.weights-table .col-spec { width: 16%; }
.weights-table .col-include { width: 6rem; white-space: nowrap; }

.product-code {
    color: var(--bs-body-color);
    font-size: .9rem;
}

/* Level badges: colour plus text "L1".."L5" (colour is never the only signal) */
.level-badge { font-weight: 600; }
.level-badge-1 { background-color: #343a40; }
.level-badge-2 { background-color: #0b5ed7; }
.level-badge-3 { background-color: #6f42c1; }
.level-badge-4 { background-color: #b02a37; }
.level-badge-5 { background-color: #146c43; }

.desc-wrap {
    display: flex;
    align-items: flex-start;
    gap: .35rem;
}

/* Indentation shows depth in tree mode, in addition to the level badge */
.desc-wrap.indent-1 { padding-left: 0; }
.desc-wrap.indent-2 { padding-left: 1.25rem; }
.desc-wrap.indent-3 { padding-left: 2.5rem; }
.desc-wrap.indent-4 { padding-left: 3.75rem; }
.desc-wrap.indent-5 { padding-left: 5rem; }

.tree-toggle,
.tree-spacer {
    flex: 0 0 1.5rem;
    width: 1.5rem;
    min-height: 1.5rem;
    text-decoration: none;
    line-height: 1.5rem;
}

.tree-caret {
    font-size: 1rem;
}

.lvl-row.lvl-1 .desc,
.lvl-row.lvl-2 .desc {
    font-weight: 600;
}

/* Breadcrumbs wrap so long paths never push the Include column off screen */
.breadcrumb-line {
    overflow-wrap: anywhere;
}

.show-in-tree {
    font-size: .8rem;
}

.row-highlight > td {
    background-color: var(--bs-warning-bg-subtle) !important;
    transition: background-color .3s;
}

/* Phones: each row becomes a stacked card with labelled fields */
@media (max-width: 575.98px) {
    .weights-table {
        min-width: 0;
    }

    .weights-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .weights-table tbody tr {
        display: block;
        border: 1px solid var(--bs-border-color);
        border-radius: .5rem;
        margin-bottom: .75rem;
        padding: .25rem .5rem;
    }

    .weights-table tbody tr.d-none {
        display: none;
    }

    .weights-table tbody td {
        display: flex;
        gap: .75rem;
        border: 0;
        padding: .25rem 0;
        width: auto;
    }

    .weights-table tbody td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 7.5rem;
        font-weight: 600;
        color: var(--bs-secondary-color);
    }

    .weights-table tbody td[data-label="Specification"]:empty {
        display: none;
    }

    .desc-wrap.indent-2,
    .desc-wrap.indent-3,
    .desc-wrap.indent-4,
    .desc-wrap.indent-5 {
        padding-left: 0;
    }
}

/* ---------------------------------------------------------------- selection (Phase 4) */

.selection-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.row-pending > td {
    background-color: var(--bs-warning-bg-subtle);
}

.include-wrap {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding-left: 0;
}

.include-wrap .form-check-input {
    float: none;
    margin: 0;
    width: 1.15rem;
    height: 1.15rem;
    cursor: pointer;
}

.include-wrap .form-check-input:disabled {
    cursor: not-allowed;
}

/* ---------------------------------------------------------------- dashboard (Phase 7) */

.stat-card {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    height: 100%;
    padding: 1rem 1.1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .75rem;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

a.stat-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .12);
    transform: translateY(-1px);
}

.stat-label {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bs-secondary-color);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.15;
}

.stat-hint {
    font-size: .8rem;
    color: var(--bs-secondary-color);
}

.stat-good .stat-value { color: #146c43; }
.stat-muted .stat-value { color: #6c757d; }
.stat-accent .stat-value { color: #1d4ed8; }

.stat-progress,
.seg-progress {
    width: 100%;
    height: .5rem;
    appearance: none;
    border: 0;
    border-radius: 1rem;
    overflow: hidden;
    background-color: #e5e7eb;
}

.stat-progress::-webkit-progress-bar,
.seg-progress::-webkit-progress-bar {
    background-color: #e5e7eb;
    border-radius: 1rem;
}

.stat-progress::-webkit-progress-value,
.seg-progress::-webkit-progress-value {
    background-color: #2563eb;
    border-radius: 1rem;
}

.stat-progress::-moz-progress-bar,
.seg-progress::-moz-progress-bar {
    background-color: #2563eb;
    border-radius: 1rem;
}

.seg-bar-col {
    min-width: 10rem;
}

.level-list li a {
    padding: .5rem .25rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
    color: var(--bs-body-color);
    text-decoration: none;
}

.level-list li:last-child a {
    border-bottom: 0;
}

.level-list li a:hover {
    background-color: var(--bs-tertiary-bg);
}

/* ---------------------------------------------------------------- audit (Phase 7) */

.audit-table td {
    vertical-align: top;
}

.audit-diff {
    font-size: .82rem;
    margin: .4rem 0 0;
}

.audit-diff th {
    font-weight: 600;
    color: var(--bs-secondary-color);
    padding-right: .75rem;
    white-space: nowrap;
}

.audit-diff .old {
    color: #b02a37;
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

.audit-diff .new {
    color: #146c43;
}

.audit-filters .form-check-inline {
    margin-right: .75rem;
}

/* ---------------------------------------------------------------- varieties and delete */

.level-badge-6 { background-color: #a35200; }
.desc-wrap.indent-6 { padding-left: 6.25rem; }

@media (max-width: 575.98px) {
    .desc-wrap.indent-6 { padding-left: 0; }
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .15rem .75rem;
    margin-top: .15rem;
}

.row-actions .btn-link {
    font-size: .8rem;
    text-decoration: none;
}

/* Delete selection checkboxes appear only in "Select to delete" mode */
.del-box {
    display: none;
    float: none;
    margin-top: 0;
    vertical-align: middle;
}

.delete-mode .del-box {
    display: inline-block;
}

.delete-mode .weights-table tbody tr:has(.del-box:checked) > td {
    background-color: var(--bs-danger-bg-subtle);
}

.delete-bar {
    border-top: 1px dashed var(--bs-danger-border-subtle);
    padding-top: .5rem;
    margin-top: .5rem;
}

.v-results {
    max-height: 26rem;
    overflow-y: auto;
}

.v-result.active code,
.v-result.active .text-body-secondary {
    color: inherit !important;
}

/* ---------------------------------------------------------------- yellow header and footer (approved 2026-12-02) */

:root {
    --app-yellow: #F5C518;
    --app-yellow-border: #D9AD0F;
    --app-on-yellow: #2B2300;
    --app-on-yellow-muted: #5C4A00;
}

.app-topbar {
    background-color: var(--app-yellow);
    color: var(--app-on-yellow);
    border-bottom: 1px solid var(--app-yellow-border);
}

.app-topbar .app-brand,
.app-topbar .btn-icon,
.app-topbar .user-menu-btn {
    color: var(--app-on-yellow);
}

.app-topbar .app-brand-sub,
.app-topbar .user-menu-btn .text-body-secondary {
    color: var(--app-on-yellow-muted) !important;
}

.app-topbar .app-brand-mark {
    background: var(--app-on-yellow);
    color: var(--app-yellow);
}

.app-topbar .avatar {
    background-color: var(--app-on-yellow);
    color: var(--app-yellow);
}

.app-topbar .user-menu-btn:hover,
.app-topbar .user-menu-btn[aria-expanded="true"] {
    background-color: rgba(43, 35, 0, .08);
    border-color: rgba(43, 35, 0, .25);
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .25rem 1rem;
    padding: .6rem 1rem;
    background-color: var(--app-yellow);
    color: var(--app-on-yellow);
    border-top: 1px solid var(--app-yellow-border);
    font-size: .8rem;
}
