/**
 * MIBT Blazor Application Styles
 * =============================
 * A comprehensive stylesheet for the MIBT Blazor WASM application that defines
 * the visual styling for the entire UI. The stylesheet is organized into logical
 * sections using #region for better navigation and maintenance.
 * 
 * Color Palette:
 * - Primary Blue: #0072ce
 * - Light Blue: #b3d9ff
 * - Background: #FAFAFA
 * - Success Green: #90EE90, #C1FFC1
 * - Error Red: #ffe6e6
 * - Warning/Modified: #E0F5FF
 * 
 * Last updated: June 20, 2025
 */

/* #region Base Elements - Core styling for base HTML elements */

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
    background-color: #FAFAFA !important;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    overflow: hidden;
}

input[type="text"],
input[type="list"] {
    text-transform: uppercase;
}

hr {
    color: black;
    margin: 0;
}
/* #endregion */

/* #region Utility Classes - Reusable utility classes */
.hidden {
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
}

.visible {
    display: block !important;
}

.disabled {
    filter: invert(100%) grayscale(100%) brightness(50%);
    pointer-events: none;
}

.enabled {
    color: black;
    pointer-events: all;
    cursor: pointer;
}

.close {
    cursor: pointer !important;
    color: red !important;
    background-color: transparent !important;
    border: 0;
}

.bubble {
    display: inline-block;
    margin-right: 5px;
    background-color: lightskyblue;
    color: black;
    text-align: center;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    text-decoration: none;
}
/* #endregion */

/* #region Progress Spinner - Styling for the application's progress indicator */
.progress-container-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0,0,0,0.5);
    z-index: 1500;
}

#progress-container-modal {
    position: fixed !important;
    z-index: 1510;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(480px, calc(100vw - 40px));
    /* Keep some breathing room above/below even when the table is tall. */
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    border-radius: 8px;
    border: 1px solid white;
    background-color: white;
    text-align: center;
}

#progress-container-header {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: ghostwhite;
    font-size: 18pt;
    font-weight: bold;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    overflow: hidden;
    padding: 10px;
    color: #333;
    cursor: pointer;
}

.progress-container-draggable-header {
    background-color: ghostwhite;
    border-bottom: 1px solid #ddd;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

    .progress-container-draggable-header:hover {
        background: linear-gradient(135deg, #e8e8e8 0%, #ddd 100%);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .progress-container-draggable-header:active {
        background: linear-gradient(135deg, #ddd 0%, #ccc 100%);
        box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }

    .progress-container-draggable-header:hover .material-symbols-outlined {
        opacity: 1;
    }

#progress-container-table {
    width: 100%;
    margin: 10px 0;
}

    #progress-container-table th {
        font-weight: bold;
        text-align: right;
        padding: 5px;
        background-color: white;
        border-bottom: 1px solid #ddd;
    }

    #progress-container-table td {
        text-align: right;
        padding: 5px;
        border-bottom: 1px solid #eee;
    }

#progress-container-button-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background-color: #f9f9f9;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-top: 1px solid #ddd;
}

/* Dialog buttons */
#progress-container-toggle {
    padding: 8px 16px;
    background-color: #0072ce;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

    #progress-container-toggle:hover {
        background-color: #005a9e;
    }

    #progress-container-toggle:focus {
        outline: 2px solid #0072ce;
        outline-offset: 2px;
    }

/* Empty rule - can be removed */
#progess-contaner-toggle {
}
/* #endregion */

/* #region Main Layout - Core layout structure for the application */
.main-page {
    height: calc(100vh - 5px) !important;
    width: calc(100vw - 5px) !important;
    border-radius: 15px;
    background-color: #FAFAFA;
}

.main-body {
    width: 100% !important;
    height: calc(100vh - 100px);
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    position: relative;
    overflow: hidden;
}

    /* Main page panels (grids) should stack and only the active one should be displayed */
    .main-body > div[id$='-grid'] {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
    }

