/***********************************************************************************************************************************************************/
/* Global overrides to standard agGrid library styles */
/***********************************************************************************************************************************************************/
.ag-row-odd {
    background-color: var(--bs-gray-50);
}

.ag-row-selected {
    background-color: #cce7ff;
}

.ag-theme-quartz {
    --ag-header-background-color: var(--bs-white);
}

    /* Default font size */
    .ag-theme-quartz, .ag-header-cell-label .ag-header-cell-text, .ag-theme-quartz .ag-row {
        font-size: 1rem;
    }

        /* Overrides ag-grid header color */
        .ag-theme-quartz .ag-header {
            border-bottom: solid 1px;
            border-bottom-color: var(--agBorderColor);
        }

        .ag-theme-quartz .ag-tabs-header.ag-menu-header, .ag-theme-quartz .ag-tabs-body.ag-menu-body, .ag-theme-quartz .ag-menu.ag-popup-child {
            background-color: var(--bs-white);
        }

.ag-header-cell-label .ag-header-cell-text {
    font-size: 1rem;
    font-weight: 500;
}

/***********************************************************************************************************************************************************/
/* Styles specific to ag-grid cell edit validation */
/***********************************************************************************************************************************************************/
.agc-cell-input-group-editor {
    margin-top: 1px;
    font-weight: normal;
}

    .agc-cell-input-group-editor .form-control:focus {
        box-shadow: none;
        border: 1px solid var(--formControlBorderColor);
        border-right: none;
    }

    .agc-cell-input-group-editor .input-group-text {
        padding: 0rem 0.75rem !important;
    }

    .agc-cell-input-group-editor.has-error button {
        color: var(--formValidationInvalidColor);
        border-color: var(--formValidationInvalidColor) !important;
        border-left: 0px;
    }

    .agc-cell-input-group-editor input {
        font-weight: normal;
        border-right: 0px;
    }

    .agc-cell-input-group-editor.has-error input {
        border-color: var(--formValidationInvalidColor) !important;
    }

.agc-cell-update-success {
    color: var(--bs-blue) !important;
    font-weight: bold;
}

.agc-cell-update-error {
    color: var(--formValidationInvalidColor) !important;
    font-weight: bold;
}

.agc-cell-input-group-editor button.agc-cell-editor-status {
    width: 40px;
}

.agc-cell-input-group-editor.has-error button.agc-cell-editor-status:hover {
    color: var(--formValidationInvalidColor) !important;
    -webkit-text-stroke-width: unset;
}

.ag-popup-editor .bootstrap-select button {
    border: solid 1px var(--ag-input-focus-border-color) !important;
    min-height: 41px !important;
}

.agc-cell-input-group-editor input,
.agc-cell-input-group-editor select,
.agc-cell-input-group-editor textarea {
    margin-left: 2px;
    height: 36px;
}

.agc-cell-input-group-editor button.input-group-text {
    margin-right: 2px;
}

.agc-cell-input-group-editor.has-error button.input-group-text i.fa.fa-times {
    color: var(--formValidationInvalidColor) !important;
}

.agc-cell-input-group-editor input:focus:not([readonly]):not([disabled]),
.agc-cell-input-group-editor select:focus:not([disabled]),
.agc-cell-input-group-editor textarea:focus:not([readonly]):not([disabled]) {
    box-shadow: 0 0 0 0.25rem rgba(13, 202, 240, .25), /* Custom Bootstrap shadow color */
    0 2px 0 0 var(--sidebarSelectedItemBorderColor) !important;
}

.agc-cell-input-group-editor:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 202, 240, .25), 0 2px 0 0 var(--sidebarSelectedItemBorderColor) !important;
}

.agc-cell-input-group-editor.has-error input:focus:not([readonly]):not([disabled]) {
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25), 0 2px 0 0 var(--formValidationInvalidColor) !important
}

.ag-cell-inline-editing {
    border-color: var(--sidebarSelectedItemBorderColor) !important;
}

.ag-paging-page-rows, .ag-paging-page-rows:focus {
    border: none !important;
    box-shadow: none !important;
}

