/**
 * ZERTI AG Grid theme — extends ag-theme-quartz with design tokens.
 * Apply both classes: ag-theme-quartz ag-theme-zerti (via zerti_ui_ag_grid_region).
 *
 * @see docs/DESIGN-SYSTEM.md
 */

#zertiAdmin .ag-theme-zerti {
    position: relative;
    width: 100%;
    padding: clamp(0.65rem, 1.5vw, 1rem);
    font-family: var(--zerti-font-family) !important;
    --ag-font-family: var(--zerti-font-family);
    --ag-font-size: var(--zerti-font-size-base);
    --ag-row-height: 2.35rem;
    --ag-header-height: 3.15rem;
    --ag-pagination-panel-height: 2.8rem;
    --ag-cell-horizontal-padding: clamp(0.55rem, 1.2vw, 0.85rem);
    --ag-wrapper-border-radius: 0;
    --ag-background-color: transparent;
    --ag-foreground-color: var(--zerti-docs-text);
    --ag-header-background-color: color-mix(in srgb, var(--zerti-docs-subtle-bg) 58%, transparent);
    --ag-header-foreground-color: var(--zerti-docs-text);
    --ag-border-color: color-mix(in srgb, var(--zerti-docs-border) 55%, transparent);
    --ag-row-hover-color: color-mix(in srgb, var(--zerti-brand) 14%, transparent);
    --ag-odd-row-background-color: transparent;
    --ag-control-panel-background-color: transparent;
    --ag-secondary-foreground-color: var(--zerti-docs-muted);
    --ag-input-background-color: var(--zerti-docs-subtle-bg);
    --ag-input-border-color: var(--zerti-docs-border);
    --ag-active-color: var(--zerti-brand);
    --ag-checkbox-checked-color: var(--zerti-brand);
    --ag-selected-row-background-color: color-mix(in srgb, var(--zerti-brand) 16%, transparent);
    --ag-range-selection-border-color: var(--zerti-brand);
}

#zertiAdmin[data-bs-theme='light'] .ag-theme-zerti {
    --ag-row-hover-color: color-mix(in srgb, var(--zerti-brand) 10%, transparent);
}

#zertiAdmin .ag-theme-zerti *,
#zertiAdmin .ag-theme-zerti input,
#zertiAdmin .ag-theme-zerti button,
#zertiAdmin .ag-theme-zerti select {
    font-family: var(--zerti-font-family) !important;
}

#zertiAdmin .ag-theme-zerti .ag-icon,
#zertiAdmin .ag-theme-zerti .ag-icon::before {
    font-family: var(--ag-icon-font-family) !important;
}

/* Font Awesome inside grids (Vazirmatn * rule must not override icon glyphs). */
#zertiAdmin .ag-theme-zerti .fa,
#zertiAdmin .ag-theme-zerti .fas,
#zertiAdmin .ag-theme-zerti .far,
#zertiAdmin .ag-theme-zerti .fab,
#zertiAdmin .ag-theme-zerti .fa-solid,
#zertiAdmin .ag-theme-zerti .fa-regular,
#zertiAdmin .ag-theme-zerti .fa-brands,
#zertiAdmin .ag-theme-zerti i[class*='fa-'] {
    font-family: var(--fa-style-family, 'Font Awesome 6 Free') !important;
    font-style: normal;
    font-variant: normal;
    line-height: 1;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
}

#zertiAdmin .ag-theme-zerti .fa-solid,
#zertiAdmin .ag-theme-zerti .fas,
#zertiAdmin .ag-theme-zerti i.fa-solid {
    font-weight: 900 !important;
}

#zertiAdmin .ag-theme-zerti .fa-regular,
#zertiAdmin .ag-theme-zerti .far {
    font-weight: 400 !important;
}

#zertiAdmin .ag-theme-zerti .fa-brands,
#zertiAdmin .ag-theme-zerti .fab {
    font-family: 'Font Awesome 6 Brands' !important;
    font-weight: 400 !important;
}

#zertiAdmin .ag-theme-zerti .ag-root-wrapper {
    border: 0;
    background: transparent;
    box-shadow: none;
}

#zertiAdmin .ag-theme-zerti .ag-body-viewport {
    direction: rtl;
    overflow-y: auto;
}

#zertiAdmin .ag-theme-zerti .ag-root,
#zertiAdmin .ag-theme-zerti .ag-header,
#zertiAdmin .ag-theme-zerti .ag-body-viewport,
#zertiAdmin .ag-theme-zerti .ag-center-cols-viewport,
#zertiAdmin .ag-theme-zerti .ag-center-cols-container,
#zertiAdmin .ag-theme-zerti .ag-paging-panel {
    background: transparent;
}