.main-header {
    background-color: #0072ce !important;
    font-size: 15pt !important;
    font-weight: bold !important;
    width: 100% !important;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

.loading-header {
    background-color: #0072ce !important;
    font-size: 15pt !important;
    font-weight: bold !important;
    width: 100% !important;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    padding: 0px;
    margin: 0px;
    height: 47px;
}

.main-image {
    width: 170px;
    padding: 0px;
    margin: 0px;
    height: 35px;
    white-space: nowrap;
}

.loading-image {
    height: 45px !important;
    width: 170px;
}

.main-name {
    text-align: left;
    vertical-align: bottom;
    color: white;
    width: 100px;
    line-height: 1;
    font-size: 12pt;
    border-left: 2px solid white;
    white-space: nowrap;
}

.main-version {
    color: white;
    font-size: 7pt;
}

.main-nav {
    font-size: 14pt;
    display: flex;
    justify-content: center; /* Centers content horizontally */
}
/* #endregion */

/* #region Main Menu - Top navigation menu styling */
.main-menu {
    text-align: center !important;
    vertical-align: middle !important;
    width: auto;
    color: white;
    white-space: nowrap;
    line-height: 50px !important;
}

.main-menu-table {
    margin: 0 auto; /* Center the table horizontally */
}

.main-menu-choice {
    padding: 5px 10px;
    display: inline-block;
}

.main-menu button {
    background-color: #0072ce !important;
    cursor: pointer !important;
    color: white !important;
    border: 0;
    font-weight: bold;
    display: inline-block;
    margin: 5px;
    line-height: normal !important;
    vertical-align: middle !important;
    height: auto !important;
    max-height: 40px !important;
}

    .main-menu button:hover {
        cursor: pointer !important;
        background-color: lightgray !important;
        border-radius: 5px !important;
        color: white !important;
        display: inline-block;
    }

    .main-menu button:focus {
        cursor: pointer !important;
    }

    .main-menu button.selected {
        background-color: #0072ce !important;
        border-bottom: 3px solid white !important;
        border-radius: 0 !important;
        color: white !important;
    }

.main-icons {
    width: 270px;
    white-space: nowrap;
    height: 50px !important;
    max-height: 50px !important;
    overflow: hidden !important;
}

    .main-icons a {
        color: white;
    }

    .main-icons table {
        height: 50px !important;
        max-height: 50px !important;
    }

    .main-icons tr {
        height: 50px !important;
        max-height: 50px !important;
    }

    .main-icons td {
        height: 50px !important;
        max-height: 50px !important;
        vertical-align: middle !important;
    }

    .main-icons span {
        line-height: normal !important;
        vertical-align: middle !important;
    }
/* #endregion */

/* #region Sheets Navigation - Tab-like navigation for content sheets */
.main-sheets {
    display: flex;
    width: 100% !important;
    height: 40px;
    white-space: nowrap !important;
    background-color: #b3d9ff !important;
    color: #333333 !important;
    font-size: 13pt !important;
    font-weight: bold !important;
    justify-content: center;
    vertical-align: bottom;
}

.main-sheets-progress {
    display: flex;
    width: 100%;
    height: 40px;
    white-space: nowrap !important;
    background-color: #b3d9ff !important;
    color: #333333 !important;
    font-size: 13pt !important;
    font-weight: bold !important;
    justify-content: left;
    vertical-align: bottom;
}

.main-sheets-progress-button {
    border-radius: 15px;
    background-color: #32CD32;
    border: 1px solid lightgrey;
    color: white;
    height: 30px;
    width: 30px;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
}

    .main-sheets-progress-button:focus {
        outline: none;
        box-shadow: 0 0 0 3px #ffffff, 0 0 0 1px #000000 inset; /* white outer border, black inner border */
    }

.main-sheets-progress-select {
    border-radius: 15px;
    background-color: white;
    border: 1px solid lightgrey;
    color: #333333;
    height: 30px;
    padding: 0 12px;
    font-size: 13pt;
    font-weight: bold;
}

    .main-sheets-progress-select:focus {
        outline: none;
        box-shadow: 0 0 0 3px #ffffff, 0 0 0 1px #000000 inset;
    }

.main-sheets-table {
    width: 100% !important;
    max-width: calc(100vw - 10px) !important;
}

    .main-sheets-table td:last-child {
        width: 40px !important;
    }

.main-sheets-table-sheets {
    vertical-align: bottom;
    width: 100% !important;
    text-align: center;
    padding: 0px;
    margin: 0px;
}

.main-sheets-table-sheets-div {
    width: 100%;
    overflow: hidden;
    padding-bottom: 5px;
}

.main-sheets-table-scroll {
    width: 40px;
}

.main-sheets .check-mark {
    color: darkgreen;
    font-size: 12pt;
    visibility: hidden;
    vertical-align: bottom;
}

.main-sheets .check-mark-checked {
    color: darkgreen;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets .check-mark-checked-issues {
    color: red;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets .check-mark-checked-warnings {
    color: #808000;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets .sheet {
    white-space: nowrap !important;
    padding: 0 !important;
    font-weight: bold !important;
    cursor: pointer !important;
    border-radius: 5px;
}

.main-sheets .sheet-selected {
    white-space: nowrap !important;
    padding: 0 !important;
    font-weight: bold !important;
    border-bottom: 6px solid white !important;
}

.main-sheets .sheet:hover {
    white-space: nowrap !important;
    background-color: white !important;
    padding: 0 !important;
    font-weight: bold !important;
    cursor: pointer !important;
}

.main-sheets .sheet-spacer {
    display: flex;
    white-space: nowrap;
    padding-left: 2px;
    padding-right: 2px;
}

.main-sheets-drop .check-mark {
    color: darkgreen;
    font-size: 12pt;
    visibility: hidden;
    vertical-align: bottom;
}

.main-sheets-drop .check-mark-checked {
    color: darkgreen;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets-drop .check-mark-checked-issues {
    color: red;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets-drop .check-mark-checked-warnings {
    color: #808000;
    font-size: 12pt;
    vertical-align: bottom;
}

.main-sheets-drop .sheet {
    white-space: nowrap !important;
    padding: 0 !important;
    font-weight: bold !important;
    cursor: pointer !important;
    border-radius: 5px;
}

.main-sheets-drop .sheet-selected {
    white-space: nowrap !important;
    padding: 0 !important;
    font-weight: bold !important;
    border-bottom: 6px solid white !important;
}

.main-sheets-drop .sheet:hover {
    white-space: nowrap !important;
    background-color: white !important;
    padding: 0 !important;
    font-weight: bold !important;
    cursor: pointer !important;
}

/* #endregion */

/* #region Page Structure - Content page layout components */
.page-body {
    max-width: 100vw !important;
}

.page-content {
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
}
/* #endregion */

.under-construction {
}

    .under-construction div:nth-of-type(2) {
        display: flex;
        flex-direction: column; /* Stack items vertically */
        justify-content: center; /* Center vertically */
        align-items: center; /* Center horizontally */
    }

        .under-construction div:nth-of-type(2) img {
            width: 40%;
        }

.icon-container {
    white-space: nowrap;
}

.icon {
    font-size: 24px;
    width: 25px;
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border-radius: 3px;
}

    .icon:hover {
        background-color: rgba(255, 255, 255, 0.2);
        transform: scale(1.1);
    }

/* Icon color definitions optimized for blue toolbar background (#0072ce) */

.save {
    color: #FFFFFF; /* white for save icon - good contrast */
    background-color: rgba(255, 255, 255, 0.1); /* subtle white background */
}

    .save:hover {
        color: #4CAF50; /* green on hover */
        background-color: rgba(76, 175, 80, 0.2); /* light green background on hover */
    }

.save-as {
    color: #FFD700; /* gold color for better contrast than previous yellow */
    background-color: rgba(255, 215, 0, 0.15); /* subtle gold background */
}

    .save-as:hover {
        color: #FFC107; /* amber on hover */
        background-color: rgba(255, 193, 7, 0.25); /* amber background on hover */
    }

.open {
    color: #FF9800; /* orange for folder open - good contrast */
    background-color: rgba(255, 152, 0, 0.15); /* subtle orange background */
}

    .open:hover {
        color: #F57C00; /* darker orange on hover */
        background-color: rgba(255, 152, 0, 0.25); /* more prominent orange background */
    }

.excel {
    color: #4CAF50; /* green for Excel theme */
    background-color: rgba(76, 175, 80, 0.15); /* subtle green background */
}

    .excel:hover {
        color: #388E3C; /* darker green on hover */
        background-color: rgba(76, 175, 80, 0.25); /* more prominent green background */
    }

.update-page {
    color: #E3F2FD; /* very light blue - improved from previous */
    background-color: rgba(227, 242, 253, 0.15); /* subtle light blue background */
}

    .update-page:hover {
        color: #BBDEFB; /* medium light blue on hover */
        background-color: rgba(187, 222, 251, 0.25); /* more prominent blue background */
    }

.update-all {
    color: #90CAF9; /* medium blue for better contrast */
    background-color: rgba(144, 202, 249, 0.15); /* subtle blue background */
}

    .update-all:hover {
        color: #64B5F6; /* darker blue on hover */
        background-color: rgba(144, 202, 249, 0.25); /* more prominent blue background */
    }

.update-email {
    color: #FFE082; /* light amber for email theme */
    background-color: rgba(255, 224, 130, 0.15); /* subtle amber background */
}

    .update-email:hover {
        color: #FFCC02; /* darker amber on hover */
        background-color: rgba(255, 204, 2, 0.25); /* more prominent amber background */
    }

.update-silent {
    color: #BDBDBD; /* medium gray for better contrast than light gray */
    background-color: rgba(189, 189, 189, 0.15); /* subtle gray background */
}

    .update-silent:hover {
        color: #9E9E9E; /* darker gray on hover */
        background-color: rgba(158, 158, 158, 0.25); /* more prominent gray background */
    }

.clear {
    color: #F44336; /* material red for clear action */
    background-color: rgba(244, 67, 54, 0.15); /* subtle red background */
}

    .clear:hover {
        color: #D32F2F; /* darker red on hover */
        background-color: rgba(244, 67, 54, 0.25); /* more prominent red background */
    }

.refresh-db {
    color: #E1BEE7; /* lavender - works well with blue background */
    background-color: rgba(225, 190, 231, 0.15); /* subtle lavender background */
}

    .refresh-db:hover {
        color: #CE93D8; /* darker lavender on hover */
        background-color: rgba(206, 147, 216, 0.25); /* more prominent lavender background */
    }

.enter-products {
    color: #FF9800; /* orange for product entry actions */
    background-color: rgba(255, 152, 0, 0.15); /* subtle orange background */
}

    .enter-products:hover {
        color: #F57C00; /* darker orange on hover */
        background-color: rgba(255, 152, 0, 0.25); /* more prominent orange background */
    }

.preview {
    color: #FFE082;
    background-color: rgba(255, 224, 130, 0.15);
}

    .preview:hover {
        color: #FFCC02;
        background-color: rgba(255, 204, 2, 0.25);
    }

.generate {
    color: #FFE082;
    background-color: rgba(255, 224, 130, 0.15);
}

    .generate:hover {
        color: #FFCC02;
        background-color: rgba(255, 204, 2, 0.25);
    }

/* #region Undo/Redo Icons - Styling for undo/redo functionality in main toolbar */
.undo {
    color: #FFB74D; /* light orange for undo action */
    background-color: rgba(255, 183, 77, 0.15); /* subtle orange background */
}

    .undo:hover {
        color: #FF9800; /* medium orange on hover */
        background-color: rgba(255, 152, 0, 0.25); /* more prominent orange background */
    }

    .undo.disabled {
        filter: invert(100%) grayscale(100%) brightness(50%);
        pointer-events: none;
        opacity: 0.5;
    }

.redo {
    color: #81C784; /* light green for redo action */
    background-color: rgba(129, 199, 132, 0.15); /* subtle green background */
}

    .redo:hover {
        color: #4CAF50; /* medium green on hover */
        background-color: rgba(76, 175, 80, 0.25); /* more prominent green background */
    }

    .redo.disabled {
        filter: invert(100%) grayscale(100%) brightness(50%);
        pointer-events: none;
        opacity: 0.5;
    }

/* Undo/Redo dropdown styling */
.main-undo-redo-dropdown {
    position: absolute;
    background: #ffffff;
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    min-width: 300px;
    max-width: 400px;
    display: none;
}

    /* Headbox tooltip (reuses undo/redo dropdown header styling, without the list) */
    .main-undo-redo-dropdown.mibt-icon-headbox {
        min-width: unset;
        max-width: 320px;
        width: max-content;
        pointer-events: auto;
        cursor: pointer;
    }

        .main-undo-redo-dropdown.mibt-icon-headbox .dropdown-header {
            border-bottom: none;
            white-space: normal;
        }

    .main-undo-redo-dropdown .dropdown-header {
        background-color: #B3D9FF;
        border-bottom: 1px solid #ddd;
        padding: 8px 12px;
        font-weight: bold;
        font-size: 14px;
        color: #333;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
    }

    .main-undo-redo-dropdown .dropdown-content {
        max-height: 300px;
        overflow-y: auto;
        font-size: 10pt;
        padding: 0;
        background-color: #E0EFFF;
    }

    .main-undo-redo-dropdown .dropdown-item {
        display: block;
        width: 100%;
        text-align: left;
        padding: 8px 12px;
        border: none;
        background-color: #E0EFFF;
        cursor: pointer;
        border-bottom: 1px solid #f0f0f0;
        border-radius: 4px;  /* 4px border-radius for consistency */
        transition: background-color 0.2s ease;
    }

        .main-undo-redo-dropdown .dropdown-item:hover {
            background-color: #D1E7FF;
        }

        .main-undo-redo-dropdown .dropdown-item.selected,
        .main-undo-redo-dropdown .dropdown-item.selected:hover {
            background-color: #e3f2fd;
            box-shadow: inset 4px 0 0 #0072ce;
        }

        /* Open Saved dropdown: selected item highlight */
        .virtual-grid-select-save-as-dropdown .dropdown-item.selected,
        .virtual-grid-select-save-as-dropdown .dropdown-item.selected:hover {
            background-color: #D1E7FF;
        }

        .main-undo-redo-dropdown .dropdown-item:last-child {
            border-bottom: none;
        }

        .main-undo-redo-dropdown .dropdown-item.disabled {
            color: #999;
            cursor: default;
            font-style: italic;
        }

            .main-undo-redo-dropdown .dropdown-item.disabled:hover {
                background-color: transparent;
            }

        .main-undo-redo-dropdown .dropdown-item div:first-child {
            font-weight: bold;
            margin-bottom: 2px;
            color: #333;
        }

        .main-undo-redo-dropdown .dropdown-item div:last-child {
            font-size: 0.9em;
            color: #666;
        }

    /* Keep dropdown open when hovering */
    .main-undo-redo-dropdown:hover {
        display: block !important;
    }
/* #endregion */

/* Highlight for updated (yellow) rows in VirtualGrid */
.virtual-grid-table-row-updated {
    background-color: #fff9c4 !important; /* Material yellow 100 */
    transition: background-color 0.3s;
}

    /* Optionally, highlight updated cells as well */
    .virtual-grid-table-row-updated td {
        background-color: #fff9c4 !important;
    }

.auto-select-wrapper {
    position: relative;
    display: inline-block;
    font-family: sans-serif;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding-right: 28px; /* reserve full width for new chevron container */
    box-sizing: border-box;
    width: fit-content;
}

    .auto-select-wrapper input {
        border: 1px solid lightgrey;
        outline: none;
        padding: 8px;
        font-size: 16px;
        border-radius: 4px;
        width: 100%;
        box-sizing: border-box;
        color: #000; /* force black text */
        font-weight: normal; /* semibold */
    }

.chevron {
    position: absolute;
    top: 0; /* full height */
    right: 0; /* flush to wrapper edge */
    bottom: 0; /* stretch */
    transform: none; /* no vertical translate needed */
    display: flex; /* center icon */
    align-items: center;
    justify-content: center;
    width: 28px; /* matches padding-right */
    cursor: pointer;
    font-size: 24px;
    color: #555;
    user-select: none;
    line-height: 1; /* keep icon tight */
}

/* Optional visual separator */
.auto-select-wrapper .chevron {
    border-left: 1px solid #ccc;
}

.auto-select-wrapper input[readonly],
.auto-select-wrapper input:read-only {
    background-color: #f5f5f5; /* lighter grey for readonly to match disabled */
    cursor: default;
}

    .auto-select-wrapper input[readonly] ~ .chevron,
    .auto-select-wrapper input:read-only ~ .chevron {
        background-color: #f5f5f5; /* lighter grey chevron for readonly */
        color: #888;
        cursor: not-allowed;
        pointer-events: none;
    }

    .auto-select-wrapper input:disabled ~ .chevron,
    .auto-select-wrapper input[readonly] ~ .chevron,
    .auto-select-wrapper input:read-only ~ .chevron {
        background-color: #f5f5f5;
        color: #888;
        cursor: not-allowed;
        pointer-events: none;
    }

    /* Never show dropdown if host input is disabled/readonly */
    .auto-select-wrapper input:disabled ~ .auto-select-dropdown,
    .auto-select-wrapper input[readonly] ~ .auto-select-dropdown,
    .auto-select-wrapper input:read-only ~ .auto-select-dropdown {
        display: none !important;
    }

.auto-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #ffffff !important; /* reinforce solid background */
    border: 1px solid #ccc !important; /* reinforce border */
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    padding-left: 8px;
    z-index: 1000;
    isolation: isolate; /* create stacking context to prevent bleed */
    color: #000; /* force black text */
    font-weight: normal; /* semibold */
}

.auto-select-dropdown {
    background: #fff;
    border: 1px solid #ccc;
}

    .auto-select-dropdown ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .auto-select-dropdown li {
        padding: 6px 8px;
        cursor: pointer;
        border: none;
        background: transparent;
        white-space: nowrap;
    }

        /* Hover state - light grey background */
        .auto-select-dropdown li:hover {
            background-color: #d3d3d3;
            border: none;
            outline: none;
        }

        /* Selected state (keyboard navigation) - light grey background */
        .auto-select-dropdown li.selected {
            background-color: #d3d3d3;
            border: none;
            outline: none;
        }

        /* Focused state - light grey background */
        .auto-select-dropdown li:focus {
            background-color: #d3d3d3;
            border: none;
            outline: none;
        }


/***********************************************************
    Sidebar
*/

:root {
    --cell-h: 48px;
    --icon: 32px;
    --pad-x: 6px;
    --pad-gap: 4px;
    --popover-bg: #fff;
    --popover-border: #d0d0d0;
    --shadow: 0 8px 24px rgba(0,0,0,.18);
    --header-h: 40px;
    --header-bg1: #f7f7f7;
    --header-bg2: #ececec;
    --sb-expanded: 208px;
    --sb-collapsed: 52px;
    /* Current sidebar width (updated by `initSidebar` on toggle) */
    --sb-current: var(--sb-collapsed);
}

/* -------------------------------------------------------------------------
   Full-width layout (100vw minus sidebar width)
   These pages render the sidebar + content inside a 2-column <table>.
   Make the table span the viewport and allocate the remaining width to the
   content cell based on the sidebar's current open/closed width.
   ------------------------------------------------------------------------- */

/*
   Inline sidebar is rendered in a 2-column table.
   Let the sidebar column size to its content (collapsed: icons only, expanded: icons+text)
   and let the content column take the remaining space.
*/
#master-grid > table,
#build-grid > table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}

    #master-grid > table td:first-child,
    #build-grid > table td:first-child {
        /* keep sidebar as tight as possible */
        width: 1%;
        white-space: nowrap;
    }

    #master-grid > table td:last-child,
    #build-grid > table td:last-child {
        width: auto;
    }

/* Ensure the content containers fill their cell */
#master-grid-content,
#build-grid-content {
    width: 100%;
    box-sizing: border-box;
}

/* Ensure these containers are positioning contexts (no markup edit required) */
#master-grid, #classification-grid, #supplemental-grid {
    position: relative;
}

