/** General Styling **/
:root {
    font-size: var(--ig-font-size);
    /* --ig-font-size is controlled by user in Preference.js font_size_map */
    --bs-badge-font-size: 0.85em;
}

body {
    color: var(--ig-text-color);
    background: var(--ig-background);
}

#main-container {
    height: calc(var(--ig-vh, 1vh) * 100);
    width: 100%;
}

#main-row {
    height: 100%;
    flex-wrap: nowrap;
}

#main-col {
    height: 100%;
    /* Position is set to relative so that the sub-window can be positioned absolutely
    *  This also allows the sub-window to be pushed properly when the ignition ai window is open
    */
    position: relative;
    flex: 1 1 0%;
    min-width: 0;
}

.content-container {
    height: 100%;
    overflow: auto;
    flex: 1 1 auto;
}

/** Web Components **/
ig-main-window {
    /* Height is dynamically set inside the web component */
    background: var(--ig-background);
    display: flex;
    flex-direction: column;
    padding: 5px 5px 2px 5px;
}

ig-sub-window {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.18);
    backdrop-filter: blur(2px);
    padding: 5px 5px 2px 5px;
    z-index: 100;
}

ig-sub-window .sub-window-content {
    width: 80%;
    height: 80%;
    background: var(--ig-background);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* This is half the width of the navigation menu */
    margin-left: -6.25rem;
    padding: 0.5rem 0.85rem 0.85rem 0.85rem;
    border: 1px solid rgba(85, 85, 85, 0.75);
    border-radius: 0.85rem;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.18);
    overflow: hidden;
    transition: inset 0.2s ease, width 0.2s ease, height 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

ig-sub-window .sub-window-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

ig-sub-window .sub-window-chrome {
    min-height: 2.75rem;
    padding: 0.25rem 0 0.6rem 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.18);
}

ig-sub-window .sub-window-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding-top: 0.4rem;
}

ig-sub-window .sub-window-view-mount-point-holder,
ig-sub-window .sub-window-tab-content-holder,
ig-sub-window .sub-window-tab-bar-holder {
    min-width: 0;
    min-height: 0;
}

ig-sub-window .sub-window-control-holder {
    flex-shrink: 0;
    gap: 0.3rem;
    font-size: 0.9rem;
}

.sub-window-tab-content-holder {
    flex: 1 1 auto;
    height: auto;
    overflow: auto;
}

ig-sub-window .content-container {
    overflow: hidden;
}

ig-sub-window .sub-window-control-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    color: var(--ig-text-color);
    opacity: 0.78;
    transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

ig-sub-window .sub-window-control-button:hover,
ig-sub-window .sub-window-control-button:focus-visible {
    background: rgba(127, 127, 127, 0.12);
    opacity: 1;
    outline: none;
}

ig-sub-window [data-ig-window-action="cancel"]:hover,
ig-sub-window [data-ig-window-action="cancel"]:focus-visible {
    background: rgba(220, 53, 69, 0.12);
    color: var(--bs-danger);
}

ig-sub-window[data-ig-window-size="maximized"] .sub-window-content {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: auto;
    margin-left: 0;
    transform: none;
    padding: 5px 5px 2px 5px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

ig-sub-window[data-ig-window-size="maximized"] {
    top: var(--ig-main-window-top, 0px);
    height: var(--ig-main-window-height, 100%);
    justify-content: flex-start;
    align-items: stretch;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
}

ig-sub-window[data-ig-window-size="maximized"] .sub-window-shell {
    background: var(--ig-background);
    border: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.175));
    border-radius: 0.375rem;
    box-shadow: var(--bs-box-shadow-sm, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075));
    overflow: hidden;
}

ig-sub-window[data-ig-window-size="maximized"] .sub-window-chrome {
    padding: 0.5rem 0.75rem;
    background: var(--ig-background);
}

ig-sub-window[data-ig-window-size="maximized"] .sub-window-main {
    padding: 0 0.75rem 0.75rem 0.75rem;
}

#minimized-window-holder {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.tab-content-container {
    overflow: auto;
}

#main-row ig-navigation-menu {
    width: 15.5rem;
    height: 100%;
    overflow-y: auto;
}

ig-navigation-menu .nav-link {
    color: var(--ig-nav-item-color);
    text-decoration: none;
}

