/* ===================================
   FILTER STYLES
   =================================== */

/* Filters Wrapper */
.filters-wrapper {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--brand-shadow);
}

.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.filters-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
}

/* Filter Grid */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.filter-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.filter-icon {
  font-size: 16px;
}

/* Filter Select */
.filter-select {
  width: 100%;
  padding: 10px 12px;
  background: #1a1c27;
  border: 2px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e8ebf0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.filter-select:hover {
  border-color: rgba(255, 255, 255, .2);
  background-color: #1f2130;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  background-color: #1f2130;
  box-shadow: 0 0 0 3px rgba(255, 210, 77, 0.15);
}

.filter-select option {
  background: #1a1c27;
  color: var(--text);
  padding: 8px;
}

/* Filter Input */
.filter-input {
  width: 100%;
  padding: 10px 12px;
  background: #1a1c27;
  border: 2px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.filter-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.filter-input:hover {
  border-color: rgba(255, 255, 255, .2);
  background-color: #1f2130;
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  background-color: #1f2130;
  box-shadow: 0 0 0 3px rgba(255, 210, 77, 0.15);
}

/* Filter Count Badge */
.filter-count {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--accent);
  color: #121212;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  display: none;
}

/* Filter Results */
.filter-results {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.results-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.results-count {
  font-size: 14px;
  color: var(--muted);
}

.results-count strong {
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
}

/* Active Filters */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 210, 77, 0.15);
  border: 1px solid rgba(255, 210, 77, 0.3);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  transition: all 0.2s;
  animation: chipIn 0.2s ease;
}

@keyframes chipIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.filter-chip .chip-label {
  color: var(--muted);
  font-weight: 600;
}

.filter-chip .chip-value {
  color: var(--accent);
  font-weight: 700;
}

.filter-chip .remove {
  all: unset;
  cursor: pointer;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s;
  color: var(--text);
  margin-left: 2px;
}

.filter-chip .remove:hover {
  background: rgba(255, 68, 68, 0.8);
  color: white;
  transform: rotate(90deg);
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 60px 20px;
}

.spinner {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, .1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

/* No Results State */
.no-results {
  text-align: center;
  padding: 80px 20px;
}

.no-results-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.no-results h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.no-results p {
  margin: 0 0 24px;
  font-size: 14px;
}

/* Error State */
.error-state {
  text-align: center;
  padding: 80px 20px;
}

.error-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.error-state h3 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #ff6b6b;
}

.error-state p {
  margin: 0 0 24px;
  font-size: 14px;
}

/* Enhanced Installer Table with State and Pincode */
.installer-table th:nth-child(6),
.installer-table td:nth-child(6) {
  min-width: 100px;
}

.installer-table th:nth-child(7),
.installer-table td:nth-child(7) {
  min-width: 90px;
}

/* Pill for Pincode */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 225, 255, 0.15);
  border: 1px solid rgba(0, 225, 255, 0.3);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-2);
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
  .filters-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .filters-grid {
    grid-template-columns: 1fr;
  }

  .filters-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .results-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .active-filters {
    width: 100%;
  }

  /* Scroll table horizontally on mobile */
  .installer-brand-body {
    overflow-x: auto;
  }

  .installer-table {
    min-width: 900px;
  }
}

@media (max-width: 500px) {
  .filters-wrapper {
    padding: 16px;
  }

  .filter-select,
  .filter-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .no-results,
  .error-state {
    padding: 60px 16px;
  }

  .no-results-icon,
  .error-icon {
    font-size: 48px;
  }
}

/* Smooth Transitions */
.installer-brand-block {
  transition: all 0.3s ease;
}

.filter-select,
.filter-input,
.btn {
  transition: all 0.2s ease;
}

/* Focus Visible for Accessibility */
.filter-select:focus-visible,
.filter-input:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Improve table readability */
.installer-table tbody tr {
  transition: background 0.2s ease;
}

.installer-table tbody tr:hover {
  background: rgba(255, 210, 77, 0.05);
}

/* Loading Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.installer-brand-block {
  animation: fadeIn 0.3s ease;
}

/* Empty state improvements */
.filters-wrapper:empty {
  display: none;
}

/* Hover effects for better UX */
.filter-chip {
  cursor: default;
}

.filter-chip:hover {
  background: rgba(255, 210, 77, 0.25);
  border-color: rgba(255, 210, 77, 0.5);
}

/* Loading skeleton (optional enhancement) */
.loading-skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}