/* Filter Bar Variables - Precise UI Colors */
:root {
  --filter-bg: #FFFFFF;
  --filter-label-color: #666666;
  --filter-border-color: #F0F0F0;
  --filter-tag-bg-active: #FECA3C; /* UI yellow */
  --filter-inner-bg: #F8F8F8; /* Light gray background for grid */
  --filter-more-color: #007ADE;
}
.brand-popup{
  flex: 1 1 0;
}
.filter-card {
  background: var(--filter-bg);
  padding: 1.25rem;
  border-radius: 0.25rem;
}

.filter-line {
  min-height: 2.5rem;
}

.filter-label {
  width: 4rem;
  color: var(--filter-label-color);
  font-size: 0.875rem;
  padding: 0.375rem 0;
}

.series-collapsed {
  max-height: 2.5rem; /* Exactly one row */
  overflow: hidden;
}

.series-expanded {
  max-height: none;
  overflow: visible;
}

.more-btn-col {
  width: 6rem;
  padding-top: 0.375rem;
}

.selection-text {
  font-size: 0.875rem;
  color: var(--text-black);
  cursor: pointer;
}

.filter-tag {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-black);
  cursor: pointer;
  border-radius: 0.125rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-tag.active {
  background: var(--filter-tag-bg-active);
}

.alphabet-nav span {
  font-size: 0.875rem;
  color: var(--text-black);
  cursor: pointer;
  padding: 0.375rem 0.75rem;
  transition: all 0.2s;
  border-radius: 0.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alphabet-nav span.active {
  background: var(--filter-tag-bg-active);
}

.alphabet-nav span:hover:not(.active) {
  background: var(--filter-inner-bg);
}

/* Brand Grid */
.brand-grid-wrapper {
  padding: 0.625rem;
  background: var(--filter-inner-bg);
  border-radius: 0.125rem;
  max-height: 40vh;
  overflow-y: auto;
}

@media (min-width: 769px) {
  .brand-grid-panel.brand-collapsed {
    max-height: 5.75rem;
    overflow: hidden;
    position: relative;
  }

  .brand-grid-panel.brand-collapsed::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1.5rem;
    background: linear-gradient(to bottom, rgba(248, 248, 248, 0), rgba(248, 248, 248, 1));
    pointer-events: none;
  }
}

.brand-grid {
  padding: 0.625rem;
  gap: 1rem;
}

.brand-item {
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  border-radius: 0.125rem;
  gap: 0.5rem;
}

.brand-item.letter-hidden {
  display: none !important;
}

.brand-item.active {
  background: var(--filter-tag-bg-active);
}

.brand-logo {
  width: 1.25rem;
}


.brand-name {
  font-size: 0.875rem;
  color: var(--text-black);
}
.series-popup {
    flex: 1 1 0;
}

/* PC端默认隐藏车系筛选 */
.series-filter {
  display: none !important;
}

/* 选择品牌后显示车系 */
.brand-selected .series-filter {
  display: flex !important;
}

/* Series & Price lines */
.series-filter, .price-filter, .age-filter {
  border-top: 1px solid var(--filter-border-color);
  padding-top: 1.25rem;
  margin-top: 0.625rem;
}

.more-link {
  color: var(--filter-more-color);
  font-size: 0.875rem;
  cursor: pointer;
}

.more-link svg {
  width: 1.25rem;
  height: 1.25rem;
}

@media (max-width: 1200px) {

}

