/**
 * AR Edilizia - Modern Category Filters
 * Ultra-modern filter pills with advanced interactions
 * Version: 1.0
 */

/* ============================================
   FILTER SECTION - Ultra Modern
   ============================================ */

.services-filter-section {
  position: sticky;
  top: 80px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: slide-down 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

[data-theme="dark"] .services-filter-section {
  background: rgba(15, 23, 42, 0.98);
  border-bottom-color: rgba(51, 65, 85, 0.8);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

/* Scrolled state */
.services-filter-section.scrolled {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(30px) saturate(200%);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .services-filter-section.scrolled {
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.services-filter-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
}

/* ============================================
   FILTER HEADER - With Search
   ============================================ */

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.filter-header__label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  min-width: fit-content;
}

[data-theme="dark"] .filter-header__label {
  color: #94a3b8;
}

.filter-header__label svg {
  width: 20px;
  height: 20px;
  color: #3b82f6;
}

/* Search Input - Compact */
.filter-search {
  position: relative;
  max-width: 300px;
  flex: 1;
}

.filter-search__input {
  width: 100%;
  padding: 10px 16px 10px 44px;
  background: #f8fafc;
  border: 2px solid transparent;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .filter-search__input {
  background: #1e293b;
  color: #f8fafc;
}

.filter-search__input:focus {
  outline: none;
  background: white;
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

[data-theme="dark"] .filter-search__input:focus {
  background: #334155;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.filter-search__input::placeholder {
  color: #94a3b8;
}

.filter-search__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #94a3b8;
  pointer-events: none;
  transition: color 0.3s ease;
}

.filter-search__input:focus ~ .filter-search__icon {
  color: #3b82f6;
}

/* Clear button */
.filter-search__clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

[data-theme="dark"] .filter-search__clear {
  background: #475569;
}

.filter-search__clear.visible {
  opacity: 1;
  pointer-events: all;
}

.filter-search__clear:hover {
  background: #cbd5e1;
  transform: translateY(-50%) scale(1.1);
}

[data-theme="dark"] .filter-search__clear:hover {
  background: #64748b;
}

.filter-search__clear svg {
  width: 14px;
  height: 14px;
  color: #64748b;
}

/* ============================================
   CATEGORY PILLS - Ultra Modern Design
   ============================================ */

.category-pills {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 0;
  position: relative;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

/* Gradient fade edges */
.category-pills::before,
.category-pills::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.category-pills::before {
  left: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.98) 0%, transparent 100%);
}

.category-pills::after {
  right: 0;
  background: linear-gradient(-90deg, rgba(255, 255, 255, 0.98) 0%, transparent 100%);
}

[data-theme="dark"] .category-pills::before {
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.98) 0%, transparent 100%);
}

[data-theme="dark"] .category-pills::after {
  background: linear-gradient(-90deg, rgba(15, 23, 42, 0.98) 0%, transparent 100%);
}

.category-pills.scrollable-start::before {
  opacity: 1;
}

.category-pills.scrollable-end::after {
  opacity: 1;
}

/* Category Pill - Modern Card Style */
.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 28px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}

