/*.page-shell {*/
/*    display: flex*/
/*}*/
.page-shell {
    display: flex;
    gap: 1rem;
}

@media (max-width: 768px) {
    .page-shell {
        flex-direction: column;
    }
}

/* content fills remaining space */
.content1 {
    flex: 1;
    overflow-y: auto;
    height: 80vh
}

@media (min-width: 768px) {
    .content1 {
        padding-left: 24px;
    }
}

@media (max-width: 767px) {
    .content1 {
        padding-left: 0;
    }
}


/* container */
.sidebar-inner {
    position: relative;
}

/* sticky filter */
.sidebar-filter {
    position: sticky;
    top: 0;
    background: #fff; /* prevents overlap */
    z-index: 5;
}

/* spacing */
.sidebar-list {
    padding: 5px;
}


/* sticky sidebar */
/*.sidebar {*/
/*    position: sticky;*/
/*    top: 20px; !* adjust to match header + nav height *!*/
/*    height: calc(100vh - 220px);*/
/*    overflow-y: auto;*/
/*    width: 300px;*/
/*    flex-shrink: 0;*/
/*    background: #fff;*/
/*}*/

.sidebar {
    background: #fff;
    overflow-y: auto;
}

/* Desktop behavior */
@media (min-width: 768px) {
    .sidebar {
        position: sticky;
        top: 20px;
        max-height: 80vh;
        width: 300px;
        flex-shrink: 0;
    }
}

/* Mobile behavior */
@media (max-width: 767px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
    }
}

/* main content scrolls with page */
.content {
    flex: 1;
    padding: 24px;
}

.layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1rem;
}

.menu {
    border: 1px solid #ddd;
    border-radius: .5rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.menu-header {
    padding: .75rem .9rem;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    font-weight: 600;
}

.menu-search {
    padding: .5rem .9rem;
    border-bottom: 1px solid #f0f0f0;
}

.menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: auto;
    max-height: calc(100vh - 220px);
}

.menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    padding: .6rem .9rem;
    border-bottom: 1px solid #f6f6f6;
    cursor: pointer;
}

.menu-item:hover {
    background: #f6f9ff;
}

.menu-item.active {
    background: #e9f2ff;
}

.menu-item .code {
    font-size: .78rem;
    color: #666;
}

.detail {
    border: 1px solid #ddd;
    border-radius: .5rem;
    padding: 1rem;
    background: #fff;
    min-height: 60vh;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .menu-list {
        max-height: none;
    }
}

.modal.fade {
    opacity: 0;
    transition: opacity .15s linear;
}

.modal.show {
    opacity: 1;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

    .status-dot.active {
        background-color: #198754;
    }

    .status-dot.inactive {
        background-color: #dc3545;
    }

.status-item {
    position: relative;
    padding-left: 14px;
    cursor: pointer;
}

.status-bar {
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 4px;
    border-radius: 2px;
}

    .status-bar.active {
        background-color: #198754; /* green */
    }

    .status-bar.inactive {
        background-color: #dc3545; /* red */
    }

    .status-bar.empty {
        background-color: #adb5bd; /* gray */
    }

.category-list {
    max-height: 250px;
    overflow-y: auto;
}

.category-option {
    padding: 6px 10px;
    cursor: pointer;
}

    .category-option:hover {
        background: #f1f1f1;
    }

    .category-option.active {
        background: #0d6efd;
        color: white;
    }

.category-sidebar-banner {
    color: #16405f;
    background: #eef7fc;
}

.preference-switch {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 1.5rem;
    padding-left: 0;
}

.preference-switch .form-check-input {
    flex: 0 0 auto;
    float: none;
    margin: 0;
}

.preference-switch .form-check-label {
    margin: 0;
}

.category-page-shell {
    width: 100%;
}

.category-page-shell-with-sidebar {
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.category-page-shell-sidebar-collapsed {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: .75rem;
}

.category-content-panel {
    min-width: 0;
}

.category-sidebar-panel {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    background: #fff;
    border: 1px solid #dce4ec;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(20, 39, 62, 0.08);
}

.category-sidebar-panel.collapsed {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 48px;
    min-height: 48px;
    overflow: visible;
}

.category-sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid #e8eef4;
    background: #f8fafc;
}

.category-sidebar-search {
    padding: .65rem .75rem;
    border-bottom: 1px solid #e8eef4;
    background: #fff;
}

.category-sidebar-search .input-group-text {
    color: #607284;
    background: #f8fafc;
}

.category-sidebar-search-status {
    margin-top: .35rem;
    color: #6c757d;
    font-size: .78rem;
}

.category-sidebar-title {
    font-weight: 700;
    line-height: 1.2;
    color: #25364a;
}

.category-sidebar-subtitle {
    margin-top: .2rem;
    font-size: .82rem;
    color: #66788a;
}

.category-sidebar-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 1px solid #d3dde7;
    border-radius: 6px;
    color: #31516d;
    text-decoration: none;
    background: #fff;
}

.category-sidebar-home:hover,
.category-sidebar-home.active {
    color: #0d6efd;
    border-color: #9ec5fe;
    background: #edf5ff;
}

