/**
 * Map Filter Overlay Styles
 * Theme-aware styling for the map filter feature
 * Matches search-map drawer design language
 */

/* Filter Backdrop - Full Viewport Coverage */
.map-filter-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1002;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity;
}

.map-filter-backdrop:not(.hidden) {
  opacity: 1;
}

.map-filter-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Filter Overlay Container */
.map-filter-overlay {
  position: fixed;
  right: 4rem;
  z-index: 1003;
  width: 360px;
  height: 500px;
  max-width: 90vw;
  max-height: 80vh;
  pointer-events: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.map-filter-overlay:not(.hidden) {
  transform: translateX(0);
}

.map-filter-overlay.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

/* Filter Container - Glassmorphism Design (matches search) */
.map-filter-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.75rem;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-filter-container:focus-within {
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.15),
    0 4px 12px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Dark theme */
html.dark .map-filter-container {
  background: rgba(0, 0, 0, 0.95);
  border-color: rgba(147, 51, 234, 0.2);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Filter Header */
.map-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--theme-toggle-border, rgba(0,0,0,0.06));
  flex-shrink: 0;
}

html.dark .map-filter-header {
  border-color: rgba(255, 255, 255, 0.06);
}

.map-filter-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--site-text, #000);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-filter-title-icon {
  width: 24px;
  height: 24px;
}

html.dark .map-filter-title {
  color: var(--site-text, #fff);
}

/* Filter Content */
.map-filter-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  scrollbar-width: thin;
}

.map-filter-content::-webkit-scrollbar {
  width: 6px;
}

.map-filter-content::-webkit-scrollbar-track {
  background: transparent;
}

.map-filter-content::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.3);
  border-radius: 3px;
}

/* Section titles */
.filter-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--site-text, #333);
  margin: 0 0 4px 0;
}

html.dark .filter-section-title {
  color: var(--site-text, #eee);
}

.filter-section-subtitle {
  font-size: 12px;
  color: var(--site-text, #666);
  margin: 0 0 12px 0;
}

html.dark .filter-section-subtitle {
  color: var(--site-text, #aaa);
}

/* Roles Grid */
.filter-roles-section {
  margin-bottom: 20px;
}

.filter-roles-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 400px) {
  .filter-roles-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Role Button */
.filter-role-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  background: rgba(128, 128, 128, 0.08);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  min-height: 70px;
}

.filter-role-btn:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.3);
}

.filter-role-btn.selected {
  background: rgba(220, 38, 38, 0.12);
  border-color: #dc2626;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.2);
}

.filter-role-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
}

html.dark .filter-role-btn {
  background: rgba(255, 255, 255, 0.05);
}

html.dark .filter-role-btn:hover {
  background: rgba(147, 51, 234, 0.15);
  border-color: rgba(147, 51, 234, 0.4);
}

html.dark .filter-role-btn.selected {
  background: rgba(147, 51, 234, 0.2);
  border-color: #9333ea;
}

/* Role Icon */
.filter-role-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  margin-bottom: 4px;
  transition: transform 0.15s ease;
}

.filter-role-btn:hover .filter-role-icon {
  transform: scale(1.1);
}

.filter-role-btn.selected .filter-role-icon {
  filter: drop-shadow(0 0 4px rgba(220, 38, 38, 0.5));
}

html.dark .filter-role-btn.selected .filter-role-icon {
  filter: drop-shadow(0 0 4px rgba(147, 51, 234, 0.6));
}

/* Role Label */
.filter-role-label {
  font-size: 10px;
  color: var(--site-text, #555);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html.dark .filter-role-label {
  color: var(--site-text, #bbb);
}

.filter-role-btn.selected .filter-role-label {
  font-weight: 600;
  color: #dc2626;
}

html.dark .filter-role-btn.selected .filter-role-label {
  color: #c084fc;
}

/* Breeds Section */
.filter-breeds-section {
  margin-bottom: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(128, 128, 128, 0.15);
}

.filter-breeds-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Breed Group */
.filter-breed-group {
  background: rgba(128, 128, 128, 0.05);
  border-radius: 8px;
  padding: 12px;
}

html.dark .filter-breed-group {
  background: rgba(255, 255, 255, 0.03);
}

.filter-breed-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.filter-breed-header-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.filter-breed-header-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--site-text, #333);
  flex: 1;
}

html.dark .filter-breed-header-label {
  color: var(--site-text, #ddd);
}

.filter-breed-count {
  font-size: 11px;
  color: var(--site-text, #888);
}

/* Breed Search */
.filter-breed-search-wrapper {
  margin-bottom: 10px;
}

.filter-breed-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(128, 128, 128, 0.2);
  border-radius: 6px;
  background: var(--site-bg, #fff);
  color: var(--site-text, #000);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-breed-search::placeholder {
  color: var(--site-text, #999);
  opacity: 0.6;
}

.filter-breed-search:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.1);
}

html.dark .filter-breed-search {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--site-text, #fff);
}

html.dark .filter-breed-search:focus {
  border-color: #9333ea;
  box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.15);
}

/* Breed List */
.filter-breed-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.filter-breed-list::-webkit-scrollbar {
  width: 4px;
}

.filter-breed-list::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.3);
  border-radius: 2px;
}