#zertiAdmin .ag-theme-zerti .ag-header {
    border-bottom: 1px solid color-mix(in srgb, var(--zerti-docs-border) 70%, transparent);
    box-shadow: 0 1px 0 color-mix(in srgb, var(--zerti-docs-text) 4%, transparent) inset;
}

#zertiAdmin .ag-theme-zerti .ag-row {
    border-bottom: 1px solid color-mix(in srgb, var(--zerti-docs-border) 40%, transparent);
}

#zertiAdmin .ag-theme-zerti .ag-row-hover {
    background: var(--ag-row-hover-color);
}

/* Shared list grid typography: headers 9pt bold centered, rows 9pt normal centered */
#zertiAdmin .ag-theme-zerti .ag-header-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#zertiAdmin .ag-theme-zerti .ag-header-cell-label {
    justify-content: center;
    width: 100%;
    font-size: var(--zerti-font-size-base);
    font-weight: 700;
    line-height: var(--zerti-line-height-tight);
}

#zertiAdmin .ag-theme-zerti .ag-header-cell-text {
    font-size: var(--zerti-font-size-base);
    font-weight: 700;
    line-height: var(--zerti-line-height-tight);
    text-align: center;
    color: var(--zerti-docs-text);
}

#zertiAdmin .ag-theme-zerti .ag-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: var(--zerti-font-size-base);
    font-weight: 400;
    line-height: var(--zerti-line-height-tight);
}

#zertiAdmin .ag-theme-zerti .ag-cell .ag-cell-value {
    font-size: inherit;
    font-weight: inherit;
    text-align: center;
    width: 100%;
}

#zertiAdmin .ag-theme-zerti .ag-cell .badge {
    font-size: var(--zerti-font-size-base);
    font-weight: 400;
}

#zertiAdmin .ag-theme-zerti .ag-floating-filter-input,
#zertiAdmin .ag-theme-zerti .ag-floating-filter-input input {
    text-align: center;
    color: var(--zerti-docs-text);
    background: color-mix(in srgb, var(--zerti-docs-subtle-bg) 78%, transparent);
}

#zertiAdmin .ag-theme-zerti:has(.zerti-grid-inline-filter-header) .ag-root-wrapper,
#zertiAdmin .ag-theme-zerti:has(.zerti-grid-inline-filter-header) .ag-header,
#zertiAdmin .ag-theme-zerti:has(.zerti-grid-inline-filter-header) .ag-header-viewport,
#zertiAdmin .ag-theme-zerti:has(.zerti-grid-inline-filter-header) .ag-header-container {
    overflow: visible;
}

#zertiAdmin .ag-theme-zerti .ag-header-cell:has(.zerti-grid-inline-filter-header) {
    overflow: visible;
    align-items: center;
    padding-block: 0.15rem;
}

#zertiAdmin .zerti-grid-inline-filter-header {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

#zertiAdmin .zerti-grid-inline-filter-header__row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    width: 100%;
    min-width: 0;
}

#zertiAdmin .zerti-grid-inline-filter-header__label-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    line-height: 1.2;
}

#zertiAdmin .zerti-grid-inline-filter-header__label-wrap.ag-header-cell-sortable {
    cursor: pointer;
}

#zertiAdmin .zerti-grid-inline-filter-header__label {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 8pt;
    line-height: 1.2;
}

#zertiAdmin .zerti-grid-inline-filter-header__toggle {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    margin: 0;
    padding: 0;
    color: var(--zerti-docs-muted);
    background: transparent;
    border: 0;
    border-radius: 0.35rem;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

#zertiAdmin .zerti-grid-inline-filter-header__toggle:hover,
#zertiAdmin .zerti-grid-inline-filter-header.is-filter-open .zerti-grid-inline-filter-header__toggle {
    color: var(--zerti-docs-text);
    background: color-mix(in srgb, var(--zerti-docs-subtle-bg) 88%, transparent);
}

#zertiAdmin .zerti-grid-inline-filter-header__toggle.is-active,
#zertiAdmin .zerti-grid-inline-filter-header.has-active-filter .zerti-grid-inline-filter-header__toggle {
    color: var(--zerti-bs-purple);
}

#zertiAdmin .zerti-grid-inline-filter-header__toggle-icon {
    display: block;
    width: 0.85rem;
    height: 0.85rem;
}

