/* SPDX-License-Identifier: LicenseRef-Highcharts */

/**
 * @license Highcharts Grid Lite v2.3.0
 *
 * (c) 2009-2025 Highsoft AS
 *
 * A commercial license may be required depending on use.
 * See www.highcharts.com/license
 */

@import url("./grid-base-variables.css");
@import url("./grid-popup-variables.css");
@import url("./grid-menu-variables.css");
@import url("./grid-link-variables.css");
@import url("./grid-input-variables.css");
@import url("./grid-button-variables.css");
@import url("./grid-caption-variables.css");
@import url("./grid-description-variables.css");
@import url("./grid-pagination-variables.css");
@import url("./grid-table-variables.css");
@import url("./grid-theme-default.css");

/* Grid container */
.hcg-container {
    container-type: inline-size;
    container-name: hcg;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
    color-scheme: light dark;
    max-height: inherit;
}

.highcharts-light .hcg-container {
    color-scheme: light;
}

.highcharts-dark .hcg-container {
    color-scheme: dark;
}

.hcg-container * {
    box-sizing: border-box;
}

.hcg-container:has(.hcg-no-data) {
    justify-content: center;
    align-items: center;
}

/* ----------------------------------------------------------
  INPUT ELEMENTS
------------------------------------------------------------ */

