/*
 * Contract specs table + dropdown (native replacement for the Kendo UI Grid / DropDownList).
 * Mirrors the look the Kendo theme + site overrides produced.
 */

/* ---------- Dropdown ---------- */

.cs-select {
    position: relative;
    width: 200px;
    height: 55px;
}

.cs-select__button {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    padding-block: 4px;
    padding-inline: 16px 8px;
    border: 0;
    border-radius: 8px;
    background-color: #f9f9f9;
    color: var(--secondary-color);
    font-size: 15px;
    line-height: 1.4;
    text-align: start;
    cursor: pointer;
}

.cs-select__button:focus {
    outline: none;
}

.cs-select__button:focus-visible {
    box-shadow: 0 0 0 2px rgba(48, 175, 133, 0.35);
}

.cs-select__value {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-select__value .text-muted {
    display: block;
}

.cs-select__arrow {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 30px;
    color: #81858b;
}

.cs-select__popup {
    position: absolute;
    inset-inline-start: 0;
    top: calc(100% + 15px);
    z-index: 1050;
    width: 100%;
    max-height: 200px;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    list-style: none;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.15);
}

.cs-select__popup[hidden] {
    display: none;
}

.cs-select__option {
    padding: 4px 8px;
    border-radius: 8px;
    color: #81858b;
    font-size: 15px;
    line-height: 1.4;
    cursor: pointer;
}

.cs-select__option:hover,
.cs-select__option.is-active {
    background-color: #f1f1f1;
}

.cs-select__option[aria-selected="true"] {
    margin: 5px 3px;
    background-color: #f1f1f1;
    color: var(--secondary-color);
}

@media (max-width: 993px) {
    .cs-select {
        width: 100%;
    }
}

/* ---------- Grid ---------- */

.cs-grid {
    position: relative;
    width: 100%;
    color: #424242;
    font-size: 14px;
    line-height: 1.4285714286;
}

.cs-grid__scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cs-grid__table {
    width: 100%;
    min-width: 1100px;
    margin: 8px 0 0;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

.cs-grid--hierarchy .cs-grid__table {
    min-width: 0;
}

.cs-grid .cs-grid__table th,
.cs-grid .cs-grid__table td {
    border: 0;
}

/* Header: rounded brand bar separated from the body by an 8px gap */
.cs-grid .cs-grid__table th {
    padding: 5px 0;
    background-color: var(--primary-color);
    color: #fff;
    font-weight: 500;
    text-align: center;
    vertical-align: bottom;
}

.cs-grid .cs-grid__table th:first-child {
    border-start-start-radius: 8px;
    border-end-start-radius: 8px;
}

.cs-grid .cs-grid__table th:last-child {
    border-start-end-radius: 8px;
    border-end-end-radius: 8px;
}

.cs-grid__header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 12px 2px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 14px;
    line-height: inherit;
}

button.cs-grid__header {
    cursor: pointer;
}

.cs-grid__sort-icon {
    display: inline-flex;
    flex: 0 0 auto;
}

.cs-grid .cs-grid__table tr.cs-grid__gap td {
    height: 8px;
    padding: 0 !important;
    background: none;
    border: 0 !important;
}

/* Body */
.cs-grid .cs-grid__table td {
    height: 44px;
    padding: 8px 12px;
    color: #81858b;
    text-align: center;
    vertical-align: middle;
    overflow-wrap: anywhere;
    background-color: transparent;
}

.cs-grid .cs-grid__table tbody tr {
    background-color: #fff;
}

.cs-grid .cs-grid__table td img {
    display: inline-block;
}

.cs-grid__empty td {
    height: 44px;
}

@media (min-width: 768px) {
    .cs-grid .cs-grid__table tbody tr.cs-grid__row--alt td {
        background-color: #f6f6f6;
    }

    .cs-grid .cs-grid__table tbody tr.cs-grid__row:hover td {
        background-color: rgba(0, 0, 0, 0.06);
    }
}

