All files / src/features/splits/pages SplitsPage.vue

99.08% Statements 217/219
87.35% Branches 152/174
100% Functions 45/45
100% Lines 172/172

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927                                                                                                                                                                                                                                                                                                                                                                                                                                      1x 1x 1x 1x     1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 167x   62x   62x 62x 62x   62x 63x     62x 62x 62x 62x 62x 62x       62x 62x   62x 62x     62x 72x   8x 9x     8x     62x 53x     62x 62x   62x         62x                                                                                                               62x 72x 154x 154x 86x   18x 2x 16x 14x     72x     62x 81x 81x 81x         81x     68x 9x 9x   2x 8x 16x   8x         16x   8x   17x     71x   62x 74x 12x 27x 14x     62x 74x           74x   12x 27x 27x 10x 17x 3x 14x 14x       12x     62x                 62x 74x 11x         74x 25x     74x     62x 74x   74x 74x 74x     74x       74x                   74x 12x     74x         74x       74x 12x           74x 14x 14x     14x     74x               62x 11x                 11x 5x     11x 5x     11x       13x 13x 13x 13x 13x 13x     45x 8x 8x 8x 8x 8x   14x 1x       7x   7x 7x   7x 7x 6x 6x   1x 1x       7x 7x             19x 19x   17x 7x 6x 5x 10x 5x   5x       7x         7x 8x   10x 2x 2x 2x 2x 2x         2x       2x 2x     1x 1x       1x       1x       1x           310x 62x       62x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
<template>
  <div>
    <div class="grid-x padding-bottom-m">
      <div class="cell splits-header">
        <h1>Splits</h1>
        <div class="view-toggle">
          <button
            class="view-btn"
            :class="{ active: !showChart }"
            title="Table View"
            data-testid="splits-view-table"
            @click="showChart = false"
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="20"
              height="20"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <line
                x1="3"
                y1="6"
                x2="21"
                y2="6"
              />
              <line
                x1="3"
                y1="12"
                x2="21"
                y2="12"
              />
              <line
                x1="3"
                y1="18"
                x2="21"
                y2="18"
              />
            </svg>
          </button>
          <button
            class="view-btn"
            :class="{ active: showChart }"
            title="Chart View"
            data-testid="splits-view-chart"
            @click="showChart = true"
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="20"
              height="20"
              viewBox="0 0 24 24"
              fill="none"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <path d="M3 3v18h18" />
              <path d="M18 17V9" />
              <path d="M13 17V5" />
              <path d="M8 17v-3" />
            </svg>
          </button>
        </div>
      </div>
    </div>
 
    <div
      class="filters-row padding-bottom-m"
      :class="{ 'no-border': showChart }"
    >
      <div class="filter-field">
        <label class="filter-label-custom">ENVIRONMENT</label>
        <EnvironmentDropdown
          ref="envDropdownRef"
          data-testid="splits-env-dropdown"
          @change="handleEnvironmentChange"
        />
      </div>
      <div class="filter-field">
        <label class="filter-label-custom required">SELECT EXPERIMENT</label>
        <SearchableSingleSelectFacet
          v-model="selectedExperiment"
          :options="experimentOptions"
          name="experiment-filter"
          placeholder="Select Experiment"
          search-placeholder="Search experiments..."
          empty-message="No experiments available"
          data-testid="splits-experiment-select"
        />
      </div>
 
      <div class="filter-field">
        <label class="filter-label-custom required">RECIPE ID</label>
        <MultiSelectFacet
          v-model="selectedRecipes"
          :options="recipesIds"
          name="recipe-filter"
          placeholder="Select recipes"
          empty-message="Select experiment first"
          display-format="inline"
          :show-count="false"
          :show-select-actions="true"
          data-testid="splits-recipe-select"
        />
      </div>
 
      <div class="filter-field">
        <label class="filter-label-custom required">DATE/DATE RANGE</label>
        <Calendar
          v-model="selectedDateRange"
          name="date-range-filter"
          selection-mode="range"
          placeholder="Select Date or Date Range"
          data-testid="splits-date-range"
        />
      </div>
 
      <div class="filter-field">
        <label
          class="filter-label-custom"
        >SPLIT BY <span class="optional-text">(optional)</span></label>
        <Button
          variant="secondary"
          data-testid="splits-split-by-btn"
          @click="openFilterDrawer"
        >
          Split By
          <span
            v-if="splitBySelectedCount > 0"
            class="filter-count-badge"
          >
            ({{ splitBySelectedCount }})
          </span>
        </Button>
      </div>
 
      <div class="filter-buttons">
        <Button
          variant="primary"
          :disabled="isSubmitDisabled"
          data-testid="splits-submit-btn"
          @click="handleSubmit"
        >
          Submit
        </Button>
        <Button
          variant="secondary"
          data-testid="splits-reset-btn"
          @click="resetFilters"
        >
          Reset
        </Button>
      </div>
    </div>
 
    <div
      v-if="error"
      class="grid-x"
    >
      <div class="cell">
        <div class="error-message padding-m text-center">
          {{ error }}
        </div>
      </div>
    </div>
 
    <template v-if="!error">
      <SplitsChart
        v-if="showChart && splitResults.length > 0"
        :split-results="splitResults"
        :recipe-weights="recipeWeights"
        :has-holdout="hasHoldout"
        class="margin-bottom-m"
        data-testid="splits-chart"
      />
 
      <TableSkeleton
        v-if="isLoading && !showChart"
        :rows="5"
        :columns="skeletonColumns"
      />
 
      <AppDataTable
        v-if="!isLoading && !showChart"
        :value="tableData"
        :columns="tableColumns"
        :sortable="true"
        :size="'small'"
        empty-message="No split results found. Try adjusting your filters."
        data-testid="splits-results-table"
      />
    </template>
 
    <FilterDrawer
      id="split-by-drawer"
      v-model="selectedSplitBy"
      title="Split By"
      :filter-sections="splitByFilterSections"
      @apply="handleFilterApply"
      @clear="handleFilterClear"
    />
  </div>
