/**
 * React Power Table - Advanced Filter Panel Styles
 * Redesigned for optimal UX and responsiveness
 */

/* Main filter panel container */
.rpt-advanced-filter-panel {
  width: 100%;
  border: 1px solid var(--rpt-border-color);
  border-radius: var(--rpt-border-radius);
  background-color: var(--rpt-bg-color);
  overflow: hidden;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s ease;
}

.rpt-advanced-filter-panel:hover {
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Panel header with toggle */
.rpt-filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background-color: var(--rpt-header-bg);
  border-bottom: 1px solid var(--rpt-border-color);
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color var(--rpt-transition-duration) ease;
}

.rpt-filter-panel-header:hover {
  background-color: var(--rpt-row-hover-bg);
}

.rpt-filter-panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--rpt-text-color);
}

.rpt-filter-panel-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
}

.rpt-chevron {
  transition: transform var(--rpt-transition-duration) ease;
}

.rpt-chevron-up {
  transform: rotate(180deg);
}

/* Panel content */
.rpt-filter-panel-content {
  padding: 1rem;
  animation: rpt-slide-down 0.2s ease-out;
  max-height: 70vh;
  overflow-y: auto;
}

/* Filter presets section */
.rpt-filter-presets {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background-color: var(--rpt-row-hover-bg);
  border-radius: var(--rpt-border-radius);
  border: 1px solid var(--rpt-border-color);
}

.rpt-presets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.rpt-presets-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--rpt-text-color);
  margin: 0;
}

.rpt-presets-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.rpt-preset-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  position: relative;
  max-width: 100%;
}

.rpt-preset-btn {
  display: flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  background-color: var(--rpt-bg-color);
  border: 1px solid var(--rpt-border-color);
  border-radius: var(--rpt-border-radius);
  font-size: 0.75rem;
  color: var(--rpt-text-color);
  cursor: pointer;
  transition: all var(--rpt-transition-duration) ease;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpt-preset-btn:hover {
  border-color: var(--rpt-primary-light);
  background-color: var(--rpt-primary-bg);
}

.rpt-preset-active {
  background-color: var(--rpt-primary);
  color: white;
  border-color: var(--rpt-primary);
}

.rpt-preset-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rpt-preset-delete {
  width: 16px;
  height: 16px;
  min-width: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--rpt-muted-color);
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  margin-left: 4px;
  transition: all var(--rpt-transition-duration) ease;
}

.rpt-preset-delete:hover {
  color: var(--rpt-danger);
  background-color: var(--rpt-danger-bg);
}

/* Save preset section */
.rpt-preset-save {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.rpt-preset-name-input {
  flex: 1;
  height: 32px;
  padding: 0 0.75rem;
  border: 1px solid var(--rpt-border-color);
  border-radius: var(--rpt-border-radius);
  font-size: 0.75rem;
  background-color: var(--rpt-input-bg);
  color: var(--rpt-input-text);
  min-width: 0;
}

.rpt-preset-save-btn {
  padding: 0 0.75rem;
  height: 32px;
  background-color: var(--rpt-primary);
  border: none;
  border-radius: var(--rpt-border-radius);
  color: white;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color var(--rpt-transition-duration) ease,
              opacity var(--rpt-transition-duration) ease;
  white-space: nowrap;
}

.rpt-preset-save-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.rpt-preset-save-btn:not(:disabled):hover {
  background-color: var(--rpt-primary-dark);
}

/* Filter search field */
.rpt-filter-search {
  position: relative;
  margin-bottom: 1rem;
}

.rpt-filter-search-input {
  width: 100%;
  height: 36px;
  padding: 0 0.75rem 0 2.25rem;
  border-radius: var(--rpt-border-radius);
  border: 1px solid var(--rpt-border-color);
  background-color: var(--rpt-input-bg);
  color: var(--rpt-input-text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--rpt-transition-duration) ease,
              box-shadow var(--rpt-transition-duration) ease;
}

.rpt-filter-search-input:focus {
  border-color: var(--rpt-primary);
  box-shadow: 0 0 0 2px var(--rpt-primary-light);
}

.rpt-filter-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--rpt-text-secondary);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

/* Active filters section */
.rpt-filters-main {
  margin-bottom: 1rem;
}

.rpt-filters-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.rpt-filters-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--rpt-text-color);
  margin: 0;
}

.rpt-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.rpt-filter-item {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  border: 1px solid var(--rpt-border-color);
  border-radius: var(--rpt-border-radius);
  background-color: var(--rpt-bg-color);
  position: relative;
}

.rpt-filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.rpt-filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--rpt-text-color);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
}

.rpt-filter-remove {
  background: none;
  border: none;
  color: var(--rpt-muted-color);
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--rpt-transition-duration) ease;
}