/* =========================
   ABSOLUTE MODE (overlay inside target container)
   ========================= */
.sb-abs {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--sb-expanded);
    height: 100%;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    box-sizing: border-box;
    overflow: visible; /* popovers can overflow */
    z-index: 10;
    padding-top: var(--header-h);
}

/* =========================
   INLINE MODE (sits inside a <td>, no absolute, no container padding)
   ========================= */
.sb-inline {
    position: static; /* not absolute */
    display: inline-block; /* sits inline in the <td> */
    vertical-align: top;
    width: var(--sb-expanded); /* expanded width */
    background: #fff;
    border-right: 1px solid #e0e0e0;
    box-sizing: border-box;
    padding-top: var(--header-h);
}

    /* Compact width for INLINE mode */
    .sb-inline.compact {
        width: var(--sb-collapsed);
    }

/* Shared header strip (works for both modes) */
.sb-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: linear-gradient(180deg, var(--header-bg1) 0%, var(--header-bg2) 100%);
}

/* For INLINE mode, keep header visible on scroll / within cell */
.sb-inline .sb-header {
    position: sticky;
    top: 0;
    height: 1px;
}

/* Chevron toggle (top-left) */
.sb-toggle {
    position: absolute;
    top: 4px;
    left: 0;
    width: 32px;
    height: 32px;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
}

    .sb-toggle:focus-visible {
        outline: 2px solid #0078d4;
        outline-offset: 2px;
    }