#zertiAdmin .zerti-grid-inline-filter-header__panel {
    display: none;
    position: absolute;
    top: calc(100% + 0.15rem);
    left: 50%;
    z-index: 12;
    box-sizing: border-box;
    min-width: 8rem;
    max-width: min(16rem, 100vw);
    padding: 0.35rem;
    transform: translate(-50%, 0);
    background-color: var(--zerti-docs-bg);
    border: 1px solid var(--zerti-docs-border);
    border-radius: 0.5rem;
    box-shadow: 0 0.35rem 1rem color-mix(in srgb, var(--zerti-docs-text) 12%, transparent);
}

#zertiAdmin .zerti-grid-inline-filter-header.is-filter-open .zerti-grid-inline-filter-header__panel {
    display: block;
}

#zertiAdmin .zerti-grid-inline-filter-header .zerti-grid-filter-select,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select,
#zertiAdmin .zerti-component-shop .zerti-shop-orders-grid .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select,
#zertiAdmin .zerti-component-financial-payments .zerti-payments-grid .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select,
#zertiAdmin .zerti-component-financial-coupons .zerti-coupons-grid .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select,
#zertiAdmin .zerti-component-inventory-comments .zerti-reviews-grid .zerti-grid-inline-filter-header .zerti-grid-filter-select {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
    height: 1.35rem !important;
    min-height: 0 !important;
    max-height: 1.35rem !important;
    margin: 0;
    padding-block: 0;
    padding-inline-start: 0.4rem;
    padding-inline-end: 1.25rem;
    font-size: 8pt;
    font-weight: 500;
    line-height: 1.35rem;
    color: var(--zerti-docs-text);
    appearance: none;
    background-color: var(--zerti-docs-subtle-bg);
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%236b7280' d='M4.2 6.2a.75.75 0 0 1 1.06 0L8 8.94l2.74-2.74a.75.75 0 1 1 1.06 1.06L8.53 10.53a.75.75 0 0 1-1.06 0L4.2 7.26a.75.75 0 0 1 0-1.06Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: var(--zerti-select-chevron-pos);
    background-size: 0.7rem;
    border: 1px solid var(--zerti-docs-border);
    border-radius: 0.4rem;
    box-shadow: none;
    cursor: pointer;
    direction: inherit;
    text-align: center;
    text-align-last: center;
    --zerti-select-pad-inline-start: 0.4rem;
    --zerti-select-pad-inline-end: 1.25rem;
}

#zertiAdmin .zerti-grid-inline-filter-header .zerti-grid-filter-select option,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select option,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select option,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select option,
#zertiAdmin .zerti-component-shop .zerti-shop-orders-grid .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select option,
#zertiAdmin .zerti-component-financial-payments .zerti-payments-grid .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select option,
#zertiAdmin .zerti-component-financial-coupons .zerti-coupons-grid .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select option,
#zertiAdmin .zerti-component-inventory-comments .zerti-reviews-grid .zerti-grid-inline-filter-header .zerti-grid-filter-select option {
    color: var(--zerti-docs-text);
    background-color: var(--zerti-docs-bg);
}

#zertiAdmin .zerti-grid-inline-filter-header .zerti-grid-filter-select:hover,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select:hover,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select:hover,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select:hover,
#zertiAdmin .zerti-component-shop .zerti-shop-orders-grid .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select:hover,
#zertiAdmin .zerti-component-financial-payments .zerti-payments-grid .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select:hover,
#zertiAdmin .zerti-component-financial-coupons .zerti-coupons-grid .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select:hover,
#zertiAdmin .zerti-component-inventory-comments .zerti-reviews-grid .zerti-grid-inline-filter-header .zerti-grid-filter-select:hover {
    border-color: color-mix(in srgb, var(--zerti-bs-purple) 35%, var(--zerti-docs-border));
}

#zertiAdmin .zerti-grid-inline-filter-header .zerti-grid-filter-select:focus,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select:focus,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select:focus,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select:focus,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-grid-filter-select:focus-visible,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select:focus-visible,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select:focus-visible,
#zertiAdmin .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select:focus-visible,
#zertiAdmin .zerti-component-shop .zerti-shop-orders-grid .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select:focus,
#zertiAdmin .zerti-component-shop .zerti-shop-orders-grid .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select:focus-visible,
#zertiAdmin .zerti-component-financial-payments .zerti-payments-grid .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select:focus,
#zertiAdmin .zerti-component-financial-payments .zerti-payments-grid .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select:focus-visible,
#zertiAdmin .zerti-component-financial-coupons .zerti-coupons-grid .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select:focus,
#zertiAdmin .zerti-component-financial-coupons .zerti-coupons-grid .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select:focus-visible,
#zertiAdmin .zerti-component-inventory-comments .zerti-reviews-grid .zerti-grid-inline-filter-header .zerti-grid-filter-select:focus,
#zertiAdmin .zerti-component-inventory-comments .zerti-reviews-grid .zerti-grid-inline-filter-header .zerti-grid-filter-select:focus-visible {
    outline: 0;
    border-color: color-mix(in srgb, var(--zerti-bs-purple) 55%, var(--zerti-docs-border));
    box-shadow: 0 0 0 0.15rem color-mix(in srgb, var(--zerti-bs-purple) 22%, transparent);
}

