/* =========================================
   Chart Grid Filter Styles
   Aligned with Inbox Table funnel behavior and design.
   ========================================= */

/* Hide menu button and keep only funnel button */
.chart-grid .ag-header-cell-menu-button {
    display: none !important;
}

.chart-grid .ag-header-cell-filter-button {
    width: 16px !important;
    min-width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    border: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    align-self: center !important;
    line-height: 0 !important;
    position: absolute !important;
    right: 2px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 2 !important;
    opacity: 0.3 !important;
    color: #f5f8ff !important;
    cursor: pointer !important;
}

.chart-grid .ag-header-cell-filtered .ag-header-cell-filter-button {
    opacity: 1 !important;
    color: #e5b900 !important;
}

.chart-grid .ag-header-cell-filter-button .st-chart-filter-icon,
.chart-grid .ag-header-cell-filter-button .st-chart-filter-icon svg,
.chart-grid .ag-header-cell-filter-button .ag-icon,
.chart-grid .ag-header-cell-filter-button svg {
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    fill: currentColor !important;
    color: inherit !important;
}

/* Color de las flechas de ordenamiento (mismo que el embudo) */
.chart-grid .ag-header-cell .ag-sort-ascending-icon,
.chart-grid .ag-header-cell .ag-sort-descending-icon,
.chart-grid .ag-header-cell .ag-sort-ascending-icon svg,
.chart-grid .ag-header-cell .ag-sort-descending-icon svg,
.chart-grid .ag-header-cell .ag-icon-asc,
.chart-grid .ag-header-cell .ag-icon-desc {
    color: #f5f8ff !important;
    fill: #f5f8ff !important;
    opacity: 0.8 !important;
}

/* Cuando la columna está ordenada (Dorado) */
.chart-grid .ag-header-cell-sorted .ag-sort-ascending-icon,
.chart-grid .ag-header-cell-sorted .ag-sort-descending-icon,
.chart-grid .ag-header-cell-sorted .ag-sort-ascending-icon svg,
.chart-grid .ag-header-cell-sorted .ag-sort-descending-icon svg,
.chart-grid .ag-header-cell-sorted .ag-icon-asc,
.chart-grid .ag-header-cell-sorted .ag-icon-desc {
    color: #e5b900 !important;
    fill: #e5b900 !important;
    opacity: 1 !important;
}

.st-chart-filter-popup.ag-popup-child {
    border-radius: 16px !important;
    border: 1px solid rgba(188, 208, 233, 0.58) !important;
    background: linear-gradient(180deg, rgba(118, 132, 151, 0.62) 0%, rgba(101, 117, 139, 0.6) 100%) !important;
    box-shadow: 0 18px 38px rgba(10, 27, 51, 0.36), 0 1px 0 rgba(255, 255, 255, 0.2) inset !important;
    padding: 10px 10px 9px !important;
    color: #f4f8ff !important;
    backdrop-filter: blur(7px);
    resize: none !important;
}

.st-chart-filter-popup .ag-filter-wrapper {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    resize: none !important;
}

/* Disable resize on all inner AG Grid resizable elements */
.st-chart-filter-popup .ag-resizer,
.st-chart-filter-popup .ag-filter-toolpanel-body,
.st-chart-filter-popup .ag-set-filter,
.st-chart-filter-popup .ag-filter-body-wrapper {
    resize: none !important;
}

/* Hide resize handles completely */
.st-chart-filter-popup .ag-resizer {
    display: none !important;
}

.st-chart-filter-popup .ag-set-filter,
.st-chart-filter-popup .ag-filter-body-wrapper,
.st-chart-filter-popup .ag-set-filter-body-wrapper {
    border: 0 !important;
    background: transparent !important;
}

.st-chart-filter-popup .ag-mini-filter,
.st-chart-filter-popup .ag-set-filter-mini-filter {
    margin: 0 0 10px 0 !important;
    width: 100% !important;
    position: relative !important;
}

.st-chart-filter-popup .ag-mini-filter .ag-input-wrapper,
.st-chart-filter-popup .ag-set-filter-mini-filter .ag-input-wrapper,
.st-chart-filter-popup .ag-mini-filter .ag-input-field-input-wrapper,
.st-chart-filter-popup .ag-set-filter-mini-filter .ag-input-field-input-wrapper {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
}