/* General rule for quick filter: no rounding for span and input */
.ag-theme-quartz > [id^='ag-quick-filter'] span.input-group-text,
.ag-theme-quartz > [id^='ag-quick-filter'] input.form-control {
    border-radius: 0;
}

.ag-theme-quartz .input-group-text[id^='ag-quick-filter'],
.ag-theme-quartz .input-group-text[id^='ag-quick-filter'] i {
    background-color: var(--bs-white) !important;
    color: var(--bs-gray)
}

    .ag-theme-quartz .input-group-text[id^='ag-quick-filter']:hover,
    .ag-theme-quartz .input-group-text[id^='ag-quick-filter']:hover i {
        color: var(--sidebarSelectedItemBorderColor);
        -webkit-text-stroke-width: 1px;
        cursor: pointer;
    }

    .ag-theme-quartz .input-group-text[id^='ag-quick-filter-'].ag-quick-filter-pers-warn,
    .ag-theme-quartz .input-group-text[id^='ag-quick-filter-'].ag-quick-filter-pers-warn i {
        background-color: var(--bs-warning-bg-subtle) !important;
        color: var(--bs-gray) !important;
        border-color: var(--bs-warning-border-subtle);
    }

    .ag-theme-quartz .input-group-text[id^='ag-quick-filter-'].ag-quick-filter-pers-warn:hover,
    .ag-theme-quartz .input-group-text[id^='ag-quick-filter-'].ag-quick-filter-pers-warn:hover i {
        color: var(--bs-white);
        -webkit-text-stroke-width: 1px;
        cursor: pointer;
    }

/* General rule for alert affecting the grid */
.ag-theme-quartz > [id^='ag-alert'] ~ .ag-root-wrapper {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Specific rule for alert: rounded top corners */
.ag-theme-quartz > [id^='ag-alert'] {
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
}

/* Rule for quick filter when no alert is present: rounded top corners */
.ag-theme-quartz > [id^='ag-quick-filter']:first-child span.input-group-text,
.ag-theme-quartz > [id^='ag-quick-filter']:first-child input.form-control {
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
}

/* Rule to ensure the grid itself does not have rounded corners at the top */
.ag-theme-quartz .ag-root-wrapper {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Rule to round the top corners of the grid when there is no alert or quick filter before it */
.ag-theme-quartz:not(:has([id^='ag-alert'])):not(:has([id^='ag-quick-filter'])) > .ag-root-wrapper {
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
}

/* Hide scrollbars by default */
.ag-cell-wrap {
    max-height: 400px;
    overflow: hidden;
    position: relative;
}

    /* Add scrollbar only on hover */
    .ag-cell-wrap:hover {
        overflow: auto;
    }

    /* Optional: Styling scrollbar for Webkit browsers (Chrome, Safari) */
    .ag-cell-wrap::-webkit-scrollbar {
        width: 14px;
    }

    .ag-cell-wrap::-webkit-scrollbar-thumb {
        background-color: var(--aggrid-row-focus-bg);
        border-left: 3px solid #fff;
        border-right: 3px solid #fff;
        border-top-right-radius: 12px;
        border-bottom-right-radius: 12px;
    }

    .ag-cell-wrap::-webkit-scrollbar-track {
        background: #fff;
    }

.ag-cell.ag-cell-value a {
    text-decoration: none;
    color: var(--bs-gray-600);
}

    .ag-cell.ag-cell-value a:hover {
        text-decoration: underline;
        color: var(--pageTitleBgColor);
        text-shadow: 0px 0px 1px var(--pageTitleBgColor);
    }


/***********************************************************************************************************************************************************/
/* Styles specific to ag-grid cell tooltip */
/***********************************************************************************************************************************************************/

.ag-tooltip {
    position: absolute;
    background-color: var(--tooltipBgColor);
    color: white;
    padding: 7px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.5);
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    white-space: pre-wrap;
    max-width: 500px;
    width: max-content;
    font-size: 0.875rem;
    z-index: 1050;
    pointer-events: none;
}