#main-row ig-navigation-menu.mobile-active-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: var(--ig-background);
}

/* PANEL */
ig-search-overlay .search-overlay-panel {
    position: fixed;
    top: 55px;
    /* Below nav icon */
    right: 20px;
    /* Align with right nav */
    width: 350px;
    background: white;
    border-radius: .5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
    padding: .75rem;
    z-index: 5000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all .18s ease;
}

ig-search-overlay .search-overlay-panel.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

ig-search-overlay .search-overlay-panel.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

/* SEARCH BAR */
ig-search-overlay .search-bar {
    display: flex;
    gap: .35rem;
    margin-bottom: .5rem;
}

ig-search-overlay .search-bar input {
    border-radius: .4rem;
    font-size: .85rem;
}

ig-search-overlay .search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .25rem .6rem;
    font-size: .8rem;
}

/* RESULTS */
ig-search-overlay .search-results {
    max-height: 260px;
    overflow-y: auto;
}

ig-search-overlay .no-results {
    padding: .5rem;
    color: #6c757d;
    font-size: .85rem;
}

/* Result item */
ig-search-overlay .nav-search-result-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .5rem;
    border-radius: .35rem;
    cursor: pointer;
    transition: background-color .15s ease;
}

ig-search-overlay .nav-search-result-item:hover {
    background-color: #f8f9fa;
}

/* Badge */
ig-search-overlay .nav-search-result-badge {
    font-size: .65rem;
    text-transform: uppercase;
    background-color: #0d6efd;
    color: white;
    padding: .2rem .45rem;
    border-radius: .25rem;
    font-weight: 600;
    letter-spacing: .5px;
}

ig-record-list-table {
    width: 100%;
    height: 100%;
    overflow: auto;
}

ig-color-selector .color-selector-quick-display {
    background-color: #000000;
    height: 100%;
    /** rounded border **/
    border: 1px solid #000;
    border-radius: 5px;
}

ig-color-selector .hue-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 15px;
    background: linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red);
    outline: none;
    opacity: 0.9;
    margin-top: 5px;
    position: relative;
    z-index: 1;
}

ig-color-selector .hue-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 15px;
    cursor: pointer;
    background: transparent;
    border: none;
}

ig-color-selector .hue-slider::-moz-range-track {
    width: 100%;
    height: 15px;
    cursor: pointer;
    background: transparent;
    border: none;
}

ig-color-selector .hue-slider::-ms-track {
    width: 100%;
    height: 15px;
    cursor: pointer;
    background: transparent;
    border: none;
    color: transparent;
}

ig-color-selector .hue-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 25px;
    height: 25px;
    background: #fff;
    border: 2px solid #000;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    margin-top: -5px;
    /* Center the thumb */
    z-index: 2;
}

ig-color-selector .hue-slider::-moz-range-thumb {
    width: 25px;
    height: 25px;
    background: #fff;
    border: 2px solid #000;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    margin-top: -5px;
    /* Center the thumb */
    z-index: 2;
}

ig-color-selector .hue-slider::-ms-thumb {
    width: 25px;
    height: 25px;
    background: #fff;
    border: 2px solid #000;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    margin-top: -5px;
    /* Center the thumb */
    z-index: 2;
}

ig-color-selector .hue-slider::-ms-fill-lower {
    background: transparent;
}

ig-color-selector .hue-slider::-ms-fill-upper {
    background: transparent;
}

.color-selector-quick-display-wrapper {
    position: relative;
}

.color-selector-quick-display {
    position: relative;
    z-index: 1;
    /* Ensure input is above the span initially */
}

.color-selector-quick-display+span {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translate(0%, -50%);
    color: white;
    text-shadow:
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 0 0 #000,
        -1px 0 0 #000,
        0 1px 0 #000,
        0 -1px 0 #000;
    /* Black outline */
    z-index: 2;
    /* Ensure span is above the input */
    pointer-events: none;
    /* Ensure span does not block input interactions */
}

.list-box-holder,
.date-selector-holder,
.time-selector-holder {
    z-index: 50000;
}

.list-box-holder .table-responsive {
    overflow-x: hidden;
}

.list-box-holder .list-box-value-cell {
    word-break: break-word;
    overflow-wrap: anywhere;
}

ig-visual-scripter .flow-node.overlap {
    outline: 2px dashed red;
}