.st-chart-filter-popup .ag-mini-filter .ag-icon,
.st-chart-filter-popup .ag-set-filter-mini-filter .ag-icon,
.st-chart-filter-popup .ag-mini-filter .ag-input-field-icon,
.st-chart-filter-popup .ag-set-filter-mini-filter .ag-input-field-icon {
    position: absolute !important;
    left: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #6a87ae !important;
    opacity: 0.95 !important;
    width: 14px !important;
    height: 14px !important;
    font-size: 14px !important;
    pointer-events: none !important;
    z-index: 2 !important;
}

.st-chart-filter-popup .ag-input-field-input,
.st-chart-filter-popup .ag-text-field-input {
    width: 100% !important;
    height: 36px !important;
    border-radius: 11px !important;
    border: 1px solid rgba(160, 186, 220, 0.76) !important;
    background: rgba(255, 255, 255, 0.96) !important;
    color: #1f3a5e !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    padding: 0 11px 0 34px !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset !important;
}

.st-chart-filter-popup .ag-input-field-input::placeholder,
.st-chart-filter-popup .ag-text-field-input::placeholder {
    color: #6a7990 !important;
    opacity: 0.95 !important;
}

.st-chart-filter-popup .ag-input-field-input:hover,
.st-chart-filter-popup .ag-text-field-input:hover,
.st-chart-filter-popup .ag-input-field-input:focus,
.st-chart-filter-popup .ag-text-field-input:focus,
.st-chart-filter-popup .ag-input-field-input:focus-visible,
.st-chart-filter-popup .ag-text-field-input:focus-visible {
    border-color: #e500cd !important;
    box-shadow: none !important;
    outline: 0 !important;
}

.st-chart-filter-popup .ag-set-filter-list {
    width: 100% !important;
    border-radius: 12px !important;
    border: 1px solid rgba(185, 205, 231, 0.74) !important;
    background: #ffffff !important;
    padding: 4px !important;
    overflow: hidden !important;
    min-height: 40px !important;
    height: auto !important;
    max-height: min(340px, 50vh) !important;
    display: flex !important;
    flex-direction: column !important;
}

.st-chart-filter-popup .ag-virtual-list-viewport {
    background: #ffffff !important;
    height: auto !important;
    flex: 1 1 auto !important;
    max-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-bottom: 4px !important;
    box-sizing: border-box !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(160, 180, 210, 0.5) transparent !important;
}

/* Webkit (Chrome, Edge, Safari) custom scrollbar */
.st-chart-filter-popup .ag-virtual-list-viewport::-webkit-scrollbar {
    width: 6px !important;
}

.st-chart-filter-popup .ag-virtual-list-viewport::-webkit-scrollbar-track {
    background: rgba(220, 230, 245, 0.35) !important;
    border-radius: 10px !important;
    margin: 4px 0 !important;
}

.st-chart-filter-popup .ag-virtual-list-viewport::-webkit-scrollbar-thumb {
    background: rgba(140, 165, 200, 0.55) !important;
    border-radius: 10px !important;
    min-height: 30px !important;
}

.st-chart-filter-popup .ag-virtual-list-viewport::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 150, 190, 0.75) !important;
}

/* Broader scrollbar coverage for all scrollable elements in popup */
.st-chart-filter-popup .ag-set-filter-list,
.st-chart-filter-popup .ag-set-filter-body-wrapper,
.st-chart-filter-popup .ag-filter-body-wrapper {
    scrollbar-width: thin !important;
    scrollbar-color: rgba(160, 180, 210, 0.5) transparent !important;
}

.st-chart-filter-popup .ag-set-filter-list::-webkit-scrollbar,
.st-chart-filter-popup .ag-set-filter-body-wrapper::-webkit-scrollbar,
.st-chart-filter-popup .ag-filter-body-wrapper::-webkit-scrollbar {
    width: 6px !important;
}

.st-chart-filter-popup .ag-set-filter-list::-webkit-scrollbar-track,
.st-chart-filter-popup .ag-set-filter-body-wrapper::-webkit-scrollbar-track,
.st-chart-filter-popup .ag-filter-body-wrapper::-webkit-scrollbar-track {
    background: rgba(220, 230, 245, 0.35) !important;
    border-radius: 10px !important;
    margin: 4px 0 !important;
}