/* (If you’re using <img class="sb-chevron left/right"> inside the button) */
.sb-chevron {
    display: none;
}
/* Show left chevron when NOT compact */
.sb-abs:not(.compact) .sb-chevron.left,
.sb-inline:not(.compact) .sb-chevron.left {
    display: block;
}
/* Show right chevron when compact */
.sb-abs.compact .sb-chevron.right,
.sb-inline.compact .sb-chevron.right {
    display: block;
}

/* =========================
   Table & rows (no flex)
   ========================= */
.sb-table {
    width: max-content;
    border-collapse: collapse;
    border-spacing: 0;
}

/* Expanded mode: make rows span the full sidebar width so hover fills the entire row */
.sb-abs:not(.compact) .sb-table,
.sb-inline:not(.compact) .sb-table {
    width: 100%;
}

    .sb-table tr {
        height: var(--cell-h);
    }

    .sb-table td {
        vertical-align: middle;
    }

.icon-cell {
    padding: 0;
    line-height: 0;
}

.label-cell {
    padding: 0 var(--pad-gap) 0 var(--pad-x);
    white-space: nowrap;
}

.sb-table tbody tr:hover {
    background: #ffffff;
}

/* Expanded mode: full-width row hover */
.sb-abs:not(.compact) .sb-table tbody tr:hover,
.sb-inline:not(.compact) .sb-table tbody tr:hover {
    background-color: #E0EFFF;
}