/* main.css forces `th, td { padding: 4px; border: 0 solid #ddd }` (!important) below 768px */
@media (max-width: 767.98px) {
    .cs-grid .cs-grid__table td {
        padding: 4px;
        background-color: #fff;
        border-bottom: 1px solid #ddd;
        border-bottom-width: 1px !important;
    }

    .cs-grid .cs-grid__table tbody tr {
        border-left: 1px solid #f2f2f2;
    }
}

/* Mobile (hierarchy) grid: symbol rows expand into a details panel */
.cs-grid--hierarchy .cs-grid__table thead {
    display: none;
}

.cs-grid--hierarchy .cs-grid__table {
    margin-top: 10px;
}

.cs-grid--hierarchy .cs-grid__table td {
    color: var(--secondary-color);
    text-align: start;
}

.cs-grid .cs-grid__table td.cs-grid__hierarchy-cell {
    padding: 0 !important;
}

.cs-grid__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: #81858b;
    cursor: pointer;
}

.cs-grid__toggle svg {
    width: 8px;
    height: 5px;
    transition: transform 0.2s ease;
}

.cs-grid__toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.cs-grid .cs-grid__table td.cs-grid__detail-cell {
    height: auto;
    padding-top: 4px;
    padding-bottom: 4px;
    overflow-wrap: normal;
}

.cs-grid__detail-title {
    color: #b5b4b5;
}

.cs-grid__detail-value {
    color: #000;
}

/* Arabic: numbers read LTR, unit labels (wrapped in a span) keep RTL */
html[lang="ar"] .cs-grid .cs-grid__table td {
    direction: ltr;
}

html[lang="ar"] .cs-grid .cs-grid__table td:has(> span) {
    direction: rtl;
}

/* Loading mask */
.cs-grid__mask {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    background-color: rgba(255, 255, 255, 0.3);
}

.cs-grid[aria-busy="true"] .cs-grid__mask {
    display: block;
}

/* ---------- Pager ---------- */

.cs-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    padding: 8px;
    border-top: 1px solid #fff;
    background-color: #fafafa;
    color: #424242;
    font-size: 14px;
    line-height: 1.4285714286;
}

.cs-pager__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 4px 8px;
    border: 0;
    border-radius: 4px;
    background: none;
    color: #424242;
    font: inherit;
    cursor: pointer;
}

.cs-pager__button:hover {
    background-color: #f1f1f1;
}

.cs-pager__button:focus {
    outline: none;
}

.cs-pager__button:focus-visible {
    box-shadow: 0 0 0 2px rgba(48, 175, 133, 0.35);
}

.cs-pager__button:disabled {
    opacity: 0.6;
    pointer-events: none;
    cursor: default;
}

.cs-pager__nav,
.cs-pager__refresh {
    padding: 4px;
}

.cs-pager__refresh {
    margin-inline-start: auto;
}

.cs-pager__numbers {
    display: flex;
    align-items: center;
    gap: 0;
}

.cs-pager__numbers .cs-pager__button {
    color: var(--primary-color);
}

.cs-pager__numbers .cs-pager__button[aria-current="page"] {
    border-radius: 8px;
    background-color: #f1f1f1;
    color: #203c83;
    cursor: default;
}

.cs-pager__select {
    display: none;
    min-width: 5em;
    height: 30px;
    padding: 4px 8px;
    border: 1px solid #767676;
    border-radius: 4px;
    background-color: #fff;
    color: #424242;
    font: inherit;
}

.cs-pager__info {
    flex: 1 1 auto;
    padding-inline: 1em;
    text-align: end;
}

[dir="rtl"] .cs-pager__nav svg {
    transform: scaleX(-1);
}

/* Narrow pagers (mobile grid): page select instead of number buttons, no info text */
.cs-pager--md .cs-pager__info {
    display: none;
}

.cs-pager--sm .cs-pager__numbers {
    display: none;
}

.cs-pager--sm .cs-pager__select {
    display: inline-block;
}