</template>
 
<script setup>
import Button from '@atomic-ui/button';
import Calendar from '@atomic-ui/calendar';
import $http from '@common-vue/util/src/modules/http';
import {
  computed, onMounted, ref, watch,
} from 'vue';
import { useRoute } from 'vue-router';
import { useStore } from 'vuex';
 
import AppDataTable from '../../../components/AppDataTable';
import EnvironmentDropdown from '../../../components/EnvironmentDropdown';
import FilterDrawer from '../../../components/FilterDrawer';
import MultiSelectFacet from '../../../components/MultiSelectFacet';
import SearchableSingleSelectFacet from '../../../components/SearchableSingleSelectFacet';
import TableSkeleton from '../../../components/TableSkeleton';
import { EXP_FQ, SPLITS_FQ } from '../../../store/types';
import { getDefaultEnvironment } from '../../../utils/environmentHelper';
import createLogger from '../../../utils/logger';
import SplitsChart from '../components/SplitsChart';
 
const log = createLogger('SplitsPage');
 
const store = useStore();
const route = useRoute();
const envDropdownRef = ref(null);
 
const loadExperimentIds = (env) => {
  store.dispatch(EXP_FQ.actions.loadIds, { api: $http, env });
};
 
const selectedExperiment = ref('');
const selectedRecipes = ref([]);
const today = new Date();
const selectedDateRange = ref([today, today]);
const showChart = ref(false);
const selectedSplitBy = ref({
  signedIn: 'both',
  adobeVisitorId: 'no',
});
const experimentDetails = ref(null);
const isLoadingExperiment = ref(false);
 
const availableExperimentsIds = computed(
  () => store.getters[EXP_FQ.getters.experimentsIds],
);
 
const recipesIds = computed(() => {
  if (!selectedExperiment.value) return [];
 
  const experiment = availableExperimentsIds.value.find(
    (exp) => exp.redisId === selectedExperiment.value,
  );
 
  return experiment?.recipes || [];
});
 
const splitResults = computed(
  () => store.getters[SPLITS_FQ.getters.splitResults],
);
 
const isLoading = computed(() => store.getters[SPLITS_FQ.getters.isLoading]);
const error = computed(() => store.getters[SPLITS_FQ.getters.error]);
 
