/* Base resets */
        *, *::before, *::after { box-sizing: border-box; }
        html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
        body { margin: 0; }
        
        /* Hero background */
        .hero-bg {
            background: linear-gradient(to bottom, rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.75)), 
                        url('/images/hero-car.jpg') center/cover no-repeat;
        }

        /* Custom scrollbar */
        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: #f1f5f9; }
        ::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }
        ::-webkit-scrollbar-thumb:hover { background: #64748b; }

        /* Form focus states */
        select:focus, input:focus {
            outline: none;
            border-color: #2563eb;
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }

        /* Category button active state */
        .category-btn.active {
            background-color: #1e3a8a !important;
            color: white !important;
            border-color: #1e3a8a !important;
        }

        /* Filter option active state */
        .filter-option.active {
            background-color: #2563eb;
            color: white;
            border-color: #2563eb;
        }

        .filter-options {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
        }

        .filter-option {
            padding: 0.5rem 1rem;
            border: 1px solid #e2e8f0;
            border-radius: 0.5rem;
            background: white;
            font-size: 0.875rem;
            color: #475569;
            cursor: pointer;
            transition: all 0.15s;
        }

        .filter-option:hover {
            border-color: #cbd5e1;
            background: #f8fafc;
        }

        /* Option item active state */
        .option-item.active {
            background-color: #dbeafe;
            border-color: #2563eb;
            color: #1e40af;
        }

        /* Color option selected state (multi-select) */
        .color-option.selected {
            box-shadow: 0 0 0 2px #2563eb;
            transform: scale(1.1);
        }

        /* Unit/mode button active */
        .unit-btn.active, .mode-btn.active {
            background-color: #2563eb;
            color: white;
        }

        /* Advanced filters styling */
        #advanced-filters {
            border-top: 1px solid #e2e8f0;
            margin-top: 1.5rem;
            padding-top: 1.5rem;
        }

        #advanced-filters .filter-section {
            margin-bottom: 2rem;
            padding-bottom: 1.5rem;
            border-bottom: 1px solid #f1f5f9;
        }

        #advanced-filters .filter-section:last-child {
            border-bottom: none;
            margin-bottom: 0;
        }

        #advanced-filters h3 {
            font-size: 1rem;
            font-weight: 600;
            color: #1e293b;
            margin-bottom: 1rem;
        }

        #advanced-filters .filter-group {
            margin-bottom: 1rem;
        }

        #advanced-filters .filter-group label {
            display: block;
            font-size: 0.875rem;
            font-weight: 500;
            color: #475569;
            margin-bottom: 0.5rem;
        }

        #advanced-filters .filter-options {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
        }

        #advanced-filters .filter-option {
            padding: 0.5rem 1rem;
            border: 1px solid #e2e8f0;
            border-radius: 0.5rem;
            background: white;
            font-size: 0.875rem;
            color: #475569;
            cursor: pointer;
            transition: all 0.15s;
        }

        #advanced-filters .filter-option:hover {
            border-color: #cbd5e1;
            background: #f8fafc;
        }

        #advanced-filters .range-inputs {
            display: flex;
            gap: 0.75rem;
        }

        #advanced-filters .range-input {
            flex: 1;
            padding: 0.625rem 0.875rem;
            border: 1px solid #e2e8f0;
            border-radius: 0.5rem;
            font-size: 0.875rem;
        }

        #advanced-filters .filter-select {
            width: 100%;
            padding: 0.625rem 0.875rem;
            border: 1px solid #e2e8f0;
            border-radius: 0.5rem;
            font-size: 0.875rem;
            background: white;
        }

        #advanced-filters .option-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
            gap: 0.5rem;
        }

        #advanced-filters .option-item {
            padding: 0.625rem 1rem;
            border: 1px solid #e2e8f0;
            border-radius: 0.5rem;
            background: white;
            font-size: 0.875rem;
            color: #475569;
            cursor: pointer;
            text-align: center;
            transition: all 0.15s;
        }

        #advanced-filters .option-item:hover {
            border-color: #cbd5e1;
            background: #f8fafc;
        }

        #advanced-filters .color-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
        }

        #advanced-filters .color-option {
            width: 2rem;
            height: 2rem;
            border-radius: 50%;
            cursor: pointer;
            transition: transform 0.15s;
            border: 2px solid transparent;
        }

        #advanced-filters .color-option:hover {
            transform: scale(1.1);
        }

        #advanced-filters .power-units {
            display: inline-flex;
            width: auto;
            max-width: max-content;
            gap: 0;
            margin-top: 0.5rem;
        }

        #advanced-filters .consumption-modes {
            display: flex;
            gap: 0.5rem;
            margin-top: 0.5rem;
        }

        #advanced-filters .unit-btn {
            /* compact pill styles come from shared .power-units .unit-btn */
            padding: 0.25rem 0.65rem;
            border: none;
            border-radius: 0.375rem;
            background: transparent;
            font-size: 0.75rem;
            color: #64748b;
            cursor: pointer;
            transition: all 0.15s;
        }

        #advanced-filters .mode-btn {
            padding: 0.375rem 0.75rem;
            border: 1px solid #e2e8f0;
            border-radius: 0.375rem;
            background: white;
            font-size: 0.75rem;
            color: #64748b;
            cursor: pointer;
            transition: all 0.15s;
        }

        #advanced-filters .filter-tag {
            margin-top: 0.5rem;
            padding: 0.375rem 0.75rem;
            border: 1px dashed #cbd5e1;
            border-radius: 0.375rem;
            background: transparent;
            font-size: 0.75rem;
            color: #64748b;
            cursor: pointer;
        }

        #advanced-filters .vin-search-input {
            width: 100%;
            padding: 0.75rem 1rem;
            border: 1px solid #e2e8f0;
            border-radius: 0.5rem;
            font-size: 0.875rem;
        }

        /* Car card hover effects */
        .car-card {
            transition: transform 0.2s, box-shadow 0.2s;
        }
        .car-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.15);
        }

        /* Mobile FAB */
        .mobile-fab {
            position: fixed;
            bottom: 1.5rem;
            right: 1.5rem;
            width: 56px;
            height: 56px;
            border-radius: 50%;
            background: #2563eb;
            color: white;
            border: none;
            box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
            cursor: pointer;
            font-size: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 50;
            transition: transform 0.2s, box-shadow 0.2s;
        }
        .mobile-fab:hover {
            transform: scale(1.05);
            box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
        }

        /* Language dropdown */
        #language-dropdown-menu.show {
            display: block !important;
        }

        /* Mobile menu */
        #mobile-menu-container.show {
            display: block !important;
        }

        /* Expand button icon rotation */
        .expand-btn.expanded .expand-icon {
            transform: rotate(180deg);
        }
        .expand-icon {
            transition: transform 0.2s;
        }

        .filter-option *, .option-item *,
        .unit-btn *, .mode-btn *, .filter-tag * {
            pointer-events: none;
        }