.st-chart-filter-popup .ag-set-filter-list::-webkit-scrollbar-thumb,
.st-chart-filter-popup .ag-set-filter-body-wrapper::-webkit-scrollbar-thumb,
.st-chart-filter-popup .ag-filter-body-wrapper::-webkit-scrollbar-thumb {
    background: rgba(140, 165, 200, 0.55) !important;
    border-radius: 10px !important;
    min-height: 30px !important;
}

.st-chart-filter-popup .ag-set-filter-list::-webkit-scrollbar-thumb:hover,
.st-chart-filter-popup .ag-set-filter-body-wrapper::-webkit-scrollbar-thumb:hover,
.st-chart-filter-popup .ag-filter-body-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 150, 190, 0.75) !important;
}

.st-chart-filter-popup .ag-virtual-list-container {
    background: #ffffff !important;
    min-width: 100% !important;
    width: max-content !important;
    padding-right: 6px !important;
    box-sizing: border-box !important;
}

.st-chart-filter-popup .ag-virtual-list-item {
    display: flex !important;
    align-items: center !important;
}

.st-chart-filter-popup .ag-set-filter-item {
    min-height: 0 !important;
    height: 100% !important;
    border-radius: 8px !important;
    margin: 1px 0 !important;
    padding: 0 8px !important;
    color: #1d395f !important;
    white-space: nowrap !important;
    font-size: 0.92rem !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    display: flex !important;
    align-items: center !important;
}

.st-chart-filter-popup .ag-set-filter-item .ag-label,
.st-chart-filter-popup .ag-set-filter-item .ag-checkbox-label,
.st-chart-filter-popup .ag-set-filter-item .ag-set-filter-item-value {
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: none !important;
}

.st-chart-filter-popup .ag-set-filter-item:hover {
    background: rgba(41, 87, 145, 0.12) !important;
}

.st-chart-filter-popup .ag-checkbox-input-wrapper {
    border-radius: 6px !important;
    border: 1px solid #7396c3 !important;
    background: #eff4fb !important;
    width: 17px !important;
    height: 17px !important;
    min-width: 17px !important;
    min-height: 17px !important;
    margin-right: 8px !important;
    position: relative !important;
    font-size: 0 !important;
}

.st-chart-filter-popup .ag-checkbox-input-wrapper:focus,
.st-chart-filter-popup .ag-checkbox-input-wrapper:focus-visible,
.st-chart-filter-popup .ag-checkbox-input-wrapper:focus-within,
.st-chart-filter-popup .ag-checkbox-input-wrapper.ag-focus-managed,
.st-chart-filter-popup .ag-checkbox-input:focus+.ag-checkbox-input-wrapper,
.st-chart-filter-popup .ag-checkbox-input:focus-visible+.ag-checkbox-input-wrapper {
    outline: none !important;
    box-shadow: none !important;
}

.st-chart-filter-popup .ag-set-filter-item:focus,
.st-chart-filter-popup .ag-set-filter-item:focus-visible {
    outline: none !important;
}

.st-chart-filter-popup .ag-checkbox-input-wrapper.ag-checked {
    border-color: #e5b900 !important;
    background: #e5b900 !important;
    box-shadow: none !important;
}

.st-chart-filter-popup .ag-checkbox-input-wrapper::after {
    content: "" !important;
    opacity: 0 !important;
}

.st-chart-filter-popup .ag-checkbox-input-wrapper.ag-checked::after {
    content: "\2713" !important;
    position: absolute !important;
    left: 50% !important;
    top: 49% !important;
    transform: translate(-50%, -50%) !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    font-family: Inter, "Segoe UI", sans-serif !important;
    letter-spacing: 0 !important;
    text-shadow: none !important;
    opacity: 1 !important;
    box-sizing: border-box !important;
}

.st-chart-filter-popup .ag-icon-checkbox-unchecked,
.st-chart-filter-popup .ag-icon-checkbox-indeterminate {
    opacity: 0 !important;
}

.st-chart-filter-popup .ag-filter-apply-panel {
    border-top: 1px solid rgba(197, 214, 237, 0.52) !important;
    margin-top: 9px !important;
    padding-top: 10px !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
}

