/**
 * Filter & Search System Redesign - BRAND-ALIGNED
 *
 * Modern horizontal layout aligned with Automuseums approved brand
 * Brand: Minimalist, Porsche-style, Inter font, Brand Blue primary
 * Designer: UI/UX Designer Agent
 * Date: January 17, 2026
 */

/* ============================================
   BRAND VARIABLES
   ============================================ */

:root {
  /* Colors - Approved Brand Palette */
  --brand-blue: #2563EB;
  --brand-blue-dark: #1D4ED8;
  --brand-blue-darker: #1E40AF;
  --light-blue: #DBEAFE;
  --dark-gray: #1F2937;
  --medium-gray: #6B7280;
  --light-gray: #F3F4F6;
  --border-gray: #E5E7EB;
  --white: #FFFFFF;
  --success-green: #10B981;
  --error-red: #EF4444;

  /* Typography - Brand Font */
  --font-primary: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Spacing - 4px Grid System */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Border Radius - Brand Standards */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows - Brand Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.museum-filters-wrapper {
  width: 100%;
  background-color: var(--light-gray);
  padding: var(--space-10) var(--space-6);
}

.museum-filters-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ============================================
   FILTER FORM
   ============================================ */

.museum-filters-form {
  width: 100%;
}

/* ============================================
   FILTERS CONTAINER (Base Layout)
   ============================================ */

.museum-filters {
  display: flex;
  flex-direction: row;
  gap: 0; /* No spacing - seamless connected look */
  align-items: stretch; /* Make all items same height */
  flex-wrap: wrap;
}

/* Desktop: No wrap */
@media (min-width: 1024px) {
  .museum-filters {
    flex-wrap: nowrap;
  }
}

/* Filter groups (individual dropdowns) */
.filter-group {
  flex: 1;
  min-width: 0; /* Allow flex items to shrink below content size */
  display: flex; /* Make filter-group a flex container */
}

/* Desktop: Custom width distribution for better UX */
@media (min-width: 1024px) {
  /* Search gets 50% - more space for typing */
  .filter-group.filter-search {
    flex: 0 0 50%;
  }

  /* Each dropdown filter gets 15% */
  .filter-group.filter-country,
  .filter-group.filter-city,
  .filter-group.filter-vehicle-type {
    flex: 0 0 15%;
  }

  /* Submit button gets 5% - compact */
  .museum-filters .filter-submit-btn {
    flex: 0 0 5%;
  }
}

/* Select dropdowns and search input styling - Seamless connected design */
.filter-select {
  width: 100%;
  height: 48px;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 400;
  color: var(--dark-gray);
  background-color: var(--white);
  border: 1px solid var(--border-gray);
  border-radius: 0;
  border-right: none;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

/* Dropdown arrow for select elements */
select.filter-select {
  cursor: pointer;
  padding-right: 40px;
  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='%236B7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 12px 12px;
}

/* Search input - Use specificity instead of !important for better maintainability */
.museum-filters-form .filter-group input[type="text"].filter-select,
.museum-filters-form .filter-group input.filter-search-input {
  /* Critical: Exact height matching select elements */
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  box-sizing: border-box;

  /* Same padding as base .filter-select */
  padding: var(--space-3) var(--space-4);
  padding-right: 40px;

  /* Remove background icon */
  background-image: none;

  /* Match line-height to selects */
  line-height: 1.5;

  /* Override all browser defaults */
  margin: 0;
  vertical-align: middle;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Focus state: Search input needs same padding-right adjustment as selects */
.museum-filters-form .filter-group input[type="text"].filter-select:focus,
.museum-filters-form .filter-group input.filter-search-input:focus {
  padding: 11px 15px;
  padding-right: 39px; /* Adjust for 2px border, same as select.filter-select:focus */
}

/* First element gets left border radius */
.filter-group:first-child .filter-select {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

/* Last filter element before button restores right border */
.filter-group:last-of-type .filter-select {
  border-right: 1px solid var(--border-gray);
}

/* Focus state - unified for all filter inputs */
.filter-select:focus {
  outline: none;
  border: 2px solid var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  padding: 11px 15px;
}

/* Focus state: Keep dropdown arrow for selects */
select.filter-select:focus {
  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='%232563EB' d='M6 3L11 8H1z'/%3E%3C/svg%3E");
  padding-right: 39px; /* Adjust for 2px border */
}

.filter-select:hover:not(:focus) {
  border-color: var(--medium-gray);
}

/* Submit button styling - Connected to filters */
.filter-submit-btn {
  flex: 0 0 auto;
  height: 48px;
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--white);
  background-color: var(--brand-blue);
  border: 1px solid var(--brand-blue);
  border-radius: 0; /* No rounded corners - seamless square design */
  cursor: pointer;
  transition: background-color 200ms ease-out, box-shadow 200ms ease-out, transform 200ms ease-out, border-color 200ms ease-out;
}

.filter-submit-btn:hover:not(:disabled) {
  background-color: var(--brand-blue-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.filter-submit-btn:active:not(:disabled) {
  background-color: var(--brand-blue-darker);
  transform: translateY(0);
  box-shadow: none;
}

.filter-submit-btn:focus {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

/* Search submit button - ensure brand alignment */
.search-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 500;
  color: var(--white);
  background-color: var(--brand-blue);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 200ms ease-out, box-shadow 200ms ease-out, transform 200ms ease-out;
}

.search-submit:hover:not(:disabled) {
  background-color: var(--brand-blue-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.search-submit:active:not(:disabled) {
  background-color: var(--brand-blue-darker);
  transform: translateY(0);
  box-shadow: none;
}

.search-submit:focus {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

/* Mobile: Stack filters and restore border radius */
@media (max-width: 767px) {
  .museum-filters {
    flex-direction: column;
    gap: var(--space-3);
  }

  .filter-group {
    width: 100%;
  }

  /* Restore border radius on mobile since elements are stacked */
  .filter-select {
    border-radius: var(--radius-md) !important;
    border-right: 1px solid var(--border-gray) !important;
  }

  .filter-submit-btn,
  .search-submit {
    width: 100%;
    border-radius: var(--radius-md) !important;
  }
}

/* ============================================
   INPUT ROW (Desktop: Horizontal)
   ============================================ */

.filter-input-row {
  display: flex;
  gap: var(--space-6); /* 24px brand spacing */
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

/* Desktop Layout (≥1024px) */
@media (min-width: 1024px) {
  .filter-input-row {
    flex-wrap: nowrap;
  }

  .filter-field--search {
    flex: 0 0 calc(30% - 18px); /* 30% width */
  }

  .filter-field--country,
  .filter-field--city,
  .filter-field--vehicle-type {
    flex: 0 0 calc(20% - 18px); /* 20% width each */
  }
}

/* Tablet Layout (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .filter-field {
    flex: 0 0 calc(50% - 12px); /* 2 columns */
  }
}

/* Mobile Layout (< 768px) */
@media (max-width: 767px) {
  .filter-input-row {
    flex-direction: column;
    gap: var(--space-3); /* 12px */
  }

  .filter-field {
    width: 100%;
  }
}

/* ============================================
   INPUT FIELDS (Search & Dropdowns)
   ============================================ */

.filter-input {
  width: 100%;
  height: 48px; /* Brand standard height */
  padding: var(--space-3) var(--space-4); /* 12px 16px */
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 400;
  color: var(--dark-gray);
  background-color: var(--white);
  border: 1px solid var(--border-gray);
  border-radius: var(--radius-md); /* 8px brand standard */
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.filter-input::placeholder {
  color: var(--medium-gray);
  opacity: 1;
}

/* Focus State - Brand Blue */
.filter-input:focus {
  outline: none;
  border: 2px solid var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  padding: 11px 15px; /* Adjust for 2px border */
}

/* Hover State */
.filter-input:hover:not(:focus) {
  border-color: var(--medium-gray);
}

/* Disabled State */
.filter-input:disabled {
  background-color: var(--light-gray);
  border-color: var(--border-gray);
  color: #9CA3AF;
  cursor: not-allowed;
  opacity: 0.6;
}

/* ============================================
   SEARCH INPUT (Special Styling)
   ============================================ */

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.filter-input--search {
  padding-right: 48px; /* Space for icon */
}

.search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--medium-gray);
  pointer-events: none;
}

/* ============================================
   SELECT DROPDOWNS (Custom Arrow)
   ============================================ */

.filter-input--select {
  padding-right: 40px; /* Space for arrow */
  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='%236B7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 12px 12px;
  cursor: pointer;
}

/* Remove default arrow in IE */
.filter-input--select::-ms-expand {
  display: none;
}

/* Arrow rotation when focused (optional enhancement) */
.filter-input--select:focus {
  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='%232563EB' d='M6 3L11 8H1z'/%3E%3C/svg%3E");
}

/* ============================================
   SEARCH BUTTON
   ============================================ */

.filter-button-row {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-6);
}

.filter-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  height: 48px;
  padding: var(--space-3) var(--space-6); /* 12px 24px */
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--white);
  background-color: var(--brand-blue);
  border: none;
  /* border-radius: 0; - No rounded corners */
  cursor: pointer;
  transition: background-color 200ms ease-out, box-shadow 200ms ease-out, transform 200ms ease-out;
}

/* Hover State */
.filter-submit-btn:hover:not(:disabled) {
  background-color: var(--brand-blue-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px); /* Subtle lift */
}

/* Active/Pressed State */
.filter-submit-btn:active:not(:disabled) {
  background-color: var(--brand-blue-darker);
  transform: translateY(0);
  box-shadow: none;
}

/* Focus State */
.filter-submit-btn:focus {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

/* Disabled/Loading State */
.filter-submit-btn:disabled {
  background-color: var(--brand-blue-dark);
  cursor: wait;
  opacity: 0.9;
}

.filter-submit-btn.is-loading .btn-text {
  display: none;
}

.filter-submit-btn.is-loading .btn-spinner {
  display: inline-block !important;
}

/* Loading Spinner */
.btn-spinner {
  display: none;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinner {
  animation: spin 1s linear infinite;
}

/* Mobile: Full Width Button */
@media (max-width: 767px) {
  .filter-submit-btn {
    width: 100%;
    min-width: 100%;
  }
}

/* ============================================
   ACTIVE FILTERS SECTION
   ============================================ */

.active-filters-section {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.active-filters-label {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: var(--dark-gray);
}

.active-filters-badges {
  display: flex;
  gap: var(--space-2); /* 8px */
  flex-wrap: wrap;
  flex: 1;
}

/* Filter Badge - Brand Blue */
.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  background-color: var(--brand-blue);
  border: none;
  border-radius: var(--radius-sm); /* 4px for small elements */
  cursor: pointer;
  transition: background-color 150ms ease;
}

.filter-badge:hover {
  background-color: var(--brand-blue-dark);
}

.badge-remove {
  font-size: 18px;
  line-height: 1;
  color: var(--white);
  transition: color 150ms ease;
}

.filter-badge:hover .badge-remove {
  color: var(--light-blue);
}

/* Clear All Button - Brand Blue Outline */
.clear-all-filters-btn {
  padding: 6px 16px;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: var(--brand-blue);
  background-color: transparent;
  border: 1px solid var(--brand-blue);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.clear-all-filters-btn:hover {
  color: var(--brand-blue-dark);
  border-color: var(--brand-blue-dark);
  background-color: var(--light-blue);
}

/* ============================================
   RESULTS COUNT
   ============================================ */

.filter-results-count {
  margin-bottom: var(--space-8);
}

.results-text {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 400;
  color: var(--medium-gray);
  display: inline-block;
  transition: transform 200ms ease-out, opacity 200ms ease-out;
}

/* Counter animation effects */
.results-text.updating {
  animation: counterPulse 600ms ease-out;
}

@keyframes counterPulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  25% {
    transform: scale(1.05);
    opacity: 0.7;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Loading state for counter */
.filtering-indicator {
  color: var(--brand-blue);
  font-style: italic;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ============================================
   ERROR STATE
   ============================================ */

.filter-error-message {
  padding: var(--space-4);
  margin-top: var(--space-6);
  font-family: var(--font-primary);
  font-size: 14px;
  color: var(--dark-gray);
  background-color: #FEF2F2; /* Light red tint */
  border: 1px solid var(--error-red);
  border-radius: var(--radius-md);
}

.filter-error-message strong {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 600;
  color: var(--error-red);
}

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

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip to Results Link */
.skip-to-results {
  position: absolute;
  top: -40px;
  left: 0;
  padding: var(--space-2);
  background: var(--brand-blue);
  color: var(--white);
  text-decoration: none;
  z-index: 100;
}

.skip-to-results:focus {
  top: 0;
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .museum-filters-wrapper {
    display: none;
  }
}

/* ============================================
   LAYOUT VARIATIONS
   ============================================ */

/**
 * Layout system for filter shortcodes
 * Allows administrators to choose between three layout options:
 * - Horizontal (default): Filters in a row on desktop
 * - Vertical: Filters stacked vertically with full width
 * - Compact: Smaller inputs and tighter spacing
 */

/* Horizontal Layout (Default) - Filters in Row */
.layout-horizontal .museum-filters {
  /* Current default behavior - no changes needed */
  /* Filters already display horizontally via existing .museum-filters flex rules */
}

/* Vertical Layout - Stacked Filters */
.layout-vertical .museum-filters {
  display: flex;
  flex-direction: column !important;
  gap: var(--space-4); /* 16px */
}

.layout-vertical .filter-group {
  width: 100% !important;
  flex: none !important;
}

/* Vertical layout: Restore borders since elements are stacked */
.layout-vertical .filter-select {
  border-radius: var(--radius-md) !important;
  border-right: 1px solid var(--border-gray) !important;
}

.layout-vertical .filter-submit-btn {
  border-radius: var(--radius-md) !important;
}

/* Compact Layout - Smaller Inputs (still seamlessly connected) */
.layout-compact .museum-filters-section {
  padding: var(--space-6) var(--space-4); /* 24px 16px */
}

.layout-compact .filter-select,
.layout-compact .filter-submit-btn {
  height: 36px !important; /* Reduced from 48px */
  font-size: 14px !important; /* Reduced from 16px */
  padding: var(--space-2) var(--space-3) !important; /* 8px 12px */
}

/* Compact layout maintains seamless connected look (no gap) */
.layout-compact .museum-filters {
  gap: 0 !important;
}

/* Mobile: All layouts stack vertically */
@media (max-width: 767px) {
  .layout-horizontal .museum-filters,
  .layout-vertical .museum-filters,
  .layout-compact .museum-filters {
    flex-direction: column;
    gap: var(--space-3);
  }

  .layout-horizontal .filter-group,
  .layout-vertical .filter-group,
  .layout-compact .filter-group {
    width: 100% !important;
  }
}

/* ============================================
   FIVA MEMBERS FILTER CHECKBOX
   ============================================ */

.fiva-filter-row {
  margin-top: var(--space-3);
  padding: 0 var(--space-1);
}

.fiva-filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  user-select: none;
  -webkit-user-select: none;
}

/* Custom checkbox appearance */
.fiva-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--brand-blue);
}

.fiva-checkbox-label {
  line-height: 1;
  color: #cab064; /* FIVA Green */
  font-weight: 600;
}

/* Checked state emphasis */
.fiva-filter-checkbox:has(.fiva-checkbox:checked) .fiva-checkbox-label {
  font-weight: 600;
}

/* Focus state for accessibility */
.fiva-checkbox:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
  border-radius: 2px;
}