const experimentOptions = computed(() => availableExperimentsIds.value.map((exp) => ({
  value: exp.redisId,
  displayValue: `${exp.id} - ${exp.name}`,
})));
 
const splitByFilterSections = ref([
  {
    name: 'osType',
    label: 'OS Type',
    type: 'single',
    options: [
      { value: 'Windows', displayValue: 'Windows', label: 'Windows' },
      { value: 'Mac OS', displayValue: 'Mac OS', label: 'Mac OS' },
      { value: 'iOS', displayValue: 'iOS', label: 'iOS' },
      { value: 'Linux', displayValue: 'Linux', label: 'Linux' },
      { value: 'Android', displayValue: 'Android', label: 'Android' },
    ],
  },
  {
    name: 'deviceType',
    label: 'Device Type',
    type: 'single',
    options: [
      { value: 'Phone', displayValue: 'Phone', label: 'Phone' },
      { value: 'PC', displayValue: 'PC', label: 'PC' },
      { value: 'Tablet', displayValue: 'Tablet', label: 'Tablet' },
    ],
  },
  {
    name: 'signedIn',
    label: 'Signed In',
    type: 'single',
    options: [
      { value: 'both', displayValue: 'Both', label: 'Both' },
      { value: 'yes', displayValue: 'Yes', label: 'Yes' },
      { value: 'no', displayValue: 'No', label: 'No' },
    ],
  },
  {
    name: 'adobeVisitorId',
    label: 'Adobe Visitor ID',
    type: 'single',
    options: [
      { value: 'no', displayValue: 'No', label: 'No' },
      { value: 'yes', displayValue: 'Yes', label: 'Yes' },
    ],
  },
  {
    name: 'path',
    label: 'Path',
    type: 'text',
    placeholder: 'Enter URL path (e.g., /home)',
  },
  {
    name: 'previousLocation',
    label: 'Previous Location',
    type: 'text',
    placeholder: 'Enter previous location URL',
  },
]);
 
const splitBySelectedCount = computed(() => {
  let count = 0;
  Object.entries(selectedSplitBy.value).forEach(([key, value]) => {
    if (key === 'signedIn' && value === 'both') return;
    if (key === 'adobeVisitorId' && value === 'no') return;
 
    if (Array.isArray(value)) {
      count += value.length;
    } else if (value) {
      count += 1;
    }
  });
  return count;
});
 
const isSubmitDisabled = computed(() => {
  const hasExperiment = !!selectedExperiment.value;
  const hasRecipes = selectedRecipes.value.length > 0;
  const hasValidDate = selectedDateRange.value
    && (Array.isArray(selectedDateRange.value)
      ? selectedDateRange.value[0] !== null
      : selectedDateRange.value !== null);
 
  return !hasExperiment || !hasRecipes || !hasValidDate;
});
 
watch(selectedExperiment, async (newExperimentId) => {
  selectedRecipes.value = [];
  experimentDetails.value = null;
 
  if (newExperimentId) {
    const currentEnv = envDropdownRef.value?.selectedEnvironment;
    isLoadingExperiment.value = true;
    try {
      const experiment = await store.dispatch(EXP_FQ.actions.loadSingle, {
        api: $http,
        id: newExperimentId,
        env: currentEnv,
      });
      experimentDetails.value = experiment;
    } catch (e) {
      log.error('Failed to load experiment details:', e);
    } finally {
      isLoadingExperiment.value = false;
    }
  }
});
 
const treatmentIds = computed(() => {
  if (!experimentDetails.value?.recipes) return [];
  return experimentDetails.value.recipes
    .filter((recipe) => recipe.recipeType?.toLowerCase() === 'treatment')
    .map((recipe) => recipe.id);
});
 
const recipeWeights = computed(() => {
  const weights = {
    control: { weight: null, id: null },
    holdout: { weight: null, id: null },
    treatments: {},
  };
 
  if (!experimentDetails.value?.recipes) return weights;
 
  experimentDetails.value.recipes.forEach((recipe) => {
    const recipeType = recipe.recipeType?.toLowerCase();
    if (recipeType === 'control') {
      weights.control = { weight: recipe.weight, id: recipe.id };
    } else if (recipeType === 'controlholdout') {
      weights.holdout = { weight: recipe.weight, id: recipe.id };
    } else if (recipeType === 'treatment') {
      weights.treatments[recipe.id] = recipe.weight;
    }
  });
 
  return weights;
});
 