/* Group rows (Save/Execute): absolutely no hover effects on TR or TD */
/*.sb-table tbody tr.group-row:hover,
.sb-table tbody tr.group-row:hover > td {
    background: transparent !important;
    background-color: transparent !important;
    color: inherit !important;
    font: inherit !important;
    border: 0 !important;
    outline: none !important;
}*/

/* Simple row buttons */
.row-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: inherit;
    position: relative;
    overflow: visible;
}

/* Compact-mode tooltips for single-action sidebar items (avoid the browser `title` tooltip) */
.sb-abs.compact .row-action[data-tooltip]::after,
.sb-inline.compact .row-action[data-tooltip]::after,
.sb-abs.compact .sb-drop-zone-paste[data-tooltip]::after,
.sb-inline.compact .sb-drop-zone-paste[data-tooltip]::after,
.sb-abs.compact .virtual-grid-drop-zone-paste[data-tooltip]::after,
.sb-inline.compact .virtual-grid-drop-zone-paste[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 3px);
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    height: 30px;
    box-sizing: border-box;
    white-space: nowrap;
    background-color: #E0EFFF;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    padding: 6px 10px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 10pt;
    font-weight: bold;
    color: #333;
    opacity: 0;
    /* Tooltips should not steal hover/hit-testing from the grid when they render over it */
    pointer-events: none;
    cursor: default;
    z-index: 1100;
}

