/* ==========================================================================
   Plugin-scoped CSS variable fallbacks
   These mirror the AmeraLabs Bricks theme tokens. When the theme is active
   its :root values take precedence; these fallbacks make the plugin portable.
   ========================================================================== */
:root {
  /* Fallbacks — only apply when the Bricks theme variables are not defined */
  --color-blue-900:   #182230;
  --color-blue-500:   #0077e7;
  --color-grey-700:   #82838e;
  --color-grey-500:   #9c9c9c;
  --color-grey-400:   #d0d5dd;
  --color-grey-300:   #eff0f7;
  --color-grey-100:   #f5f7fd;
  --color-white:      #ffffff;
  --radius-s:         6px;
  --text-m:           1.5rem;
}

/* Plugin-only tokens derived from theme variables */
.settings-3d-filter-section {
  --3dps-focus-color:    var(--color-blue-500);
  --3dps-focus-shadow:   rgba(0, 119, 231, 0.15);
  --3dps-border-hover:   var(--color-grey-700);
  --3dps-disabled-bg:    var(--color-grey-300);
  --3dps-disabled-color: var(--color-grey-500);
  --3dps-highlight-bg:   rgba(0, 119, 231, 0.08);
}

/* ==========================================================================
   Tabulator pagination size fix
   ========================================================================== */
.tabulator-page-size {
  width: 70px !important;
  height: 45px !important;
  text-align: left;
  padding: 0 8px !important;
}

/* ==========================================================================
   Filter section
   ========================================================================== */
.settings-3d-filter-section {
  border-radius: var(--radius-s);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.settings-3d-filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4rem;
  flex-wrap: wrap;
  gap: 12px;
}

.settings-3d-filter-title {
  display: flex;
  flex-direction: column;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-blue-900);
  margin: 0;
  gap: 0.5rem;
}

.settings-3d-search-container {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
  max-width: 400px;
}

.settings-3d-search-input {
  height: 45px;
  padding: 0 12px;
  border: 1px solid var(--color-grey-400);
  border-radius: var(--radius-s);
  transition: all 0.2s ease;
  flex: 1;
  background: var(--color-white);
  color: var(--color-blue-900);
  font-size: inherit;
  font-family: inherit;
}

.settings-3d-search-input::placeholder {
  color: var(--color-blue-900);
  opacity: 0.6;
}

.settings-3d-search-input:focus {
  outline: none;
  border-color: var(--3dps-focus-color);
  box-shadow: 0 0 0 3px var(--3dps-focus-shadow);
}