.hcg-container .hcg-input {
    width: 100%;

    &:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

    &::placeholder {
        color: #767676;
    }

    &:focus-visible {
        outline: none;
        border-color: transparent;
    }

    &[type="checkbox"] {
        --ig-input-checkbox-size: 1.333em;

        appearance: none;
        width: var(--ig-input-checkbox-size);
        height: var(--ig-input-checkbox-size);
        cursor: pointer;
        position: relative;

        &:checked::before {
            content: "";
            position: absolute;
            inset: 0;
            margin: 0.05em;
            mask: center/contain no-repeat;
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
        }
    }

    &.hcg-icon {
        padding-left: 25px;
        appearance: none;
        background-repeat: no-repeat;
        background-position: left 10px center;
    }

    &.hcg-icon-search {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3e%3cpath d='M10.5 10.5L7.50005 7.5M8.5 5C8.5 6.933 6.933 8.5 5 8.5C3.067 8.5 1.5 6.933 1.5 5C1.5 3.067 3.067 1.5 5 1.5C6.933 1.5 8.5 3.067 8.5 5Z' stroke='%23767676' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
    }

    select& {
        appearance: none;
        background-image: url("data:image/svg+xml,%3csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M3.5 7.5L6 10L8.5 7.5M3.5 4.5L6 2L8.5 4.5' stroke='%23767676' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 5px center;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
}

/* ----------------------------------------------------------
  BUTTON ELEMENT
------------------------------------------------------------ */

.hcg-container .hcg-button {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    line-height: 1;
    gap: 2px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;

    svg {
        width: 1em;
        height: 1em;
        display: block;
    }

    span {
        display: inline-block;
        line-height: 1;
    }

    span:empty {
        display: none;
    }

    &.reverse {
        flex-direction: row-reverse;
    }

    &:focus-visible {
        outline: none;
        border-color: transparent;
    }

    &:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }
}

/* ----------------------------------------------------------
  TABLE ELEMENTS
------------------------------------------------------------ */

/* <table> */
.hcg-container .hcg-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    table-layout: fixed;
    flex: 1;

    &.hcg-scrollable-content {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    /* <thead> */
    &.hcg-virtualization thead {
        display: block;
    }

    thead th {
        position: relative;
    }

    &.hcg-scrollable-content tbody {
        height: 100%;
        overflow: auto;
        min-height: 0;
        flex: 1;
    }

    &.hcg-virtualization tbody {
        display: block;
        position: relative;
    }

    tbody tr {
        overflow: hidden;
        width: 100%;
    }

    tbody tr.hcg-mocked-row td,
    tbody tr td {
        position: relative;
        line-height: 1em;
        overflow: hidden;
    }

    tbody tr.hcg-mocked-row td {
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .hcg-last-header-cell-in-row,
    td:last-of-type {
        border-right: none;
    }

    tr:last-of-type td {
        border-bottom: none;
    }

    &.hcg-scrollable-content tbody tr {
        display: block;
    }

    &.hcg-virtualization tbody tr {
        position: absolute;
    }

    tbody.hcg-rows-content-nowrap td {
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    tbody td:focus {
        outline: none;
    }
}

/* ----------------------------------------------------------
  HEADER ELEMENTS
------------------------------------------------------------ */
.hcg-container thead th {
    .hcg-header-cell-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .hcg-header-cell-content {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .hcg-header-cell-container.hcg-no-width .hcg-header-cell-content {
        visibility: hidden;
        transition: none;
    }

    .hcg-header-cell-icons {
        display: flex;
        overflow: hidden;
        align-items: center;
        max-width: 0;
        opacity: 0;
        cursor: pointer;
        transition: max-width 0.3s ease, opacity 0.3s ease;
    }

    .hcg-header-cell-icons .hcg-button.hcg-button-selected::after {
        content: "";
        position: absolute;
        top: 2px;
        right: 2px;
        width: 0.3em;
        height: 0.3em;
        border-radius: 50%;
    }

    :is(:hover, :focus-visible) .hcg-header-cell-icons,
    .hcg-header-cell-icons:has(.hcg-button:focus-visible, .hcg-button.hcg-button-highlighted, .hcg-button.hcg-button-selected),
    .hcg-header-cell-container.hcg-no-width .hcg-header-cell-icons {
        max-width: 100px;
        opacity: 1;
    }

    .hcg-header-cell-container.hcg-no-width .hcg-header-cell-menu-icon {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin-left: 0;
    }

    .hcg-header-cell-icons .hcg-header-cell-menu-icon button {
        padding-inline: 3px;
    }

    .hcg-header-cell-icons > :first-child {
        margin-left: 5px;
    }

    .hcg-column-resizer {
        position: absolute;
        display: flex;
        align-items: center;
        justify-content: center;
        top: 0;
        width: 9px;
        right: -5px;
        height: 100%;
        user-select: none;
        z-index: 10;
        cursor: col-resize;
    }

    .hcg-column-resizer.hovered::after {
        content: "";
        height: 100%;
    }
}

/* ----------------------------------------------------------
  PAGINATION ELEMENTS
------------------------------------------------------------ */

.hcg-container .hcg-pagination {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;

    > * {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        align-items: center;
    }

    .hcg-pagination-info {
        justify-content: flex-start;
    }

    .hcg-pagination-controls {
        justify-content: center;
        gap: 2px;

        .hcg-pagination-pages {
            display: flex;
            flex-wrap: nowrap;
            gap: 2px;

            .hcg-button {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                min-width: 30px;
            }

            span {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                min-width: 20px;
            }
        }
    }

    .hcg-pagination-page-size {
        justify-content: flex-end;
        text-align: right;

        select.hcg-input {
            width: 60px;
            margin-left: 8px;
        }
    }

    /* .hcg-pagination-nav-dropdown {
        display: none;
        min-width: 200px;
    } */

    &.hcg-pagination-left,
    &.hcg-pagination-center,
    &.hcg-pagination-right {
        > * {
            flex: 0 0 auto;
            min-width: auto;
        }
    }

    &.hcg-pagination-left { justify-content: flex-start; }
    &.hcg-pagination-center { justify-content: center; }
    &.hcg-pagination-right { justify-content: flex-end; }

    &:not(:has(.hcg-pagination-info)) .hcg-pagination-controls {
        justify-content: flex-start;
    }

    &:not(:has(.hcg-pagination-page-size)) .hcg-pagination-controls {
        justify-content: flex-end;
    }
}

@container hcg (max-width: 800px) {
    .hcg-container .hcg-pagination {
        flex-direction: column;
        align-items: stretch;
        --ig-pagination-stacked-align: center;

        &.hcg-pagination-left { --ig-pagination-stacked-align: flex-start; }
        &.hcg-pagination-right { --ig-pagination-stacked-align: flex-end; }

        > * {
            flex: 0 0 auto;
            justify-content: var(--ig-pagination-stacked-align);
        }

        .hcg-pagination-info,
        .hcg-pagination-controls,
        .hcg-pagination-page-size {
            justify-content: var(--ig-pagination-stacked-align);
        }

        .hcg-pagination-page-size {
            text-align: center;
        }
        &.hcg-pagination-left .hcg-pagination-page-size { text-align: left; }
        &.hcg-pagination-right .hcg-pagination-page-size { text-align: right; }

        &:not(:has(.hcg-pagination-page-size)) .hcg-pagination-controls,
        &:not(:has(.hcg-pagination-info)) .hcg-pagination-controls {
            justify-content: var(--ig-pagination-stacked-align);
        }
    }
}

/* ----------------------------------------------------------
  CREDITS ELEMENT
------------------------------------------------------------ */

.hcg-credits,
.highcharts-light .hcg-credits {
    display: block;
    width: 114px;
    height: 20px;
    background-size: contain;
    background-repeat: no-repeat;
    background-image:
        image-set(
            /* stylelint-disable-next-line function-comma-newline-after */
            url("https://assets.highcharts.com/grid/logo_light.png") 1x,
            url("https://assets.highcharts.com/grid/logo_lightx2.png") 2x
        );
}

@media (prefers-color-scheme: dark) {
    .hcg-credits {
        background-image:
            image-set(
                /* stylelint-disable-next-line function-comma-newline-after */
                url("https://assets.highcharts.com/grid/logo_dark.png") 1x,
                url("https://assets.highcharts.com/grid/logo_darkx2.png") 2x
            );
    }
}

.highcharts-dark .hcg-credits {
    background-image:
        image-set(
            /* stylelint-disable-next-line function-comma-newline-after */
            url("https://assets.highcharts.com/grid/logo_dark.png") 1x,
            url("https://assets.highcharts.com/grid/logo_darkx2.png") 2x
        );
}

/* ----------------------------------------------------------
  POPUP ELEMENTS
------------------------------------------------------------ */
.hcg-container .hcg-popup {
    position: absolute;
    z-index: 1000;
    border-radius: 6px;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08), 0 7px 7px 0 rgba(0, 0, 0, 0.07), 0 17px 10px 0 rgba(0, 0, 0, 0.04), 0 30px 12px 0 rgba(0, 0, 0, 0.01);
    min-width: 200px;
    overflow: auto;
    border-width: 1px;
    border-style: solid;

    .hcg-popup-content {
        padding: 5px;
    }

    .hcg-menu-header {
        font-size: 0.75rem;
        padding: 3px;
        margin-bottom: 5px;
    }

    .hcg-menu-header-category {
        opacity: 0.5;
        user-select: none;
    }
}

/* ----------------------------------------------------------
  MENU ELEMENTS
------------------------------------------------------------ */

.hcg-container .hcg-menu-container {
    margin: 0;
    display: flex;
    flex-direction: column;
    list-style: none;
    row-gap: 5px;
    padding: 0;

    .hcg-menu-item {
        display: flex;
        align-items: center;
        gap: 2px;
        width: 100%;
        min-width: 185px;
        min-height: 2rem;
        padding: 8px 8px 8px 12px;
        font-size: 0.75rem;
        font-weight: 600;
        background-color: transparent;
        border: 1px solid transparent;
        border-radius: 5px;
    }

    .hcg-menu-item:not(:disabled) {
        cursor: pointer;
    }

    .hcg-menu-item:focus-visible {
        outline: none;
    }

    .hcg-menu-item-icon {
        --icon-size: 16px;

        flex: 0 0 var(--icon-size);
        width: var(--icon-size);
        height: var(--icon-size);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        opacity: 0.6;
    }

    .hcg-menu-item.active .hcg-menu-item-icon,
    .hcg-menu-item.highlighted .hcg-menu-item-icon,
    .hcg-menu-item:not(:disabled):hover .hcg-menu-item-icon {
        opacity: 1;
    }

    .hcg-menu-item-label {
        flex: 1 1 auto;
        min-width: 0;
        text-align: left;
        padding-left: 0.75rem;
    }

    .hcg-menu-divider {
        border-top-width: 1px;
        border-top-style: solid;
        height: 0;
    }
}

/* ----------------------------------------------------------
  FILTERING ELEMENTS
------------------------------------------------------------ */

.hcg-header-cell:has(.hcg-column-filter-wrapper) {
    overflow: hidden;
}

.hcg-column-filter-wrapper {
    width: 100%;
    display: flex;
    flex-flow: column;
    row-gap: 5px;
    min-width: 50px;
}

.hcg-clear-filter-button {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    display: inline;
    vertical-align: baseline;
    font: inherit;
    font-size: 0.625rem;
    white-space: nowrap;
    font-weight: normal;
    align-self: end;
}

.hcg-clear-filter-button:hover {
    text-decoration: underline;
    cursor: pointer;
}

.hcg-clear-filter-button:disabled,
.hcg-clear-filter-button:disabled:hover {
    opacity: 0.5;
    text-decoration: none;
    cursor: default;
}

/* ----------------------------------------------------------
  OTHER ELEMENTS
------------------------------------------------------------ */

/* Sorting */
.hcg-table thead th.hcg-column-sortable {
    cursor: pointer;
}

/* Accessibility */
.hcg-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
    clip: rect(1px, 1px, 1px, 1px);
    margin-top: -3px;
    opacity: 0.01;
}

.hcg-container.hcg-caption * {
    font: inherit;
    margin: 0;
}

/* Loader */
.hcg-loading-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    width: 100%;
    height: 100%;
    gap: 10px;
    color: light-dark(#000000, #ffffff);
}

.hcg-loading-wrapper .hcg-spinner {
    border-top-width: 5px;
    border-top-style: solid;
    border-top-color: light-dark(#000000, #ffffff);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Start Grid CSS Helpers Classes */

.hcg-table thead tr th.hcg-right .hcg-header-cell-content,
.hcg-table tbody tr td.hcg-right {
    text-align: right;
}

.hcg-table thead tr th.hcg-center .hcg-header-cell-content,
.hcg-table tbody tr td.hcg-center {
    text-align: center;
}

.hcg-table thead tr th.hcg-left .hcg-header-cell-content,
.hcg-table tbody tr td.hcg-left {
    text-align: left;
}

/* End Grid CSS Helpers Classes */