.st-chart-filter-popup .ag-button {
    border-radius: 999px !important;
    border: 1px solid rgba(151, 176, 206, 0.82) !important;
    background: rgba(247, 250, 255, 0.96) !important;
    color: #1e395d !important;
    min-height: 33px !important;
    padding: 0 16px !important;
    font-size: 0.84rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.01em !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset !important;
    cursor: pointer !important;
}

.st-chart-filter-popup .ag-button:hover {
    border-color: rgba(124, 154, 193, 0.92) !important;
    background: #ffffff !important;
}

.st-chart-filter-popup .ag-filter-apply-panel .ag-button:first-child {
    border-color: #e500cd !important;
    background: #e500cd !important;
    color: #ffffff !important;
    box-shadow: none !important;
}

.st-chart-filter-popup .ag-filter-apply-panel .ag-button:first-child:hover {
    background: #f100d9 !important;
    border-color: #f100d9 !important;
    box-shadow: none !important;
}

/* =========================================
   Chart Grid Base Layout Overrides
   ========================================= */
.chart-grid {
    --ag-background-color: transparent;
    --ag-header-background-color: transparent;
    --ag-odd-row-background-color: rgba(71, 110, 156, 0.24);
    --ag-control-panel-background-color: transparent;
    --ag-row-border-color: rgba(255, 255, 255, 0.06);
    --ag-header-column-separator-display: none;
    --ag-header-column-resize-handle-display: none;
    --ag-border-color: transparent;
    --ag-wrapper-border-color: transparent;
    background-color: transparent !important;
}

.chart-grid.ag-theme-alpine-dark {
    --ag-background-color: transparent;
    --ag-header-background-color: transparent;
    --ag-odd-row-background-color: rgba(71, 110, 156, 0.24);
    --ag-foreground-color: #cbd5e1;
    --ag-header-foreground-color: #ffffff;
}

.chart-grid .ag-root-wrapper,
.chart-grid .ag-root-wrapper-body,
.chart-grid .ag-body,
.chart-grid .ag-body-viewport,
.chart-grid .ag-center-cols-clipper,
.chart-grid .ag-center-cols-viewport,
.chart-grid .ag-center-cols-container {
    background-color: transparent !important;
}

.chart-grid .ag-root-wrapper {
    border: none !important;
    border-radius: 12px !important;
    overflow: hidden !important;
}