/* Breed Item */
.filter-breed-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.filter-breed-item:hover {
  background: rgba(128, 128, 128, 0.1);
}

.filter-breed-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #dc2626;
  cursor: pointer;
}

html.dark .filter-breed-checkbox {
  accent-color: #9333ea;
}

.filter-breed-name {
  font-size: 12px;
  color: var(--site-text, #444);
  line-height: 1.3;
  flex: 1;
}

html.dark .filter-breed-name {
  color: var(--site-text, #ccc);
}

/* Show More Button */
.filter-breed-show-more {
  margin-top: 8px;
  padding: 8px;
  background: transparent;
  border: 1px dashed rgba(128, 128, 128, 0.3);
  border-radius: 4px;
  color: var(--site-text, #666);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-breed-show-more:hover {
  background: rgba(128, 128, 128, 0.1);
  border-color: rgba(128, 128, 128, 0.5);
}

html.dark .filter-breed-show-more {
  color: var(--site-text, #aaa);
  border-color: rgba(255, 255, 255, 0.15);
}

/* No Results */
.filter-breed-no-results {
  padding: 16px;
  text-align: center;
  color: var(--site-text, #888);
  font-size: 12px;
  font-style: italic;
}

/* Actions Section */
.filter-actions-section {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--theme-toggle-border, rgba(0,0,0,0.06));
  flex-shrink: 0;
}

html.dark .filter-actions-section {
  border-color: rgba(255, 255, 255, 0.06);
}

/* Filter Buttons */
.filter-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  border: none;
}

.filter-btn-secondary {
  background: rgba(128, 128, 128, 0.1);
  color: var(--site-text, #555);
}

.filter-btn-secondary:hover {
  background: rgba(128, 128, 128, 0.2);
}

html.dark .filter-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--site-text, #ccc);
}

html.dark .filter-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.filter-btn-primary {
  background: #dc2626;
  color: #fff;
}

.filter-btn-primary:hover {
  background: #b91c1c;
}

html.dark .filter-btn-primary {
  background: #9333ea;
}

html.dark .filter-btn-primary:hover {
  background: #7c3aed;
}

.filter-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
}

html.dark .filter-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.3);
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .map-filter-overlay {
    width: 100%;
    max-width: none;
    right: 0;
    left: 0;
    height: auto;
    max-height: 70vh;
    bottom: 0;
    top: auto;
    transform: translateY(100%);
    border-radius: 1rem 1rem 0 0;
  }
  
  .map-filter-overlay:not(.hidden) {
    transform: translateY(0);
  }
  
  .map-filter-overlay.hidden {
    transform: translateY(100%);
  }
  
  .map-filter-container {
    border-radius: 1rem 1rem 0 0;
  }
  
  .filter-roles-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 400px) {
  .filter-roles-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .filter-role-btn {
    min-height: 60px;
    padding: 8px 2px;
  }
  
  .filter-role-icon {
    width: 28px;
    height: 28px;
  }
  
  .filter-role-label {
    font-size: 9px;
  }
}

/* Limit reached shake animation */
@keyframes limitShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.filter-breed-item.limit-reached-shake {
  animation: limitShake 0.4s ease;
  background: rgba(220, 38, 38, 0.1);
}

html.dark .filter-breed-item.limit-reached-shake {
  background: rgba(147, 51, 234, 0.15);
}

/* Limit info banner */
.filter-limit-info {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: rgba(220, 38, 38, 0.08);
  border-radius: 6px;
  font-size: 12px;
  color: var(--site-text, #666);
}

html.dark .filter-limit-info {
  background: rgba(147, 51, 234, 0.12);
}

.filter-limit-info.limit-warning {
  background: rgba(234, 179, 8, 0.15);
}

html.dark .filter-limit-info.limit-warning {
  background: rgba(234, 179, 8, 0.12);
}

/* Filter indicator badge on toggle button - iOS notification style */
.filter-indicator {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: #ff3b30; /* iOS red */
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  line-height: 20px;
  text-align: center;
  border-radius: 10px;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  z-index: 10;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.filter-indicator.active {
  opacity: 1;
  transform: scale(1);
}

.filter-indicator.hidden {
  display: none;
}

/* Badge consistent in dark mode */
html.dark .filter-indicator {
  background: #ff3b30; /* Keep iOS red in dark mode too */
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .map-filter-backdrop,
  .map-filter-overlay,
  .filter-role-btn,
  .filter-breed-search,
  .filter-btn {
    transition: none;
  }
  
  .filter-breed-item.limit-reached-shake {
    animation: none;
  }
  
  .filter-indicator {
    transition: none;
  }
}