.sb-abs.compact .row-action[data-tooltip]:hover::after,
.sb-inline.compact .row-action[data-tooltip]:hover::after,
.sb-abs.compact .sb-drop-zone-paste[data-tooltip]:hover::after,
.sb-inline.compact .sb-drop-zone-paste[data-tooltip]:hover::after,
.sb-abs.compact .virtual-grid-drop-zone-paste[data-tooltip]:hover::after,
.sb-inline.compact .virtual-grid-drop-zone-paste[data-tooltip]:hover::after {
    opacity: 1;
}

/* Contenteditable upload zone can hold focus/caret; show tooltip on focus as well as hover */
.sb-abs.compact .sb-drop-zone-paste[data-tooltip]:focus::after,
.sb-inline.compact .sb-drop-zone-paste[data-tooltip]:focus::after,
.sb-abs.compact .sb-drop-zone-paste[data-tooltip]:focus-within::after,
.sb-inline.compact .sb-drop-zone-paste[data-tooltip]:focus-within::after,
.sb-abs.compact .virtual-grid-drop-zone-paste[data-tooltip]:focus::after,
.sb-inline.compact .virtual-grid-drop-zone-paste[data-tooltip]:focus::after,
.sb-abs.compact .virtual-grid-drop-zone-paste[data-tooltip]:focus-within::after,
.sb-inline.compact .virtual-grid-drop-zone-paste[data-tooltip]:focus-within::after {
    opacity: 1;
}

/* Ensure the drop/paste zone can anchor its tooltip */
.sb-abs .sb-drop-zone-paste,
.sb-inline .sb-drop-zone-paste,
.sb-abs .virtual-grid-drop-zone-paste,
.sb-inline .virtual-grid-drop-zone-paste {
    position: relative;
}