.category-sidebar-collapse,
.category-sidebar-rail-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #d3dde7;
    border-radius: 6px;
    color: #31516d;
    background: #fff;
}

.category-sidebar-collapse:hover,
.category-sidebar-rail-button:hover {
    color: #0d6efd;
    border-color: #9ec5fe;
    background: #edf5ff;
}

.category-sidebar-rail-button {
    margin: .4rem 0;
}

.category-sidebar-list {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 7.5rem);
    overflow-y: auto;
    padding: .45rem;
}

.category-sidebar-item {
    --category-sidebar-depth: 0;
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    align-items: center;
    gap: .45rem;
    min-height: 38px;
    padding: .45rem .55rem .45rem calc(.55rem + (var(--category-sidebar-depth) * 1rem));
    border-radius: 6px;
    color: #2b3a4a;
    text-decoration: none;
}

.category-sidebar-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-sidebar-result-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.category-sidebar-result-name,
.category-sidebar-result-path {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-sidebar-result-path {
    margin-top: .15rem;
    color: #7a8a9a;
    font-size: .74rem;
    font-weight: 400;
}

.category-sidebar-item:hover {
    color: #0d6efd;
    background: #f1f7ff;
}

.category-sidebar-item.active {
    color: #0b4da2;
    background: #e8f2ff;
    font-weight: 700;
}

.category-sidebar-item.sop {
    font-size: .92rem;
    color: #43566b;
}

.category-sidebar-count {
    min-width: 1.5rem;
    padding: .1rem .35rem;
    border-radius: 999px;
    color: #607284;
    background: #eef2f6;
    text-align: center;
    font-size: .72rem;
    font-weight: 600;
}

.category-sidebar-empty {
    padding: .75rem;
    color: #6c757d;
}

@media (max-width: 991.98px) {
    .category-page-shell-with-sidebar {
        grid-template-columns: 1fr;
    }

    .category-page-shell-sidebar-collapsed {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .category-sidebar-panel {
        position: static;
        max-height: none;
    }

    .category-sidebar-list {
        max-height: 45vh;
    }
}

html, body {
    height: 100%;
    overflow: auto;
}

@media (max-width: 767px) {

    html, body {
        overflow:auto;
    }
}

.card-img-top {
    height: 150px;
    object-fit: contain;
}

.card-image-container {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

    .card-image-container img {
        max-height: 100%;
        max-width: 100%;
        object-fit: contain;
    }

.sop-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    cursor: zoom-in;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

    .sop-thumbnail:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 14px rgba(0,0,0,0.2);
    }

@media (max-width: 768px) {
    .sop-thumbnail {
        width: 100px;
        height: 100px;
    }
}

.image-caption {
    min-height: 28px;
}

.sop-print-header,
.sop-print-footer {
    display: none;
}

@media print {
    @page {
        size: auto;
        margin: 14mm 13mm 16mm;
    }

    html:has(.sop-print-layout),
    body:has(.sop-print-layout) {
        height: auto !important;
        overflow: visible !important;
    }

    body:has(.sop-print-layout) {
        color: #17222d;
        background: #fff !important;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 10pt;
        line-height: 1.45;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body:has(.sop-print-layout) .navbar-header,
    body:has(.sop-print-layout) #layout-wrapper > nav,
    body:has(.sop-print-layout) .category-sidebar-banner,
    body:has(.sop-print-layout) .toast-container,
    body:has(.sop-print-layout) .rz-dialog-wrapper,
    body:has(.sop-print-layout) .modal,
    body:has(.sop-print-layout) .modal-backdrop,
    body:has(.sop-print-layout) #components-reconnect-modal,
    .sop-print-layout .category-sidebar-panel,
    .sop-print-layout .sop-summary-card,
    .sop-print-layout .card-footer,
    .sop-print-layout .btn,
    .sop-print-layout .tooltip,
    .sop-print-layout .alert-border-left {
        display: none !important;
    }

    body:has(.sop-print-layout) #layout-wrapper {
        min-height: 0 !important;
    }

    body:has(.sop-print-layout) #layout-wrapper > .container-fluid,
    body:has(.sop-print-layout) .page-content {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0 !important;
    }

    .sop-print-layout,
    .sop-print-layout.category-page-shell-with-sidebar,
    .sop-print-layout.category-page-shell-sidebar-collapsed {
        display: block;
        width: 100%;
    }

    .sop-print-layout .category-content-panel {
        width: 100%;
    }

    .sop-print-header {
        display: block;
        margin: 0 0 8mm;
        padding: 0 0 6mm;
        border-bottom: 2px solid #315f88;
    }

    .sop-print-brand {
        display: flex;
        align-items: center;
        gap: 3mm;
        margin-bottom: 5mm;
        color: #315f88;
    }

    .sop-print-brand img {
        width: 9mm;
        height: 9mm;
        object-fit: contain;
    }

    .sop-print-brand-name {
        font-size: 12pt;
        font-weight: 700;
        letter-spacing: .08em;
    }

    .sop-print-document-type {
        color: #5e6b77;
        font-size: 8pt;
        letter-spacing: .06em;
        text-transform: uppercase;
    }

    .sop-print-header h1 {
        margin: 0 0 5mm;
        color: #162b3d;
        font-size: 24pt;
        font-weight: 700;
        line-height: 1.15;
    }

    .sop-print-metadata {
        display: grid;
        grid-template-columns: .7fr 1.2fr 1.2fr .55fr;
        gap: 3mm 7mm;
        margin: 0;
    }

    .sop-print-metadata > div {
        min-width: 0;
    }

    .sop-print-metadata dt {
        margin: 0 0 1mm;
        color: #667481;
        font-size: 7.5pt;
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
    }

    .sop-print-metadata dd {
        margin: 0;
        color: #17222d;
        font-size: 9.5pt;
        font-weight: 600;
        overflow-wrap: anywhere;
    }

    .sop-print-content-row,
    .sop-steps-list {
        display: block !important;
        margin: 0 !important;
    }

    .sop-overview-column,
    .sop-steps-column,
    .sop-step-card {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }

    .sop-overview-column,
    .sop-steps-column {
        flex: none !important;
    }

    .sop-step-card {
        margin: 0 0 5mm;
        break-inside: avoid-page;
        page-break-inside: avoid;
    }

    .sop-steps-list {
        counter-reset: sop-print-step;
    }

    .sop-steps-list .sop-step-step {
        counter-increment: sop-print-step;
    }

    .sop-print-layout .card {
        height: auto !important;
        margin: 0;
        border: 1px solid #cbd5df;
        border-left: 3px solid #467aa6;
        border-radius: 3px;
        background: #fff !important;
        box-shadow: none !important;
    }

    .sop-print-layout .sop-step-description .card {
        border-left-color: #27869a;
        background: #f3fafb !important;
    }

    .sop-print-layout .sop-step-note .card {
        border-left-color: #d28a21;
        background: #fff9ed !important;
    }

    .sop-print-layout .card-body {
        padding: 4mm 4.5mm;
    }

    .sop-print-layout .card-title {
        margin: 0 0 3mm;
        color: #1e3447;
        font-size: 12pt;
        font-weight: 700;
        line-height: 1.3;
    }

    .sop-steps-list .sop-step-step .card-title::before,
    .sop-overview-column .sop-step-description .card-title::before,
    .sop-overview-column .sop-step-note .card-title::before {
        display: block;
        margin-bottom: 1mm;
        color: #52708a;
        font-size: 7.5pt;
        font-weight: 700;
        letter-spacing: .08em;
    }

    .sop-steps-list .sop-step-step .card-title::before {
        content: "STEP " counter(sop-print-step);
    }

    .sop-overview-column .sop-step-description .card-title::before {
        content: "OVERVIEW";
    }

    .sop-overview-column .sop-step-note .card-title::before {
        content: "NOTE";
        color: #9b651c;
    }

    .sop-print-layout .markdown-body > :first-child {
        margin-top: 0;
    }

    .sop-print-layout .markdown-body > :last-child {
        margin-bottom: 0;
    }

    .sop-print-layout .markdown-body h1,
    .sop-print-layout .markdown-body h2,
    .sop-print-layout .markdown-body h3,
    .sop-print-layout .markdown-body h4,
    .sop-print-layout .markdown-body h5,
    .sop-print-layout .markdown-body h6 {
        break-after: avoid-page;
        page-break-after: avoid;
    }

    .sop-print-layout .markdown-body p,
    .sop-print-layout .markdown-body li {
        orphans: 3;
        widows: 3;
    }

    .sop-print-layout .markdown-body table {
        width: 100%;
        border-collapse: collapse;
    }

    .sop-print-layout .markdown-body th,
    .sop-print-layout .markdown-body td {
        padding: 2mm;
        border: 1px solid #bfc9d3;
    }

    .sop-print-layout .markdown-body pre,
    .sop-print-layout .markdown-body code {
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    .sop-print-layout a {
        color: inherit !important;
        text-decoration: none !important;
    }

    .sop-print-layout img {
        break-inside: avoid-page;
        page-break-inside: avoid;
    }

    .sop-print-layout .sop-thumbnail {
        width: auto !important;
        height: auto !important;
        max-width: 46mm;
        max-height: 58mm;
        border: 1px solid #cbd5df;
        object-fit: contain;
    }

    .sop-print-layout .sop-big-image {
        width: auto;
        max-width: 100%;
        max-height: 95mm;
        border: 1px solid #cbd5df;
        object-fit: contain;
    }

    .sop-print-layout .text-muted {
        color: #56636f !important;
    }

    .sop-print-footer {
        display: flex;
        justify-content: space-between;
        gap: 8mm;
        margin-top: 7mm;
        padding-top: 3mm;
        border-top: 1px solid #cbd5df;
        color: #687580;
        font-size: 7.5pt;
    }

    .sop-print-footer span:last-child {
        text-align: right;
    }
}

.draggable {
    cursor: grab;
}

    .draggable:active {
        cursor: grabbing;
    }