/* Mobile/Tablet Pop-up Filter Layout */
@media (max-width: 991.98px) {
  .content-area {
    padding: 0 0 12vh 0;
  }

  .filter-card {
    position: fixed;
    top: var(--header-offset, 4.375rem);
    display: flex !important;
    flex-direction: row !important;
    background: #fff;
    z-index: 1050;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
    border-radius: 0;
    left: 0;
    width: 100%;
  }

  .filter-line {
    flex: 1;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-bottom: 0 !important;
    border: none !important;
    padding: 0.75rem 0 0 !important;
    min-height: 3rem;
    position: static;
  }

  .mobile-layout-control {
    position: static !important;
    right: auto !important;
    bottom: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    padding: 0 0.625rem 0 !important;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-left: 1px solid #f0f0f0;
    cursor: pointer;
  }

  .mobile-layout-control .layout-icon {
    width: 1.25rem;
    height: 1.25rem;
    opacity: 1;
    cursor: pointer;
    display: block;
  }

  /* Reset PC styles */
  .brand-filter, .series-filter, .price-filter, .age-filter {
    border-top: none !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
    display: flex !important; /* 移动端强制显示车系 */
  }

  .filter-label {
    width: auto !important;
    font-size: 0.9375rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }

  .filter-label::after {
    content: "";
    width: 0;
    height: 0;
    border-left: 0.25rem solid transparent;
    border-right: 0.25rem solid transparent;
    border-top: 0.3125rem solid #666;
    transition: transform 0.3s;
  }

  .filter-line.active .filter-label {
    color: var(--filter-tag-bg-active);
  }

  .filter-line.active .filter-label::after {
    transform: rotate(180deg);
    border-top-color: var(--filter-tag-bg-active);
  }

  /* Popups */
  .filter-popup, .grid-popup {
    position: fixed;
    top: calc(var(--header-offset, 4.375rem) + 3rem);
    left: 0;
    right: 0;
    max-height: 70vh;
    overflow-y: auto;
    background: #fff;
    padding: 1rem !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    display: none !important;
    z-index: 1100;
  }

  /* Show popups when line is active */
  .filter-line.active .filter-popup {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Brand Grid inside popup in mobile */
  .brand-grid-panel {
    display: flex !important;
    flex-direction: column !important;
    max-height: none;
    overflow: visible;
    background: transparent;
    padding: 0 !important;
    box-shadow: none;
    z-index: auto;
    border-top: none;
    margin-left: 0 !important;
    pointer-events: auto;
    position: static;
    max-height: 50vh;
    overflow-y: auto;
  }
  .brand-grid-wrapper{
    margin-bottom: 0;
  }
  .brand-grid-panel .brand-item{
    padding: 0.375rem 0.5rem;
  }

  .brand-grid-panel .brand-grid {
    padding: 0;
    gap: 0.5rem;
  }

  .brand-popup {
    max-height: 80vh !important;
  }

  /* Series Filter optimization in mobile */
  .series-filter.active .series-collapsed {
    max-height: none !important;
    overflow: visible !important;
  }

  .series-filter.active .more-btn-col {
    display: none !important;
  }

  body.filter-open::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1040;
  }

}

/* Home filter (PC modal + compact 2-level brands) */
.home-filter-trigger {
  border: 1px solid #f0f0f0;
}

/* Mobile reset strip uses .home-mobile-filter-actions (fixed below tab row) */

.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: #f6f6f6;
  font-size: 0.875rem;
  color: #333;
}

.home-filter-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 99999999;
}

.home-filter-modal.active {
  display: block;
}

.home-filter-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.48);
}

.home-filter-dialog {
  position: relative;
  width: min(1120px, calc(100% - 2rem));
  max-height: calc(100vh - 3rem);
  margin: 1.5rem auto;
  background: #fff;
  border-radius: 1rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}

.home-filter-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f0f0f0;
}

.home-filter-close {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: #f5f5f5;
  border-radius: 999px;
  font-size: 1.5rem;
  line-height: 1;
}

.home-filter-body {
  overflow: auto;
  padding: 1.5rem;
}

.home-filter-body .filter-card {
  padding: 0;
  border-radius: 0;
}