/* Expanded sidebar: make single-action row labels match the Save/Delete/Execute option styling */
.sb-abs:not(.compact) .row-action span,
.sb-inline:not(.compact) .row-action span,
.sb-abs:not(.compact) .sb-drop-zone-paste span,
.sb-inline:not(.compact) .sb-drop-zone-paste span {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 10pt;
    font-weight: bold;
    font-style: normal;
    color: #333;
}

    .row-action:focus-visible {
        outline: 2px solid #0078d4;
        border-radius: 6px;
        outline-offset: 2px;
    }

    .row-action img {
        width: var(--icon);
        height: var(--icon);
        display: block;
    }

/* Sidebar-hosted VirtualGrid upload drop zone (reuse VirtualGrid classes, but override toolbar positioning) */
.sb-abs .sb-drop-zone,
.sb-inline .sb-drop-zone {
    position: static;
    left: auto;
    display: inline-block;
    padding-right: 0;
    gap: 0;
}

    .sb-abs .sb-drop-zone > *,
    .sb-inline .sb-drop-zone > * {
        border: 0;
        padding: 0;
        font-weight: inherit;
        border-radius: 0;
        transition: none;
    }

.sb-drop-zone-paste {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    outline: none;
}

    /* Ensure right-click targets the editable paste zone (not the image) so the browser enables Paste */
    .sb-drop-zone-paste img {
        pointer-events: none;
    }

    .sb-drop-zone-paste.is-dragover {
        outline: 2px dashed #0078d4;
        outline-offset: 2px;
        border-radius: 6px;
        background-color: rgba(0, 120, 212, 0.08);
    }

    .sb-drop-zone-paste:focus-visible {
        outline: 2px solid #0078d4;
        outline-offset: 2px;
        border-radius: 6px;
    }

/* Group rows (compact mode popovers) */
.group-row-hover {
    display: inline-block;
    position: relative;
}

.main-icon {
    width: var(--icon);
    height: var(--icon);
    display: inline-block;
    border-radius: 4px;
    outline: none;
}

    .main-icon:focus-visible {
        outline: 2px solid #0078d4;
        outline-offset: 2px;
    }

/* Popover (match undo/redo dropdown HEADER styling) */
.popover {
    position: absolute;
    top: 0;
    left: calc(100% + 4px);  /* Align with undo/redo dropdowns (moved 4px closer) */
    min-width: 300px;  /* Match undo/redo dropdown min-width */
    max-width: 400px;  /* Match undo/redo dropdown max-width */
    background: #f8f9fa !important;  /* Match undo/redo dropdown HEADER color */
    background-color: #f8f9fa !important;
    border: 1px solid #ddd;  /* Match undo/redo dropdown border */
    border-radius: 4px;  /* Match undo/redo dropdown border-radius */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);  /* Match undo/redo dropdown shadow */
    padding: 0;  /* Match undo/redo dropdown (no padding on container) */
    display: none;
    opacity: 0;
    transition: none !important;  /* Disable all transitions */
    transform: none !important;  /* Disable all transforms */
    z-index: 1001;  /* Match undo/redo dropdown z-index */
}

    /* Popover hover - lock everything down */
/*    .popover:hover {
        background: #f8f9fa !important;
        background-color: #f8f9fa !important;
        transform: none !important;
        filter: none !important;
    }*/

    .popover.open {
        display: block;
        opacity: 1;
    }

.options {
    display: grid;
    padding: 0 !important;  /* Match undo/redo dropdown content (no padding) */
    margin: 0 !important;
    background: transparent !important;
}

    /* Lock down options container on hover */
/*    .options:hover {
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        transform: none !important;
    }*/

.opt-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 12px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid #f0f0f0;  /* Match undo/redo dropdown separator */
    padding: 8px 12px;  /* Match undo/redo dropdown padding */
    cursor: pointer;
    border-radius: 4px;  /* 4px border-radius for consistency */
    text-align: left;
    color: #333;  /* Match undo/redo dropdown color */
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;  /* Match body font */
    font-size: 10pt;  /* Match undo/redo dropdown font size */
    font-weight: normal;  /* Match undo/redo dropdown (not bold) */
    font-style: normal;
    width: 100%;
}

.opt-item:hover,
.opt-item:focus-visible {
    background-color: #E0EFFF;
}

    /* Last item should not have bottom border */
    .opt-item:last-child {
        border-bottom: none;
    }

/* Popover options: absolutely no hover/active/focus visual effects - MOST AGGRESSIVE */
/*.popover .opt-item,
.popover .opt-item:hover,
.popover .opt-item:active,
.popover .opt-item:focus,
.popover .opt-item:focus-visible,
.popover button.opt-item,
.popover button.opt-item:hover,
.popover button.opt-item:active,
.popover button.opt-item:focus,
button.opt-item:hover,
button.opt-item:active,
button.opt-item:focus,
.options button.opt-item:hover,
.options button.opt-item:active,
.popover .options button.opt-item:hover,
.popover .options button.opt-item:active {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    color: #333 !important;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    font-size: 10pt !important;
    font-weight: normal !important;
    font-style: normal !important;
    text-decoration: none !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-top: 0 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    outline: none !important;
    box-shadow: none !important;
    filter: none !important;
    transform: none !important;
    transition: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}*/