/* CSP-safe utilities */
.color-swatch { width: 1.75rem; height: 1.75rem; border-radius: 9999px; cursor: pointer; display: inline-block; }
.color-swatch-black { background: #000; }
.color-swatch-white { background: #fff; border: 1px solid #ccc; }
.color-swatch-silver { background: #c0c0c0; }
.color-swatch-gray { background: #808080; }
.color-swatch-red { background: #ff0000; }
.color-swatch-blue { background: #0000ff; }
.color-swatch-green { background: #008000; }
.color-swatch-yellow { background: #ffff00; }
.color-swatch-orange { background: #ffa500; }
.color-swatch-brown { background: #8b4513; }
.hidden-by-default { display: none; }
.advanced-panel-hidden { display: none; margin-top: 15px; }
.preview-thumb { max-width: 150px; max-height: 150px; margin: 5px; }

/* Prevent overflow in narrow filter sidebar layouts */
.range-inputs { min-width: 0; }
.range-inputs input { min-width: 0; width: 100%; }
#advanced-filters .range-input.mileage-range-disabled,
#advanced-filters .range-input:disabled {
    background-color: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
    cursor: not-allowed;
    opacity: 1;
}
.consumption-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Photo remove button — inline styles so it works without Tailwind purge */
.photo-remove-btn {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  border: none;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.photo-remove-btn:hover {
  background: #dc2626;
}

/* Searchable select (typeahead combobox) */
.searchable-select {
  position: relative;
  width: 100%;
}
.searchable-select-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.7rem 2.25rem 0.7rem 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  background: #fff;
  color: #0f172a;
  font-size: 0.95rem;
  cursor: text;
}
.searchable-select-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.searchable-select.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}
.searchable-select.is-disabled .searchable-select-input {
  background: #f1f5f9;
  cursor: not-allowed;
}
.searchable-select-caret {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #64748b;
  font-size: 0.7rem;
}
.searchable-select-menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  max-height: 16rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  z-index: 40;
}
.searchable-select.open .searchable-select-menu {
  display: block;
}
.searchable-select-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.65rem 0.9rem;
  color: #0f172a;
  cursor: pointer;
  font-size: 0.95rem;
}
.searchable-select-option:hover,
.searchable-select-option.active {
  background: #eff6ff;
  color: #1d4ed8;
}
.searchable-select-option.hidden-opt {
  display: none;
}
.searchable-select-empty {
  padding: 0.75rem 0.9rem;
  color: #64748b;
  font-size: 0.875rem;
}

/* Currency toggle — same look as language pill */
.currency-toggle {
  display: inline-flex;
  align-items: center;
  width: auto;
  max-width: max-content;
  flex: 0 0 auto;
  background: #f1f5f9;
  padding: 0.125rem;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
}
.currency-toggle .currency-option {
  flex: 0 0 auto;
  min-width: 2.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 0.375rem;
  border: none;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  line-height: 1.25;
  height: auto;
}
.currency-toggle .currency-option.active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

/* Power unit toggle — same compact pill as currency / language */
.power-units,
#create-power-unit-toggle.currency-toggle,
#create-power-unit-toggle {
  display: inline-flex !important;
  align-items: center;
  width: auto !important;
  max-width: max-content;
  flex: 0 0 auto;
  align-self: center;
  gap: 0;
  background: #f1f5f9;
  padding: 0.125rem;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  height: auto !important;
  min-height: 0 !important;
}
.power-units {
  margin-top: 0.5rem;
}
#create-power-unit-toggle {
  margin-top: 0;
}
.power-units .unit-btn,
#create-power-unit-toggle .power-unit-option,
#create-power-unit-toggle .currency-option {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 2.75rem;
  padding: 0.25rem 0.65rem !important;
  border-radius: 0.375rem;
  border: none !important;
  background: transparent !important;
  font-size: 0.75rem !important;
  font-weight: 700;
  color: #64748b !important;
  cursor: pointer;
  line-height: 1.25;
  height: auto !important;
  box-shadow: none !important;
}
.power-units .unit-btn.active,
#create-power-unit-toggle .power-unit-option.active,
#create-power-unit-toggle .power-unit-option.bg-primary-600,
#create-power-unit-toggle .currency-option.active {
  background: #2563eb !important;
  color: #fff !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12) !important;
}
.consumption-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#seller-avatar {
  width: 2.75rem !important;
  height: 2.75rem !important;
  max-width: 2.75rem !important;
  max-height: 2.75rem !important;
  border-radius: 9999px;
  object-fit: cover;
  flex-shrink: 0;
}

.seller-profile-hit {
  cursor: pointer;
}
.seller-profile-hit:hover {
  opacity: 0.9;
}

.create-listing-color-option {
  pointer-events: auto !important;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.chat-messages-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-scroll-bottom-btn {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  border: none;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s ease, transform 0.15s ease;
}
.chat-scroll-bottom-btn.visible {
  display: inline-flex;
}
.chat-scroll-bottom-btn:hover {
  background: #1d4ed8;
}
.gallery-thumbs {
  align-items: center;
}
.gallery-thumb {
  width: 5rem;
  height: 4rem;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 2px solid transparent;
  background: #f1f5f9;
  padding: 0;
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.gallery-thumb.is-active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}
.gallery-thumb:hover:not(.is-active) {
  border-color: #cbd5e1;
}

.car-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.car-lightbox.open {
  display: flex;
}
.car-lightbox-image {
  max-width: min(96vw, 1400px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 0.5rem;
}
.car-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 9999px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}
.car-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 9999px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.75rem;
  cursor: pointer;
}
.car-lightbox-nav.prev { left: 1rem; }
.car-lightbox-nav.next { right: 1rem; }
.progress-fill-init { width: 0%; }
.error-banner { color: red; padding: 20px; text-align: center; }
@keyframes toastSlideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { to { transform: translateX(100%); opacity: 0; } }
.toast { animation: toastSlideIn 0.3s ease-out; }

.unread-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.15rem;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}
.unread-indicator.hidden {
  display: none !important;
}