const skeletonColumns = [
  { field: 'transactionDate', header: 'Transaction Date' },
  { field: 'distinctSeedCount', header: 'Distinct Seed' },
  { field: 'controlCount', header: 'Control' },
  { field: 'holdoutCount', header: 'Holdout' },
  { field: 'controlPercentage', header: 'Control' },
  { field: 'holdoutPercentage', header: 'Holdout' },
];
 
const hasHoldout = computed(() => {
  const hasHoldoutData = splitResults.value.some(
    (r) => r.holdoutCount !== undefined
      && r.holdoutCount !== null
      && r.holdoutCount > 0,
  );
 
  const hasHoldoutRecipe = experimentDetails.value?.recipes?.some(
    (recipe) => recipe.recipeType?.toLowerCase() === 'controlholdout',
  );
 
  return hasHoldoutData || hasHoldoutRecipe;
});
 
const tableColumns = computed(() => {
  const { control, holdout, treatments } = recipeWeights.value;
 
  const controlCountHeader = control.id ? `Control (${control.id})` : 'Control';
  const holdoutCountHeader = holdout.id ? `Holdout (${holdout.id})` : 'Holdout';
  const controlPercentHeader = control.weight !== null && control.id
    ? `Control ${control.weight}% (${control.id})`
    : 'Control';
  const holdoutPercentHeader = holdout.weight !== null && holdout.id
    ? `Holdout ${holdout.weight}% (${holdout.id})`
    : 'Holdout';
 
  const baseColumns = [
    {
      field: 'transactionDate',
      header: 'Transaction Date',
      dataType: 'date',
    },
    { field: 'distinctSeedCount', header: 'Distinct Seed' },
    { field: 'controlCount', header: controlCountHeader },
  ];
 
  if (hasHoldout.value) {
    baseColumns.push({ field: 'holdoutCount', header: holdoutCountHeader });
  }
 
  const treatmentCountColumns = treatmentIds.value.map((id) => ({
    field: `treatment_${id}`,
    header: `Treatment (${id})`,
  }));
 
  const percentageColumns = [
    { field: 'controlPercentage', header: controlPercentHeader },
  ];
 
  if (hasHoldout.value) {
    percentageColumns.push({
      field: 'holdoutPercentage',
      header: holdoutPercentHeader,
    });
  }
 
  const treatmentPercentageColumns = treatmentIds.value.map((id) => {
    const weight = treatments[id];
    const header = weight !== undefined
      ? `Treatment ${weight}% (${id})`
      : `Treatment (${id})`;
    return { field: `treatmentPercentage_${id}`, header };
  });
 
  return [
    ...baseColumns,
    ...treatmentCountColumns,
    ...percentageColumns,
    ...treatmentPercentageColumns,
  ];
});
 
const tableData = computed(() => splitResults.value.map((result) => {
  const row = {
    transactionDate: result.transactionDate,
    distinctSeedCount: result.distinctSeedCount?.toLocaleString() || '-',
    controlCount: result.controlCount?.toLocaleString() || '-',
    holdoutCount: result.holdoutCount?.toLocaleString() || '-',
    controlPercentage: result.controlPercentage?.toFixed(2) || '-',
    holdoutPercentage: result.holdoutPercentage?.toFixed(2) || '-',
  };
 
  treatmentIds.value.forEach((id) => {
    row[`treatment_${id}`] = result.treatments[id]?.toLocaleString() || '-';
  });
 
  treatmentIds.value.forEach((id) => {
    row[`treatmentPercentage_${id}`] = result.treatmentsPercentage[id]?.toFixed(2) || '-';
  });
 
  return row;
}));
 
function formatDate(date) {
  Iif (!date) return null;
  const d = new Date(date);
  const year = d.getFullYear();
  const month = String(d.getMonth() + 1).padStart(2, '0');
  const day = String(d.getDate()).padStart(2, '0');
  return `${year}-${month}-${day}`;
}
 