/* Force last child to have no bottom border */
.popover .opt-item:last-child,
.popover button.opt-item:last-child,
.options button.opt-item:last-child {
    border-bottom: none !important;
}

    .opt-item img {
        width: var(--icon);
        height: var(--icon);
        display: block;
    }

    .opt-item .opt-label {
        white-space: nowrap;
        font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;  /* Match body font */
        font-size: 10pt;  /* Match undo/redo dropdown font size */
        font-weight: bold;  /* Match undo/redo dropdown (bold operation names) */
        font-style: normal;
        color: #333;  /* Match undo/redo dropdown color */
    }

/* =========================
   COMPACT (icons-only) — apply to BOTH modes
   ========================= */

/* Hide inline row labels in compact */
.sb-abs.compact .row-action span,
.sb-inline.compact .row-action span {
    display: none;
}

/* Hide upload drop-zone label in compact */
.sb-abs.compact .sb-drop-zone-paste span,
.sb-inline.compact .sb-drop-zone-paste span {
    display: none;
}

/* Hide grouped label column in compact */
.sb-abs.compact .label-cell,
.sb-inline.compact .label-cell {
    display: none;
}

/* Tighten icons in compact */
.sb-abs.compact .row-action,
.sb-inline.compact .row-action {
    gap: 0;
}

/* Compact popover as icon tiles */
.sb-abs.compact .popover,
.sb-inline.compact .popover {
    min-width: auto;
    max-width: none;
    padding: 4px;
}

.sb-abs.compact .options,
.sb-inline.compact .options {
    display: grid;
    grid-auto-flow: row;
    grid-auto-rows: max-content;
    gap: 3px;
    align-items: center;
    justify-items: stretch;
}

.sb-abs.compact .opt-item,
.sb-inline.compact .opt-item {
    display: flex;
    align-items: center;
    justify-content: left;
    padding: 3px;
    width: 100%;
}

/* =========================
   EXPANDED (flat list; hide group rows) — BOTH modes
   ========================= */
.sb-abs:not(.compact) tr.group-row,
.sb-inline:not(.compact) tr.group-row {
    display: none;
}

.expanded-panel {
    display: none;
    margin-top: 12px;
    width: 100%;
}

.sb-abs:not(.compact) .expanded-panel,
.sb-inline:not(.compact) .expanded-panel {
    display: block;
}

.expanded-panel .section-title {
    font-weight: 600;
    font-size: 14px;
    color: #444;
    margin: 12px 0 2px;
}

.expanded-panel .section-rule {
    border: 0;
    border-top: 1px solid #e6e6e6;
    margin: 0 0 8px 0;
}

/* =========================
   Container padding toggle (used ONLY in absolute mode when script decides)
   ========================= */
.sb-pad-expanded {
    padding-left: var(--sb-expanded);
}

.sb-pad-collapsed {
    padding-left: var(--sb-collapsed);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .popover {
        transition: none;
    }
}

/* Sidebar rows: don't change background while hovering inside a popover */
/*.sb-table tbody tr:has(.popover:hover) {
    background: transparent !important;
}*/

/* AFTER the aggressive rules: explicit hovered state for group-row popovers */
.opt-item:hover {
    background-color: #E0EFFF !important;
}

/* Sidebar single-action rows: match hover background to the dropdown items */
.row-action:hover,
.row-action:focus-visible {
    background-color: #E0EFFF;
    border-radius: 6px;
}

/* When expanded, the entire table row is highlighted; avoid a smaller nested highlight on the button itself */
.sb-abs:not(.compact) .row-action:hover,
.sb-inline:not(.compact) .row-action:hover {
    background-color: transparent;
}

/* Upload row behaves like a button */
.sb-drop-zone-paste:hover,
.sb-drop-zone-paste:focus-visible {
    background-color: #E0EFFF;
    border-radius: 6px;
}

/* Expanded mode uses full-row hover for the upload row as well */
.sb-abs:not(.compact) .sb-drop-zone-paste:hover,
.sb-inline:not(.compact) .sb-drop-zone-paste:hover {
    background-color: transparent;
}

/* Compact-mode group icons (Save/Delete/Execute right-arrow icons) */
.group-row-hover:hover .main-icon,
.group-row-hover:focus-within .main-icon {
    background-color: #E0EFFF;
}


/* Base look */
.sb-drop-zone {
    border: 2px dashed transparent; /* start invisible */
    border-radius: 6px;
    transition: border-color 120ms ease, background-color 120ms ease;
}

    /* When the mouse is dragging over (files) */
    .sb-drop-zone.is-dragover {
        border-color: #4caf50; /* green outline */
        background-color: rgba(76,175,80,0.08);
    }

    /* (Optional) also show on simple hover when not dragging */
    .sb-drop-zone:hover {
        border-color: #9e9e9e;
    }