.chart-grid .ag-header,
.chart-grid .ag-header-viewport {
    background: transparent !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

.chart-grid .ag-header-row {
    background: #10233f !important;
    border-radius: 12px 12px 0 0 !important;
    overflow: hidden !important;
}

.chart-grid .ag-center-cols-container {
    border-bottom-right-radius: 12px !important;
    border-bottom-left-radius: 12px !important;
    overflow: hidden !important;
}

.chart-grid .ag-header-cell,
.chart-grid .ag-header-group-cell {
    background: transparent !important;
    box-shadow: none !important;
    border-right: 1px solid rgba(148, 163, 184, 0.12) !important;
    padding-right: 2px !important; /* Elimina espacio en blanco sobrante del theme */
}

/* Forzar que el redimensionador sea visible en la última columna */
.chart-grid .ag-header-cell:last-child .ag-header-cell-resize {
    display: block !important;
    width: 6px !important;
}

.chart-grid .ag-header-cell-label,
.chart-grid .ag-header-group-text {
    align-items: center !important;
}

.chart-grid .ag-header-cell-label {
    width: 100% !important;
    padding-right: 18px !important; /* Espacio mínimo para el botón de filtro al ras */
    box-sizing: border-box !important;
    display: flex !important;
    overflow: hidden !important; 
}

.chart-grid .ag-header-cell.ag-header-center {
    padding-left: 0 !important; /* Elimina los 12px por defecto que lo empujaban a la derecha */
    padding-right: 0 !important;
}

.chart-grid .ag-header-cell.ag-header-center .ag-header-cell-label {
    justify-content: center !important;
    padding-left: 18px !important; /* Equilibra el padding-right del filtro para un centrado real */
}

.chart-grid .ag-header-cell.ag-header-center .ag-header-cell-text {
    flex: initial !important; /* Deja de llenar todo el espacio para que justify-content del padre lo centre */
    text-align: center !important;
}

.chart-grid .ag-header-cell-text,
.chart-grid .ag-header-group-text {
    color: #ffffff !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    flex: 1 1 auto !important;
}

.chart-grid .ag-row-even,
.chart-grid .ag-row-even .ag-cell {
    background-color: transparent !important;
}

.chart-grid .ag-row-odd,
.chart-grid .ag-row-odd .ag-cell {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.chart-grid .ag-cell {
    box-shadow: none !important;
    color: #cbd5e1 !important;
    font-weight: 400 !important;
    display: flex !important;
    align-items: center !important;
}

.chart-grid .ag-cell.ag-cell-center {
    justify-content: center !important;
    text-align: center !important;
}

.chart-grid .ag-cell-wrapper,
.chart-grid .ag-cell-value {
    display: flex !important;
    align-items: center !important;
    min-height: 100% !important;
}

.chart-grid .ag-cell-value,
.chart-grid .ag-group-value {
    font-weight: 400 !important;
}

/* =========================================
   Column Chooser Popup — Workshop State
   Popup custom con estilo glassmorphism
   idéntico al embudo de filtros.
   ========================================= */

.st-column-chooser-popup {
    border-radius: 16px !important;
    border: 1px solid rgba(188, 208, 233, 0.58) !important;
    background: linear-gradient(180deg, rgba(118, 132, 151, 0.62) 0%, rgba(101, 117, 139, 0.6) 100%) !important;
    box-shadow: 0 18px 38px rgba(10, 27, 51, 0.36), 0 1px 0 rgba(255, 255, 255, 0.2) inset !important;
    padding: 10px !important;
    backdrop-filter: blur(7px);
    animation: stColumnChooserIn 0.15s ease-out;
}

@keyframes stColumnChooserIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.st-column-chooser-list {
    border-radius: 12px;
    border: 1px solid rgba(185, 205, 231, 0.74);
    background: #ffffff;
    padding: 4px;
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(160, 180, 210, 0.5) transparent;
}

.st-column-chooser-list::-webkit-scrollbar {
    width: 6px;
}

.st-column-chooser-list::-webkit-scrollbar-track {
    background: rgba(220, 230, 245, 0.35);
    border-radius: 10px;
    margin: 4px 0;
}

.st-column-chooser-list::-webkit-scrollbar-thumb {
    background: rgba(140, 165, 200, 0.55);
    border-radius: 10px;
    min-height: 30px;
}

.st-column-chooser-item {
    display: flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    margin: 0;
    color: #1d395f;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.1;
    transition: background 0.12s;
}

.st-column-chooser-item:hover {
    background: rgba(41, 87, 145, 0.12);
}

/* ── Checkbox dorado (idéntico al embudo) ── */
.st-column-checkbox {
    width: 15px;
    height: 15px;
    min-width: 15px;
    min-height: 15px;
    border-radius: 4px;
    border: 1px solid #7396c3;
    background: #eff4fb;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    color: transparent;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.st-column-checkbox.checked {
    border-color: #e5b900;
    background: #e5b900;
    color: #ffffff;
}

.st-column-chooser-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Botones Ok / Cancelar (estilo embudo) ── */
.st-column-chooser-buttons {
    border-top: 1px solid rgba(197, 214, 237, 0.52);
    margin-top: 9px;
    padding-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.st-column-btn {
    border-radius: 999px;
    border: 1px solid rgba(151, 176, 206, 0.82);
    background: rgba(247, 250, 255, 0.96);
    color: #1e395d;
    min-height: 33px;
    padding: 0 16px;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
    cursor: pointer;
    transition: all 0.15s ease;
}

.st-column-btn:hover {
    border-color: rgba(124, 154, 193, 0.92);
    background: #ffffff;
}

.st-column-btn-ok {
    border-color: #e500cd;
    background: #e500cd;
    color: #ffffff;
    box-shadow: none;
}

.st-column-btn-ok:hover {
    background: #f100d9;
    border-color: #f100d9;
}

/* ── Column Chooser Search ── */
.st-column-chooser-search {
    margin-bottom: 12px;
    padding: 2px 0;
}

.st-column-search-input {
    width: 100%;
    height: 36px;
    border-radius: 11px;
    border: 1px solid rgba(160, 186, 220, 0.76) !important;
    background: rgba(255, 255, 255, 0.96) !important;
    color: #1f3a5e !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    padding: 0 14px !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset !important;
    outline: none !important;
}

.st-column-search-input:focus { border-color: #e500cd !important; }
.st-column-search-input::placeholder { color: #8da1bc !important; }