#zertiAdmin[data-bs-theme='dark'] .zerti-grid-inline-filter-header .zerti-grid-filter-select,
#zertiAdmin[data-bs-theme='dark'] .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select,
#zertiAdmin[data-bs-theme='dark'] .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select,
#zertiAdmin[data-bs-theme='dark'] .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select,
#zertiAdmin[data-bs-theme='dark'] .zerti-component-shop .zerti-shop-orders-grid .zerti-grid-inline-filter-header .zerti-shop-grid-filter-select,
#zertiAdmin[data-bs-theme='dark'] .zerti-component-financial-payments .zerti-payments-grid .zerti-grid-inline-filter-header .zerti-payments-grid-filter-select,
#zertiAdmin[data-bs-theme='dark'] .zerti-component-financial-coupons .zerti-coupons-grid .zerti-grid-inline-filter-header .zerti-coupons-grid-filter-select,
#zertiAdmin[data-bs-theme='dark'] .zerti-component-inventory-comments .zerti-reviews-grid .zerti-grid-inline-filter-header .zerti-grid-filter-select {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23adb5bd' d='M4.2 6.2a.75.75 0 0 1 1.06 0L8 8.94l2.74-2.74a.75.75 0 1 1 1.06 1.06L8.53 10.53a.75.75 0 0 1-1.06 0L4.2 7.26a.75.75 0 0 1 0-1.06Z'/%3E%3C/svg%3E");
    background-size: 0.7rem;
}

#zertiAdmin .ag-theme-zerti .ag-root-wrapper > .ag-popup:has(.ag-filter),
#zertiAdmin .ag-theme-zerti .ag-root-wrapper > .ag-popup-child:has(.ag-filter) {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

@media (max-width: 575.98px) {
    #zertiAdmin .ag-theme-zerti.ag-theme-zerti--compact,
    #zertiAdmin .ag-theme-zerti.zerti-shop-orders-grid--compact,
    #zertiAdmin .ag-theme-zerti.zerti-customers-grid--compact,
    #zertiAdmin .ag-theme-zerti.zerti-products-grid--compact,
    #zertiAdmin .ag-theme-zerti.zerti-payments-grid--compact,
    #zertiAdmin .ag-theme-zerti.zerti-sales-report-grid--compact,
    #zertiAdmin .ag-theme-zerti.zerti-standard-reports-grid--compact,
    #zertiAdmin .ag-theme-zerti.zerti-reviews-grid--compact {
        width: 100%;
        min-width: 0;
        padding: 0.5rem 0.45rem;
        --ag-cell-horizontal-padding: 0.35rem;
        --ag-row-height: 3.5rem;
    }

    #zertiAdmin .ag-theme-zerti.zerti-shop-orders-grid--compact .ag-center-cols-viewport,
    #zertiAdmin .ag-theme-zerti.zerti-customers-grid--compact .ag-center-cols-viewport,
    #zertiAdmin .ag-theme-zerti.zerti-products-grid--compact .ag-center-cols-viewport,
    #zertiAdmin .ag-theme-zerti.zerti-payments-grid--compact .ag-center-cols-viewport,
    #zertiAdmin .ag-theme-zerti.zerti-sales-report-grid--compact .ag-center-cols-viewport,
    #zertiAdmin .ag-theme-zerti.zerti-standard-reports-grid--compact .ag-center-cols-viewport,
    #zertiAdmin .ag-theme-zerti.zerti-reviews-grid--compact .ag-center-cols-viewport {
        overflow-x: hidden;
    }

    #zertiAdmin .ag-theme-zerti[class*='-grid--compact'] .ag-header-cell,
    #zertiAdmin .ag-theme-zerti[class*='-grid--compact'] .ag-cell {
        min-width: 0;
    }

    #zertiAdmin .ag-theme-zerti[class*='-grid--compact'] .ag-row {
        border-bottom: 1px solid color-mix(in srgb, var(--zerti-docs-border) 35%, transparent);
    }

    #zertiAdmin .ag-theme-zerti[class*='-grid--compact'] .ag-cell {
        white-space: normal;
        line-height: var(--zerti-line-height-tight);
        word-break: break-word;
        overflow: hidden;
    }
}