.home-filter-body .filter-popup {
  position: static !important;
  display: block !important;
  box-shadow: none !important;
  padding: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

.home-filter-body .brand-grid {
  gap: 0.5rem;
  padding: 0.5rem;
}

.brand-group {
  display: grid;
  grid-template-columns: minmax(170px, 220px) 1fr;
  align-items: start;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0;
  border-bottom: 1px dashed #f0f0f0;
}

.brand-group.letter-hidden {
  display: none !important;
}

.brand-group:last-child {
  border-bottom: none;
}

.brand-children {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding-left: 0;
}

.home-filter-body .brand-item {
  padding: 0.25rem 0.5rem;
  min-height: 2rem;
  font-size: 0.8125rem;
}

.home-filter-body .brand-name {
  font-size: 0.8125rem;
  line-height: 1.2;
}

.brand-primary-item {
  /* background: #fafafa;
  border: 1px solid #ededed; */
  width: fit-content;
  max-width: 100%;
}

.brand-primary-disabled {
  cursor: default !important;
  opacity: 0.9;
  pointer-events: none !important;
  user-select: none;
}

.brand-child-item {
  background: #fff;
  border: 1px solid #f0f0f0;
}

.home-filter-footer {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #f0f0f0;
}

/* 首页右侧内容区底部：备案号 */
.home-site-footer {
  margin-top: 0.5rem;
  padding: 0.75rem 0 0.25rem;
  text-align: right;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-gray, #666);
}
.home-site-footer-copy {
  margin-bottom: 0.25rem;
  color: var(--text-light, #999);
}
.home-site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem 0.5rem;
}
.home-site-footer-links a {
  color: var(--text-gray, #666);
  text-decoration: none;
}
.home-site-footer-links a:hover {
  color: var(--blue-color, #007ADE);
  text-decoration: underline;
}
.home-site-footer-sep {
  color: #ccc;
  user-select: none;
}

body.home-filter-open {
  overflow: hidden;
}

@media (max-width: 991.98px) {
  .brand-group {
    grid-template-columns: 1fr;
    gap: 0.375rem;
    padding: 0.25rem 0;
  }

  .brand-children {
    gap: 0.25rem;
  }
}

/* Mobile/Tablet: keep old top filter interaction, no modal shell */
@media (max-width: 991.98px) {
  .home-filter-trigger {
    display: none !important;
  }

  .home-filter-modal {
    position: static !important;
    inset: auto !important;
    display: block !important;
    z-index: auto !important;
  }

  .home-filter-backdrop,
  .home-filter-header,
  .home-filter-footer {
    display: none !important;
  }

  .home-filter-dialog,
  .home-filter-body {
    width: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    overflow: visible !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  /* Override PC modal rules on mobile: keep old tab-popup behavior */
  .home-filter-body .filter-popup,
  .home-filter-body .grid-popup {
    position: fixed !important;
    top: calc(var(--header-offset, 4.375rem) + 3rem) !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 70vh !important;
    overflow-y: auto !important;
    background: #fff !important;
    padding: 1rem !important;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1) !important;
    display: none !important;
    z-index: 1100 !important;
  }

  .home-filter-body .filter-line.active .filter-popup {
    display: flex !important;
    flex-direction: column !important;
  }

  .home-filter-body .brand-grid-panel {
    max-height: 50vh !important;
    overflow-y: auto !important;
  }

  body.home-filter-open {
    overflow: auto;
  }

  /*
   * Second fixed row under brand/series/price/year tabs: reset + chips.
   * Must be a sibling of .filter-card (not inside the horizontal flex row).
   */
  .home-mobile-filter-actions {
    position: fixed;
    top: calc(var(--header-offset, 4.375rem) + 3rem);
    left: 0;
    right: 0;
    z-index: 1048;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border-bottom: 1px solid var(--filter-border-color, #f0f0f0);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
  }

  .home-mobile-filter-actions-inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    max-width: 100%;
    min-height: 2.25rem;
  }

  .home-mobile-active-filter-chips {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
    min-width: 0;

    -webkit-overflow-scrolling: touch;
    padding-bottom: 1px;
  }

  .home-mobile-active-filter-chips .active-filter-chip--compact {
    flex-shrink: 0;
  }

  .home-mobile-filter-hint {
    flex: 1 1 auto;
    font-size: 0.8125rem;
    color: #777;
    line-height: 1.35;
    min-width: 0;
    padding-right: 0.25rem;
  }

  .active-filter-chip--compact {
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    gap: 0.15rem;
    background: #f5f5f5;
    border: 1px solid #ebebeb;
  }

  .active-filter-chip-key {
    font-weight: 600;
    color: #666;
    text-transform: lowercase;
  }

  .active-filter-chip-val {
    color: #111;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-mobile-reset-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-shrink: 0;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1a1a1a;
    text-decoration: none;
    background: linear-gradient(180deg, #fff6d5 0%, #fecb3c 100%);
    border: 1px solid #e0ad12;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  }

  .home-mobile-reset-btn:active {
    filter: brightness(0.96);
  }

  .home-mobile-reset-icon {
    flex-shrink: 0;
  }

  /* Dropdown panels clear both fixed strips when reset row is shown */
  .page-home--mobile-filter-bar .home-filter-body .filter-popup,
  .page-home--mobile-filter-bar .home-filter-body .grid-popup {
    top: calc(var(--header-offset, 4.375rem) + 3rem + 3.375rem) !important;
    max-height: min(70vh, calc(100vh - var(--header-offset, 4.375rem) - 3rem - 3.375rem - 1rem)) !important;
  }

  /* Reserve space so list is not hidden under fixed filter rows */
  .content-area.page-home .car-list {
    padding-top: 3rem !important;
  }

  .content-area.page-home .car-list.car-list--mobile-has-filter-actions {
    padding-top: calc(3rem + 3.375rem) !important;
  }
}