.rpt-filter-remove:hover {
  color: var(--rpt-danger);
  background-color: var(--rpt-danger-bg);
}

.rpt-filter-control {
  position: relative;
}

.rpt-filter-input {
  width: 100%;
  height: 32px;
  padding: 0 0.5rem;
  border: 1px solid var(--rpt-border-color);
  border-radius: var(--rpt-border-radius);
  background-color: var(--rpt-input-bg);
  color: var(--rpt-input-text);
  font-size: 0.75rem;
  transition: border-color var(--rpt-transition-duration) ease,
              box-shadow var(--rpt-transition-duration) ease;
}

.rpt-filter-input:focus {
  border-color: var(--rpt-primary);
  outline: none;
  box-shadow: 0 0 0 1px var(--rpt-primary-light);
}

.rpt-filter-select {
  padding-right: 1.5rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 16px 12px;
  appearance: none;
}

/* Range inputs for number and date */
.rpt-filter-range {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.rpt-filter-range-input {
  flex: 1;
  min-width: 0;
}

.rpt-filter-range-separator {
  color: var(--rpt-text-color);
  line-height: 1;
  flex-shrink: 0;
}

/* Clear filter button */
.rpt-filter-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--rpt-muted-color);
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--rpt-transition-duration) ease;
}

.rpt-filter-clear:hover {
  color: var(--rpt-danger);
  background-color: var(--rpt-danger-bg);
}

/* Empty filter state */
.rpt-filters-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--rpt-muted-color);
  font-size: 0.875rem;
  background-color: var(--rpt-row-hover-bg);
  border-radius: var(--rpt-border-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.rpt-empty-filter-icon {
  width: 32px;
  height: 32px;
  color: var(--rpt-muted-color);
  opacity: 0.5;
}

/* Advanced filter control: filter groups */
.rpt-filter-groups {
  margin-top: 1.5rem;
}

.rpt-filter-group {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--rpt-border-color);
  border-radius: var(--rpt-border-radius);
  background-color: var(--rpt-row-hover-bg);
}

.rpt-filter-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.rpt-group-operator-select {
  padding: 0.25rem 0.5rem;
  border-radius: var(--rpt-border-radius);
  border: 1px solid var(--rpt-border-color);
  background-color: var(--rpt-input-bg);
  font-size: 0.75rem;
  height: 28px;
}

.rpt-group-remove {
  padding: 0.25rem 0.5rem;
  border: none;
  background-color: var(--rpt-danger-bg);
  color: var(--rpt-danger);
  border-radius: var(--rpt-border-radius);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--rpt-transition-duration) ease;
  height: 28px;
  display: flex;
  align-items: center;
}

.rpt-group-remove:hover {
  background-color: var(--rpt-danger);
  color: white;
}

.rpt-filter-group-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

/* Action buttons */
.rpt-filters-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rpt-add-group-btn {
  padding: 0.5rem 1rem;
  background-color: var(--rpt-bg-color);
  border: 1px dashed var(--rpt-border-color);
  border-radius: var(--rpt-border-radius);
  color: var(--rpt-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--rpt-transition-duration) ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
}

.rpt-add-group-btn:hover {
  background-color: var(--rpt-primary-bg);
  border-color: var(--rpt-primary-light);
}

.rpt-clear-filters-btn {
  padding: 0.5rem 1rem;
  background-color: var(--rpt-danger-bg);
  border: none;
  border-radius: var(--rpt-border-radius);
  color: var(--rpt-danger);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--rpt-transition-duration) ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.rpt-clear-filters-btn:hover {
  background-color: var(--rpt-danger);
  color: white;
}

/* Status badges for filter condition */
.rpt-filter-condition-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  background: var(--rpt-primary-bg);
  color: var(--rpt-primary);
  margin-left: auto;
}

/* Animations */
@keyframes rpt-slide-down {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Badge for filter count */
.rpt-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  height: 18px;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 9999px;
  background-color: var(--rpt-primary);
  color: white;
  margin-left: 0.5rem;
}

/* Responsive styles */
@media (max-width: 768px) {
  .rpt-filter-panel-content {
    padding: 0.75rem;
  }

  .rpt-filters-grid {
    grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
  }

  .rpt-filter-group-filters {
    grid-template-columns: 1fr;
  }

  .rpt-preset-save {
    flex-direction: column;
  }

  .rpt-preset-name-input {
    width: 100%;
  }

  .rpt-preset-save-btn {
    width: 100%;
  }
}

/* Better tablet UI */
@media (min-width: 769px) and (max-width: 1024px) {
  .rpt-filters-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
  
  .rpt-filter-group-filters {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (orientation: landscape) {
  .rpt-filter-panel-content {
    max-height: 80vh;
  }
  
  .rpt-filters-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}