/* SSR /search page */
.ssr-search-main { padding: 2rem 0; }
.ssr-search-form { margin-bottom: 1rem; }
.ssr-listing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.ssr-car-card { border: 1px solid #ddd; border-radius: 8px; overflow: hidden; }
.ssr-car-link { text-decoration: none; color: inherit; }
.ssr-car-media { height: 160px; background: #f0f0f0; display: flex; align-items: center; justify-content: center; }
.ssr-car-img { max-width: 100%; max-height: 100%; object-fit: cover; }
.ssr-car-body { padding: 1rem; }
.ssr-car-title { margin: 0 0 0.5rem; }
.ssr-car-meta { margin: 0; color: #666; }
.ssr-car-location { margin: 0.5rem 0; }
.ssr-car-price { margin: 0; font-weight: bold; color: #2a9d8f; }
.ssr-pagination { margin-top: 2rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ssr-noscript { margin-top: 2rem; }

/* Long unbroken strings (VIN-like spam, pasted numbers) must wrap — Tailwind break-* not in build */
.break-anywhere {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

#car-description,
#car-title,
#car-subtitle {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.car-details-description-card {
  overflow: hidden;
  min-width: 0;
}

.car-details-sidebar {
  position: relative;
  z-index: 2;
  min-width: 0;
}

/* Chat: listing title link must shrink to text width (not full row) */
.chat-car-title-link {
  display: inline-block;
  max-width: 100%;
  width: auto;
  vertical-align: top;
}

/* Chat: flex min-width:auto prevents shrink; long messages empty/collapse the pane */
#chat-main,
#chat-messages {
  min-width: 0;
  overflow-x: hidden;
}

.chat-message-row {
  max-width: 100%;
  min-width: 0;
}

.chat-bubble-wrap {
  max-width: min(80%, 100%);
  min-width: 0;
}

.chat-bubble {
  display: inline-block;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.chat-bubble-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Generic client-side field validation styles */
.field-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14) !important;
}

.field-invalid:focus,
.field-invalid:focus-visible {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
  outline: none !important;
}

.form-field-error {
  color: #dc2626;
}

/* Profile notification switch */
.az-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.az-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.az-switch-track {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 9999px;
  background: #cbd5e1;
  transition: background-color 0.2s ease;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.az-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s ease;
}

.az-switch input:checked + .az-switch-track {
  background: #2563eb;
}

.az-switch input:checked + .az-switch-track .az-switch-thumb {
  transform: translateX(20px);
}

.az-switch input:focus-visible + .az-switch-track {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.az-switch input:disabled + .az-switch-track {
  opacity: 0.55;
  cursor: not-allowed;
}

.az-switch:has(input:disabled) {
  cursor: not-allowed;
}