async function handleSubmit() {
  log.info('Submit clicked');
  log.info('Selected Experiment:', selectedExperiment.value);
  log.info('Selected Recipes:', selectedRecipes.value);
  log.info('Selected Date Range:', selectedDateRange.value);
  log.info('Selected Split By:', selectedSplitBy.value);
 
  if (!selectedRecipes.value.length) {
    log.warn('No recipes selected');
    return;
  }
 
  const recipes = selectedRecipes.value.join(',');
 
  let startDate = null;
  let endDate = null;
 
  if (selectedDateRange.value) {
    if (Array.isArray(selectedDateRange.value)) {
      startDate = formatDate(selectedDateRange.value[0]);
      endDate = formatDate(selectedDateRange.value[1]);
    } else {
      startDate = formatDate(selectedDateRange.value);
      endDate = startDate;
    }
  }
 
  const currentEnv = envDropdownRef.value?.selectedEnvironment;
  const filters = {
    env: currentEnv,
    recipes,
    ...(startDate && { startDate }),
    ...(endDate && { endDate }),
  };
 
  Object.entries(selectedSplitBy.value).forEach(([key, value]) => {
    if (!value || value === '') return;
 
    if (key === 'signedIn') {
      if (value === 'yes') filters.signedIn = true;
      else if (value === 'no') filters.signedIn = false;
      else if (value === 'both') filters.signedIn = null;
    } else if (key === 'adobeVisitorId') {
      filters.adobeVisitorId = value === 'yes';
    } else {
      filters[key] = value;
    }
  });
 
  log.info('Calling API with filters:', filters);
 
  await store.dispatch(SPLITS_FQ.actions.fetchSplitResults, {
    api: $http,
    filters,
  });
}
 
async function resetFilters() {
  selectedExperiment.value = '';
  selectedRecipes.value = [];
  const resetDate = new Date();
  selectedDateRange.value = [resetDate, resetDate];
  selectedSplitBy.value = {
    signedIn: 'both',
    adobeVisitorId: 'no',
  };
 
  const currentEnv = envDropdownRef.value?.selectedEnvironment;
  await store.dispatch(SPLITS_FQ.actions.fetchSplitResults, {
    api: $http,
    filters: { env: currentEnv, recipes: '' },
  });
}
 
function handleEnvironmentChange(newEnv) {
  log.info(`Environment changed to: ${newEnv}`);
  loadExperimentIds(newEnv);
}
 
function openFilterDrawer() {
  store.commit('slideoutStore/TOGGLE', 'split-by-drawer');
}
 
function handleFilterApply(filters) {
  selectedSplitBy.value = { ...filters };
}
 
function handleFilterClear() {
  selectedSplitBy.value = {
    signedIn: 'both',
    adobeVisitorId: 'no',
  };
}
 
onMounted(async () => {
  const env = route.query.env || getDefaultEnvironment();
  await Promise.all([
    store.dispatch(SPLITS_FQ.actions.load, { api: $http }),
    loadExperimentIds(env),
  ]);
});
</script>
 
<style lang="scss" scoped>
$filter-input-height: 40px;
$filter-border-color: #ced4da;
$filter-focus-color: #0066cc;
 
.splits-header {
  display: flex;
  align-items: center;
  gap: 12px;
 
  h1 {
    margin: 0;
  }
}
 
.view-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
 
.view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid $filter-border-color;
  border-radius: 4px;
  background-color: $white;
  cursor: pointer;
  transition: all 0.2s ease;
  color: $gray-1-color;
 
  svg {
    stroke: currentColor;
  }
 
  &:hover {
    border-color: $filter-focus-color;
    color: $filter-focus-color;
  }
 
  &.active {
    border-color: $filter-focus-color;
    background-color: rgba(0, 102, 204, 0.1);
    color: $filter-focus-color;
  }
}
 
.filters-row {
  display: flex;
  align-items: stretch;
  gap: 16px;
  border-bottom: $gray-3-border;
  background-color: $white;
  position: sticky;
  top: 0;
  z-index: 100;
  padding-top: rem-calc(12);
 
  &.no-border {
    border-bottom: none;
  }
}
 