[data-theme="dark"] .category-pill {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

/* Animated gradient background */
.category-pill::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, #0ea5e9, #3b82f6, #6366f1);
  background-size: 200% 200%;
  border-radius: 28px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
  animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* Hover State */
.category-pill:hover {
  transform: translateY(-3px) scale(1.05);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow:
    0 8px 20px -4px rgba(59, 130, 246, 0.25),
    0 0 30px rgba(59, 130, 246, 0.1);
}

.category-pill:hover::before {
  opacity: 0.1;
}

/* Active State - Full Gradient */
.category-pill--active {
  background: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 50%, #6366f1 100%);
  background-size: 200% 200%;
  border-color: transparent;
  color: white;
  font-weight: 700;
  box-shadow:
    0 8px 25px -5px rgba(59, 130, 246, 0.5),
    0 0 40px rgba(59, 130, 246, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  animation: gradient-shift 6s ease infinite;
}

.category-pill--active::before {
  opacity: 0;
}

.category-pill--active:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    0 12px 30px -6px rgba(59, 130, 246, 0.6),
    0 0 50px rgba(59, 130, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Icon (optional) */
.category-pill__icon {
  width: 18px;
  height: 18px;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.category-pill:hover .category-pill__icon {
  transform: scale(1.2) rotate(10deg);
}

.category-pill--active .category-pill__icon {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Count Badge */
.category-pill__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: rgba(59, 130, 246, 0.15);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  color: #3b82f6;
  transition: all 0.3s ease;
}

[data-theme="dark"] .category-pill__count {
  background: rgba(96, 165, 250, 0.2);
  color: #60a5fa;
}

.category-pill:hover .category-pill__count {
  background: rgba(59, 130, 246, 0.25);
  transform: scale(1.1);
}

.category-pill--active .category-pill__count {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

/* ============================================
   SCROLL CONTROLS - Arrows
   ============================================ */

.category-scroll-controls {
  display: none;
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
}

@media (min-width: 1024px) {
  .category-scroll-controls {
    display: block;
  }
}

.category-scroll-btn {
  position: absolute;
  width: 40px;
  height: 40px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: all;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  opacity: 0;
}

[data-theme="dark"] .category-scroll-btn {
  background: #1e293b;
  border-color: #334155;
}

.category-scroll-btn.visible {
  opacity: 1;
}

.category-scroll-btn--prev {
  left: -20px;
}

.category-scroll-btn--next {
  right: -20px;
}

.category-scroll-btn:hover {
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  border-color: transparent;
  transform: scale(1.15);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

.category-scroll-btn:hover svg {
  color: white;
}

.category-scroll-btn svg {
  width: 20px;
  height: 20px;
  color: #64748b;
  transition: color 0.3s ease;
}

[data-theme="dark"] .category-scroll-btn svg {
  color: #94a3b8;
}

/* ============================================
   RESULTS INFO
   ============================================ */

.filter-results-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid #e2e8f0;
}

[data-theme="dark"] .filter-results-info {
  border-top-color: #334155;
}

.filter-results__count {
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
}

[data-theme="dark"] .filter-results__count {
  color: #94a3b8;
}

.filter-results__count strong {
  color: #3b82f6;
  font-weight: 700;
}

.filter-results__reset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.3s ease;
}

[data-theme="dark"] .filter-results__reset {
  color: #94a3b8;
}

.filter-results__reset:hover {
  background: #f8fafc;
  color: #3b82f6;
}

[data-theme="dark"] .filter-results__reset:hover {
  background: #1e293b;
  color: #60a5fa;
}

.filter-results__reset svg {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
}

.filter-results__reset:hover svg {
  transform: rotate(180deg);
}

/* ============================================
   LOADING STATE
   ============================================ */

.category-pills.loading {
  pointer-events: none;
  opacity: 0.6;
}

.category-pills.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
  .services-filter-section {
    top: 60px;
  }

  .filter-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
  }

  .filter-search {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .services-filter-container {
    padding: 12px 16px;
  }

  .category-pills {
    gap: 8px;
    padding: 2px 0;
  }

  .category-pill {
    padding: 10px 20px;
    font-size: 13px;
  }

  .category-pill__count {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
  }

  .filter-results-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.category-pill:focus {
  outline: none;
  box-shadow:
    0 0 0 4px rgba(59, 130, 246, 0.2),
    0 8px 20px -4px rgba(59, 130, 246, 0.25);
}

.category-pill--active:focus {
  box-shadow:
    0 0 0 4px rgba(59, 130, 246, 0.3),
    0 12px 30px -6px rgba(59, 130, 246, 0.6);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .category-pill,
  .category-scroll-btn,
  .filter-search__input {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}

/* High contrast */
@media (prefers-contrast: high) {
  .category-pill {
    border-width: 3px;
  }

  .category-pill--active {
    border: 3px solid #3b82f6;
  }
}

/* GPU Acceleration */
.category-pill,
.category-scroll-btn {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}