ig-visual-scripter .edge-hint {
    position: absolute;
    z-index: 5;
    width: 24px;
    height: 24px;
    background: #d9534f;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border-radius: 50%;
    pointer-events: none;
    opacity: .85;
}

ig-visual-scripter .edge-hint.top {
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
}

ig-visual-scripter .edge-hint.right {
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

ig-visual-scripter .edge-hint.bottom {
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
}

ig-visual-scripter .edge-hint.left {
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
}

ig-visual-scripter .edge-hint.top::before {
    content: '↑';
}

ig-visual-scripter .edge-hint.right::before {
    content: '→';
}

ig-visual-scripter .edge-hint.bottom::before {
    content: '↓';
}

ig-visual-scripter .edge-hint.left::before {
    content: '←';
}

ig-visual-scripter #canvas_holder {
    overflow: hidden;
}

ig-textarea {
    padding-left: 0!important;
}

/** Calendar Date Selector **/
ig-calendar-table td[data-event-date]:hover {
    background: #f0f0f0;
}

ig-toast {
    position: fixed;
    z-index: 100000;
    right: 5%;
    /* This will be the final position after animation */
    top: 25px;
}

ig-toast .toast-notification {
    background-color: #559;
    text-align: center;
    color: white;
    padding: 1rem;
    margin-bottom: 1rem;
    animation: slide-in-right 0.5s ease-out forwards;
    position: relative;
    /* Make sure this is positioned relative to the toast-holder */
    right: 0%;
    /* Start position for the animation */
}

@keyframes slide-in-right {
    from {
        right: -10%;
        /* Start from the edge of the toast-holder */
        opacity: 0;
    }

    to {
        right: 0%;
        /* Move towards the final position, inside the toast-holder */
        opacity: 1;
    }
}


/** Calendar Styling **/
table .calendar-selected-cell {
    background: #badce3;
}

/** Generic Helper Classes **/
.hide-element {
    display: none !important;
}

.cursor-pointer {
    cursor: pointer;
}

.user-selection-none {
    user-select: none;
    -webkit-user-select: none;
}

.no-text-selection {
    user-select: none;
    -webkit-user-select: none;
}

/** Bootstrap overrides **/

:root {
    --bs-body-font-size: var(--ig-font-size);
}

.badge {
    --bs-badge-font-size: 0.85em;
}

.btn {
    font-size: .925rem;
}

.dropdown-menu {
    font-size: .925rem;
}

.offcanvas.offcanvas-end {
    --bs-offcanvas-width: 450px;
}

/** Mobile layout tweaks **/
@media (max-width: 991.98px) {
    #main-container {
        width: 100%;
    }

    ig-sub-window .sub-window-content {
        width: 95%;
        height: 90%;
        margin-left: 0;
    }

    ig-search-overlay .search-overlay-panel {
        width: min(350px, calc(100vw - 2rem));
        right: 1rem;
    }

    #main-row ig-navigation-menu.mobile-active-menu {
        padding: 0.5rem 0.75rem;
    }

    #main-row ig-navigation-menu .row.text-nowrap {
        white-space: normal;
    }

    #main-row ig-navigation-menu .nav-link {
        white-space: normal;
        word-break: break-word;
    }
}