.filter-field {
  flex: 1 1 0%;
  min-width: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
 
  > *:not(.filter-label-custom) {
    margin-top: auto;
  }
 
  :deep(.env-selector-section) {
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
 
    .env-dropdown-skeleton .dropdown-label,
    .env-dropdown .dropdown-label,
    .env-dropdown .label-lg,
    .env-dropdown .select-label-top {
      display: none !important;
    }
 
    .env-dropdown {
      margin: 0 !important;
      padding: 0 !important;
    }
  }
 
  :deep(.select-container) {
    width: 100%;
    position: relative;
    margin: 0 !important;
    padding: 0 !important;
 
    .label-lg,
    .select-label-top {
      display: none !important;
    }
 
    select {
      height: $filter-input-height;
      box-sizing: border-box;
      width: 100%;
      border: 1px solid $filter-border-color;
      border-radius: 4px;
      font-size: 14px;
      padding: 0.5rem 2rem 0.5rem 0.75rem;
 
      &:hover {
        border-color: $filter-focus-color;
      }
 
      &:focus {
        border-color: $filter-focus-color;
        box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
        outline: none;
      }
    }
  }
 
  :deep(.input-container) {
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
 
    .p-calendar {
      width: 100%;
      border: none !important;
      position: relative;
      margin: 0 !important;
      padding: 0 !important;
 
      &::after {
        display: none !important;
        content: none !important;
      }
 
      &.p-inputwrapper-filled::after {
        display: none !important;
        content: none !important;
      }
 
      fieldset {
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        min-width: 0 !important;
 
        legend {
          display: none !important;
        }
      }
 
      .p-inputtext {
        height: $filter-input-height !important;
        width: 100% !important;
        box-sizing: border-box;
        border: 1px solid $filter-border-color !important;
        border-radius: 4px !important;
        padding: 0.5rem 2.5rem 0.5rem 0.75rem !important;
        font-size: 14px !important;
 
        &:hover {
          border-color: $filter-focus-color !important;
        }
 
        &:focus {
          border-color: $filter-focus-color !important;
          box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
          outline: none;
        }
      }
 
      .p-datepicker-trigger {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        background: transparent !important;
        border: none !important;
        color: $gray-1-color;
      }
    }
  }
 
  :deep(.facet-container) {
    width: 100%;
    display: block;
    row-gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
 
  :deep(.csg-horizontal-facet-cont) {
    width: 100%;
    display: block;
    margin: 0 !important;
    padding: 0 !important;
  }
 
  :deep(.csg-horizontal-facet) {
    width: 100%;
    height: $filter-input-height !important;
    min-height: $filter-input-height !important;
    border: 1px solid $filter-border-color !important;
    border-radius: 4px !important;
    background-color: $white !important;
    padding: 0 12px !important;
    font-size: 14px !important;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-right: 0 !important;
    overflow: hidden;
 
    > *:first-child {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      min-width: 0;
      flex: 1;
    }
 
    &:hover {
      border-color: $filter-focus-color !important;
    }
 
    &.selected {
      border-color: $filter-focus-color !important;
    }
  }
 
  :deep(button.button) {
    width: 100%;
    height: $filter-input-height;
    min-height: $filter-input-height;
  }
}
 
.filter-label-custom {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: $black;
  margin-bottom: 8px;
  line-height: 1;
  min-height: 13px;
 
  &.required::after {
    content: ' *';
    color: #d32f2f;
  }
 
  .optional-text {
    font-weight: 400;
    color: $gray-1-color;
    text-transform: lowercase;
  }
}
 
.filter-buttons {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  align-items: flex-end;
 
  :deep(button) {
    height: $filter-input-height;
    white-space: nowrap;
    padding-left: 24px;
    padding-right: 24px;
  }
}
 
.error-message {
  color: $error-color;
  background: $accent1-color;
  border: 1px solid $error-color;
  border-radius: 4px;
}
 
.filter-count-badge {
  margin-left: 4px;
  font-weight: 600;
}
</style>