.settings-3d-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.settings-3d-filter-item {
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Remove old custom arrow — Choices.js has its own */
.settings-3d-filter-item::after {
  display: none !important;
}

.settings-3d-filter-label {
  text-transform: capitalize;
  color: var(--color-blue-900);
  font-size: var(--text-m);
  font-weight: 500;
  margin-bottom: 6px;
}

/* ==========================================================================
   Choices.js overrides
   ========================================================================== */

.settings-3d-filter-item .choices {
  width: 100%;
  margin-bottom: 0;
}

.settings-3d-filter-item .choices__inner {
  min-height: 45px;
  padding: 0 40px 0 12px;
  border: 1px solid var(--color-grey-400);
  border-radius: var(--radius-s);
  background-color: var(--color-white);
  font-size: inherit;
  font-family: inherit;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.settings-3d-filter-item .choices__inner:hover {
  border-color: var(--3dps-border-hover);
}

.settings-3d-filter-item .choices.is-open .choices__inner,
.settings-3d-filter-item .choices.is-focused .choices__inner {
  border-color: var(--3dps-focus-color);
  box-shadow: 0 0 0 3px var(--3dps-focus-shadow);
  outline: none;
}

.settings-3d-filter-item .choices__list--single {
  padding: 0;
  line-height: 43px;
}

.settings-3d-filter-item .choices__list--single .choices__item {
  color: var(--color-blue-900);
  font-size: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-3d-filter-item .choices__placeholder {
  color: var(--color-blue-900);
  opacity: 0.6;
}

/* Hide Choices default arrow */
.settings-3d-filter-item .choices__inner::after,
.settings-3d-filter-item .choices[data-type*=select-one]::after {
  display: none !important;
}

.settings-3d-filter-item .choices[data-type*=select-one] .choices__button {
  display: none;
}

/* Our single chevron */
.settings-3d-filter-item .choices[data-type*=select-one] {
  position: relative;
}

.settings-3d-filter-item .choices[data-type*=select-one] .choices__inner {
  padding-right: 40px;
}

.settings-3d-filter-item .choices[data-type*=select-one]::before {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--color-blue-900);
  background: currentColor;
  pointer-events: none;
  z-index: 2;
  transition: transform 0.25s ease-in-out;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='black' fill-rule='evenodd' clip-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='black' fill-rule='evenodd' clip-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.settings-3d-filter-item .choices.is-open[data-type*=select-one]::before {
  transform: translateY(-50%) rotate(180deg);
}

/* Disabled state */
.settings-3d-filter-item .choices.is-disabled .choices__inner {
  background: var(--3dps-disabled-bg);
  opacity: 0.6;
  cursor: not-allowed;
}

.settings-3d-filter-item .choices.is-disabled[data-type*=select-one]::before {
  color: var(--3dps-disabled-color);
}

/* Dropdown */
.settings-3d-filter-item .choices__list--dropdown,
.settings-3d-filter-item .choices__list[aria-expanded] {
  border: 1px solid var(--color-grey-400);
  border-radius: var(--radius-s);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  background: var(--color-white);
}

.settings-3d-filter-item .choices__list--dropdown .choices__input,
.settings-3d-filter-item .choices__list[aria-expanded] .choices__input {
  border-bottom: 1px solid var(--color-grey-400);
  padding: 8px 12px;
  font-size: inherit;
  font-family: inherit;
  background: var(--color-white);
  color: var(--color-blue-900);
}

.settings-3d-filter-item .choices__list--dropdown .choices__input:focus {
  outline: none;
}

.settings-3d-filter-item .choices__list--dropdown .choices__item,
.settings-3d-filter-item .choices__list[aria-expanded] .choices__item {
  padding: 8px 12px;
  font-size: inherit;
  color: var(--color-blue-900);
}

.settings-3d-filter-item .choices__list--dropdown .choices__item--selectable.is-highlighted,
.settings-3d-filter-item .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
  background-color: var(--3dps-highlight-bg);
  color: var(--color-blue-900);
}

/* ==========================================================================
   Tabulator overrides
   ========================================================================== */

.ui.button {
  margin: 0 !important;
}

.tabulator .tabulator-header .tabulator-col {
  background-color: var(--color-grey-100);
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
  color: var(--color-blue-900);
  font-weight: 500;
}

.tabulator .tabulator-footer .tabulator-page-counter {
  font-size: 1.4rem;
}

.tabulator .tabulator-footer .tabulator-footer-contents {
  flex-wrap: wrap;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.settings-3d-button-container {
  display: flex;
  gap: 1.5rem;
  justify-content: right;
  margin-top: 3rem;
}

#download-profile,
#settings-3d-reset-filters {
  padding: 0;
}

#download-profile {
  font: inherit;
  color: var(--color-blue-700);
  font-weight: 700;
  background: transparent;
}

#download-profile:hover {
  color: var(--color-blue-500);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
  .tabulator-paginator label,
  .tabulator-paginator select {
    display: block !important;
    width: 100%;
    margin-bottom: 1rem !important;
    margin-left: auto !important;
  }
}

@media (max-width: 768px) {
  .settings-3d-filter-header {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-3d-search-container {
    max-width: 100%;
  }
}

/* -------------------------------------------------------------------------
   Theme-independent baseline styles (v1.2.0)
   Provide sane defaults so the plugin is usable without the Bricks theme.
   ------------------------------------------------------------------------- */
.tdps-button[hidden]{display:none !important;}
.tdps-button{display:inline-block;padding:10px 18px;font-size:14px;line-height:1.2;border-radius:6px;border:1px solid transparent;cursor:pointer;text-decoration:none;transition:background .15s ease,border-color .15s ease,color .15s ease;}
.tdps-button:disabled{opacity:.6;cursor:default;}
.tdps-button-secondary{background:transparent;color:#d33;border-color:#d33;}
.tdps-button-secondary:hover:not(:disabled){color:#ff8d8d;}
.tdps-admin-notice{color:#b32d2e;font-weight:600;}
.tdps-filter-hint{color:#999;font-size:12px;font-weight:400;}