@media (max-width: 767.98px) {
    ig-sub-window {
        top: var(--ig-main-window-top, 0px);
        height: var(--ig-main-window-height, 100%);
        padding: 0;
        background: rgba(0, 0, 0, 0.35);
    }

    ig-sub-window .sub-window-content {
        top: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        left: 0.75rem;
        width: auto;
        height: auto;
        margin-left: 0;
        transform: none;
        border: 1px solid rgba(0, 0, 0, 0.2);
        border-radius: 0.75rem;
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    ig-sub-window[data-ig-window-size="maximized"] {
        top: var(--ig-main-window-top, 0px);
        height: var(--ig-main-window-height, 100%);
        padding: 0;
        background: transparent;
    }

    ig-sub-window[data-ig-window-size="maximized"] .sub-window-content {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        margin-left: 0;
        transform: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    ig-sub-window .sub-window-shell {
        height: auto;
        min-height: 100%;
    }

    ig-sub-window .content-container {
        height: auto;
        overflow: visible;
    }

    ig-sub-window .sub-window-tab-content-holder {
        height: auto;
    }

    ig-page-header .container-fluid > .d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    ig-page-header [data-ig-nav-group="left"],
    ig-page-header [data-ig-nav-group="center"],
    ig-page-header [data-ig-nav-group="right"] {
        flex-wrap: wrap;
    }

    ig-page-header [data-ig-nav-group="center"] {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    ig-page-header [data-ig-nav-group="right"] {
        margin-left: auto;
    }

    ig-page-header [data-ig-nav-group="left"] {
        margin-right: auto;
    }

    .ig-page-header-label--mobile-hidden {
        display: none;
    }

    ig-page-header .ig-page-header-link--profile .me-2 {
        margin-right: 0.25rem;
    }

    ig-page-header .nav-link {
        padding: 0.25rem 0.5rem;
    }

    ig-search-overlay .search-bar input {
        font-size: 16px;
    }

    .ig-record-table__controls {
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .ig-record-table__controls .btn-group {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.5rem;
    }

    .ig-record-table__controls .btn-group > .btn {
        margin-left: 0;
        border-radius: 0.375rem;
    }

    .ig-record-table__controls .js-selected-count,
    .ig-record-table__controls .js-edit-mode-hint {
        width: 100%;
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .list-box-holder .table-responsive {
        overflow-x: auto;
    }
}

.ig-edit-mode td.ig-cell-edited {
    background-color: #fff3cd;
    box-shadow: inset 0 0 0 1px #ffe69c;
}

.ig-record-table__viewport tbody > .ig-record-table__row {
    content-visibility: auto;
    contain-intrinsic-size: 44px;
}

/** Issue Tracker Conversation **/
ig-issue-tracker-conversation .issue-conversation-inline-link {
    color: var(--ig-accent);
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    opacity: 0.88;
    cursor: pointer;
    transition: border-color 0.15s ease, opacity 0.15s ease, color 0.15s ease;
}

ig-issue-tracker-conversation .issue-conversation-inline-link:visited {
    color: var(--ig-accent);
}

ig-issue-tracker-conversation .issue-conversation-inline-link:hover,
ig-issue-tracker-conversation .issue-conversation-inline-link:focus-visible {
    color: var(--ig-accent);
    text-decoration: none;
    border-bottom-color: currentColor;
    opacity: 1;
}

/** Wiki Editor **/
ig-wiki-editor .wiki-editor-shell {
    min-height: 12rem;
}

ig-wiki-editor .wiki-editor-add-type,
ig-wiki-editor .wiki-editor-block-type,
ig-wiki-editor .wiki-editor-style {
    width: auto;
    min-width: 9rem;
}

ig-wiki-editor .wiki-editor-block {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

ig-wiki-editor .wiki-editor-block-selected {
    border-color: var(--ig-accent) !important;
    box-shadow: 0 0 0 0.125rem rgba(var(--bs-primary-rgb), 0.12);
}

ig-wiki-editor .wiki-editor-text {
    min-height: 2.5rem;
    white-space: pre-wrap;
}

ig-wiki-editor .wiki-editor-text:empty::before {
    content: attr(data-placeholder);
    color: var(--bs-secondary-color);
}

ig-wiki-editor .wiki-editor-table-wrapper td {
    min-width: 8rem;
    height: 2.25rem;
    outline: none;
}

ig-wiki-editor .wiki-editor-table-wrapper td:focus,
ig-wiki-editor .wiki-editor-text:focus {
    border-color: var(--ig-accent);
    box-shadow: 0 0 0 0.125rem rgba(var(--bs-primary-rgb), 0.12);
}

ig-wiki-editor .wiki-editor-field-control .form-control,
ig-wiki-editor .wiki-editor-field-control .form-select {
    width: auto;
    min-width: 7rem;
}

ig-wiki-editor .wiki-editor-shell.is-invalid {
    border-color: var(--bs-form-invalid-border-color) !important;
}

ig-wiki-editor .wiki-editor-shell.is-invalid .invalid-feedback {
    display: block;
}

ig-wiki-editor.wiki-editor-disabled .wiki-editor-toolbar,
ig-wiki-editor.wiki-editor-disabled .wiki-editor-block-header,
ig-wiki-editor.wiki-editor-disabled .wiki-editor-table-controls {
    display: none !important;
}
