/**
 * Menu Filters System - CSS
 * Styles for floating button, modal, and filter animations
 */

/* Floating Action Button (FAB) */
.ms-filter-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--primary, #000000);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ms-filter-fab svg {
  fill: white !important;
  stroke: white !important;
  color: white !important;
}

.ms-filter-fab svg * {
  fill: white !important;
  stroke: white !important;
  color: white !important;
}

.ms-filter-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.ms-filter-fab:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.ms-filter-fab.has-filters {
  background: var(--primary-d-3, #000000);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  }
  100% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

.ms-filter-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff3b30;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  animation: badgeAppear 0.3s ease-out;
  line-height: 1;
  text-align: center;
}

@keyframes badgeAppear {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Filter Modal */
.ms-filter-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ms-filter-modal.is-open {
  display: flex;
  opacity: 1;
}

.ms-filter-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.ms-filter-modal-content {
  position: relative;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 100vw;
  max-height: 80vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.ms-filter-modal.is-open .ms-filter-modal-content {
  transform: translateY(0);
}

.ms-filter-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 1;
}

.ms-filter-modal-title {
  font-size: 20px;
  font-weight: 600;
  color: #000000;
  margin: 0;
}

.ms-filter-modal-close {
  background: none;
  border: none;
  color: #666666;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ms-filter-modal-close:hover {
  background: rgba(0, 0, 0, 0.04);
}

.ms-filter-modal-body {
  padding: 0 24px 24px;
  max-height: calc(80vh - 140px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ms-filter-modal-footer {
  padding: 16px 24px 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #ffffff;
  position: sticky;
  bottom: 0;
  z-index: 1;
}

.ms-filter-apply-btn {
  width: 100%;
  background: var(--primary, #000000);
  color: #ffffff;
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.ms-filter-apply-btn:hover {
  background: var(--primary-d-3, #000000);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ms-filter-apply-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Filter Tags */
.ms-filter-tags {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
}

.ms-filter-tag-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.ms-filter-tag-item:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

.ms-filter-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid #dee2e6;
  border-radius: 4px;
  background: #ffffff;
  cursor: pointer;
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.ms-filter-checkbox:checked {
  background: var(--primary, #000000);
  border-color: var(--primary, #000000);
}

.ms-filter-checkbox:checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 6px;
  width: 6px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.ms-filter-tag-label {
  font-size: 16px;
  font-weight: 500;
  color: #333333;
  flex: 1;
  user-select: none;
}

.ms-filter-tag-item:has(.ms-filter-checkbox:checked) {
  background: var(--primary, #000000);
  border-color: var(--primary, #000000);
}

.ms-filter-tag-item:has(.ms-filter-checkbox:checked) .ms-filter-tag-label {
  color: #ffffff;
  font-weight: 600;
}

/* Snackbar */
.ms-filter-snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.9);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1500;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  min-width: 200px;
  width: auto;
  white-space: nowrap;
}

.ms-filter-snackbar.is-visible {
  transform: translateX(-50%) translateY(0);
}

.ms-filter-snackbar-text {
  font-size: 14px;
  font-weight: 500;
}

.ms-filter-snackbar-clear {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.ms-filter-snackbar-clear:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* No Results Toast */
.ms-no-results-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: #ffffff;
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 2500;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 320px;
  width: 90%;
}

.ms-no-results-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.ms-no-results-content p {
  font-size: 16px;
  color: #666666;
  margin: 0 0 20px 0;
  line-height: 1.4;
}

.ms-no-results-clear {
  background: var(--primary, #000000);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ms-no-results-clear:hover {
  background: #333333;
  transform: translateY(-1px);
}

/* Filtered Items Animation */
.ms-item-filtered-out {
  display: none !important;
}

.ms-section-empty {
  display: none;
}

/* Mobile Optimizations */
@media (max-width: 767px) {
  .ms-filter-fab {
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
  }

  .ms-filter-modal-content {
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
  }

  .ms-filter-modal-header {
    padding: 16px 20px 12px;
  }

  .ms-filter-modal-title {
    font-size: 18px;
  }

  .ms-filter-modal-body {
    padding: 0 20px 20px;
    max-height: calc(85vh - 140px);
  }

  .ms-filter-modal-footer {
    padding: 12px 20px 20px;
  }

  .ms-filter-apply-btn {
    padding: 12px 20px;
    font-size: 15px;
  }

  .ms-filter-tag-item {
    padding: 10px 14px;
  }

  .ms-filter-tag-label {
    font-size: 15px;
  }

  .ms-filter-snackbar {
    bottom: 20px;
  }

  .ms-no-results-toast {
    margin: 0 20px;
    max-width: none;
  }
}

/* Tablet and Desktop */
@media (min-width: 768px) {
  .ms-filter-modal {
    align-items: center;
    padding: 20px;
  }

  .ms-filter-modal-content {
    border-radius: 16px;
    max-width: 480px;
    max-height: 70vh;
    transform: scale(0.9);
  }

  .ms-filter-modal.is-open .ms-filter-modal-content {
    transform: scale(1);
  }

  .ms-filter-tags {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
  }

  .ms-filter-tag-item {
    padding: 14px 16px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .ms-filter-modal-content {
    background: #1c1c1e;
    color: #ffffff;
  }

  .ms-filter-modal-header {
    background: #1c1c1e;
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }

  .ms-filter-modal-footer {
    background: #1c1c1e;
    border-top-color: rgba(255, 255, 255, 0.1);
  }

  .ms-filter-modal-title {
    color: #ffffff;
  }

  .ms-filter-modal-close {
    color: #ffffff;
  }

  .ms-filter-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .ms-filter-tag-item {
    background: #2c2c2e;
  }

  .ms-filter-tag-item:hover {
    background: #3a3a3c;
  }

  .ms-filter-checkbox {
    background: #2c2c2e;
    border-color: #48484a;
  }

  .ms-filter-tag-label {
    color: #ffffff;
  }

  .ms-filter-tag-item:has(.ms-filter-checkbox:checked) {
    background: rgba(255, 255, 255, 0.1);
  }

  .ms-no-results-toast {
    background: #1c1c1e;
    color: #ffffff;
  }

  .ms-no-results-content p {
    color: #8e8e93;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .ms-filter-fab {
    border: 2px solid #ffffff;
  }

  .ms-filter-checkbox {
    border-width: 3px;
  }

  .ms-filter-tag-item {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .ms-filter-fab,
  .ms-filter-modal-content,
  .ms-filter-snackbar,
  .ms-no-results-toast,
  .ms-item-filtered-out,
  .ms-filter-tag-item,
  .ms-filter-checkbox,
  .ms-filter-apply-btn {
    transition: none;
  }

  .ms-filter-fab:hover {
    transform: none;
  }

  .ms-filter-tag-item:hover {
    transform: none;
  }

  .ms-no-results-clear:hover {
    transform: none;
  }

  .ms-filter-apply-btn:hover {
    transform: none;
  }
}
