/* DAVR header search + category-first filter refinement.
   Presentation only: React still owns search, category taxonomy and filter data. */
@media (min-width: 1024px) {
  /* Search is the only browse control kept near DAVR in the header. */
  html.davr-desktop-browser-layout #root header {
    min-height: 64px !important;
    padding-block: 7px !important;
    gap: 11px !important;
    background: rgba(255,255,255,.985) !important;
    box-shadow: 0 1px 10px rgba(27,70,49,.045);
  }
  html.davr-desktop-browser-layout #root header > .brand {
    margin-right: 3px !important;
  }
  html.davr-desktop-browser-layout #root header > .davr-desktop-search-toggle {
    display: inline-flex !important;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 41px !important;
    padding: 0 15px !important;
    border: 1px solid #d5e9de;
    border-radius: 12px;
    background: #eff9f4;
    color: #087c63;
    font: inherit;
    font-size: 13.5px;
    font-weight: 760;
    white-space: nowrap;
    cursor: pointer;
  }
  html.davr-desktop-browser-layout #root header > .davr-desktop-search-toggle:hover,
  html.davr-desktop-browser-layout #root header > .davr-desktop-search-toggle[aria-expanded="true"] {
    border-color: #9ccfbb;
    background: #e5f6ed;
  }
  html.davr-desktop-browser-layout #root header > .davr-desktop-search-toggle:focus-visible {
    outline: 3px solid #8bd3b8;
    outline-offset: 2px;
  }
  html.davr-desktop-browser-layout #root header .header-actions {
    gap: clamp(8px, 1.1vw, 15px) !important;
    margin-left: auto !important;
  }
  html.davr-desktop-browser-layout #root header .header-actions > button.primary {
    min-height: 42px !important;
    padding: 9px 16px !important;
    font-size: 13.5px;
    border-radius: 12px;
  }
  html.davr-desktop-browser-layout #root header .header-actions .city-picker,
  html.davr-desktop-browser-layout #root header .header-actions .picker {
    min-height: 40px;
  }
  html.davr-desktop-browser-layout .davr-desktop-sidebar {
    top: calc(var(--davr-desktop-header-height, 64px) + 13px);
  }
  /* The existing React search remains mounted and uses the existing PWA toggle.
     Open it as a compact inline field directly over the search trigger in
     the header, not at x=16 over the navigation sidebar. */
  html.davr-desktop-browser-layout .catalog-discovery:not(.shop-discovery-mode) .search {
    top: calc((var(--davr-desktop-header-height, 64px) - 52px) / 2) !important;
    left: var(--davr-desktop-search-left, 165px) !important;
    width: min(510px, calc(100vw - var(--davr-desktop-search-left, 165px) - 320px)) !important;
    min-height: 52px !important;
    padding: 4px 7px !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 34px rgba(12,52,39,.14) !important;
  }
  /* Users should see live results while using header search. */
  html.davr-desktop-browser-layout.davr-desktop-search-open body::before {
    display: none !important;
  }
  html.davr-desktop-browser-layout.davr-desktop-search-open #root header {
    z-index: 40 !important;
  }
}
@media (min-width: 1024px) and (max-width: 1199px) {
  html.davr-desktop-browser-layout #root header {
    padding-inline: 18px !important;
  }
  html.davr-desktop-browser-layout .catalog-discovery:not(.shop-discovery-mode) .search {
    width: min(360px, calc(100vw - var(--davr-desktop-search-left, 165px) - 290px)) !important;
  }
  html.davr-desktop-browser-layout #root header > .davr-desktop-search-toggle {
    padding-inline: 10px !important;
  }
}
@media (min-width: 701px) {
  /* Category tree is the primary filter, not a tiny tile beside city fields. */
  .filter-modal {
    width: min(1010px, calc(100vw - 36px)) !important;
    max-width: 1010px !important;
    max-height: min(90dvh, 880px) !important;
    border: 1px solid #dcece4;
    border-radius: 23px !important;
    box-shadow: 0 28px 90px rgba(12,49,37,.24);
  }
  .filter-modal .modal-top {
    padding: 17px 24px !important;
    background: linear-gradient(115deg,#fff,#f7fcf9) !important;
    border-bottom: 1px solid #e0eee6;
  }
  .filter-modal .modal-top [data-slot="dialog-title"] {
    color: #19392d;
    font-size: 23px;
    font-weight: 850;
  }
  .filter-modal .catalog-filters {
    max-height: calc(min(90dvh, 880px) - 69px) !important;
    padding: 21px 24px 0 !important;
    background: #f6f9f7 !important;
    scrollbar-gutter: stable;
  }
  .filter-modal .filter-title h2 {
    margin-bottom: 11px;
    font-size: 17px;
    color: #26483a;
  }
  .filter-modal .filter-hint {
    margin-bottom: 16px;
    color: #657c71;
    font-size: 13px;
  }
  .filter-modal .filter-sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
  }
  .filter-modal .filter-sections > .filter-group:first-child {
    grid-column: 1 / -1;
    border: 1px solid #bbddce;
    border-radius: 19px;
    background: linear-gradient(115deg, #fff, #f0faf5);
    box-shadow: 0 7px 22px rgba(13,104,75,.055);
  }
  .filter-modal .filter-sections > .filter-group:first-child > summary {
    min-height: 56px;
    border-bottom: 1px solid transparent;
    color: #096c54;
    font-size: 16px;
  }
  .filter-modal .filter-sections > .filter-group:first-child[open] > summary {
    border-bottom-color: #e1eee6;
  }
  .filter-modal .filter-group {
    overflow: hidden;
    border: 1px solid #dfece6;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(18,65,45,.025);
  }
  .filter-modal .filter-group summary {
    min-height: 53px;
    padding: 14px 17px;
    color: #28473b;
    font-size: 14.5px;
    font-weight: 800;
  }
  .filter-modal .filter-group summary:hover {
    background: #f3faf6;
  }
  .filter-modal .filter-group[open] > summary {
    border-bottom: 1px solid #edf3ef;
  }
  .filter-modal .filter-group summary > svg:first-child {
    color: #0a9a76;
  }
  .filter-modal .filter-fields {
    gap: 13px 14px;
    padding: 14px 17px 20px;
  }
  .filter-modal .filter-sections > .filter-group:first-child .filter-fields {
    padding: 17px 20px 22px;
  }
  .filter-modal .filter-sections > .filter-group:first-child .filter-fields > .filter-full:first-child {
    grid-column: 1 / -1;
    max-width: 100%;
  }
  .filter-modal .filter-sections > .filter-group:first-child .picker {
    min-height: 50px;
    border: 1px solid #b9dfcf;
    border-radius: 13px;
    background: #fff;
    color: #215846;
    font-weight: 730;
  }
  .filter-modal .filter-category-trail {
    gap: 9px;
    padding: 5px 0;
    align-items: center;
  }
  .filter-modal .filter-category-trail button {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid #d5e9de;
    border-radius: 9px;
    background: #fff;
    color: #44685a;
    font-weight: 700;
  }
  .filter-modal .filter-category-trail button[aria-current="page"] {
    border-color: #a4d9c3;
    background: #e6f7ee;
    color: #08765d;
  }
  .filter-modal .filter-category-back {
    min-height: 37px;
    justify-content: flex-start;
    color: #08745a;
    font-weight: 770;
  }
  .filter-modal .filter-category-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
  }
  .filter-modal .filter-category-list button {
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    min-height: 54px;
    padding: 10px 14px;
    border: 1px solid #dcebe4;
    border-radius: 13px;
    background: #fff;
    color: #2a5140;
    font-size: 13.5px;
    font-weight: 700;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
  }
  .filter-modal .filter-category-list button:hover {
    transform: translateY(-1px);
    border-color: #8bc5ad;
    background: #f0faf5;
  }
  .filter-modal .filter-category-list button.active {
    border-color: #09886b;
    background: #e3f6ec;
    color: #07664f;
  }
  .filter-modal .filter-category-list button:focus-visible,
  .filter-modal .filter-category-trail button:focus-visible,
  .filter-modal .filter-group summary:focus-visible {
    outline: 3px solid #92d6bc;
    outline-offset: 2px;
  }
  .filter-modal .filter-fields :is(input:not([type="checkbox"]), .picker) {
    min-height: 46px;
    border-radius: 12px;
  }
  .filter-modal .filter-actions {
    gap: 10px;
    margin-top: 18px;
    padding: 13px 20px 15px !important;
    border-top: 1px solid #e1ece6;
    background: rgba(255,255,255,.97) !important;
    box-shadow: 0 -7px 18px rgba(27,69,43,.035);
  }
  .filter-modal .filter-actions .primary {
    min-height: 45px;
    border-radius: 12px;
  }
}
@media (min-width: 701px) and (max-width: 820px) {
  .filter-modal .filter-sections {
    grid-template-columns: minmax(0, 1fr);
  }
  .filter-modal .filter-category-list {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}
@media (max-width: 700px) {
  /* Mobile keeps the familiar bottom tab bar, but gains readable category
     drill-down options in the shared filter dialog. */
  .filter-modal .filter-category-list button {
    min-height: 48px;
    border-radius: 12px;
    padding: 10px 12px;
    line-height: 1.4;
    white-space: normal;
  }
}
@media (prefers-reduced-motion: reduce) {
  .filter-modal .filter-category-list button {
    transition: none !important;
  }
}


/* Long listing forms should not be a phone-sized column on desktop. */
@media (min-width: 1024px) {
  .form-modal:not(.compact) {
    width: min(840px, calc(100vw - 64px)) !important;
    max-width: 840px !important;
    max-height: min(92dvh, 960px) !important;
    padding: 24px 30px !important;
    border-radius: 24px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }
  .form-modal:not(.compact) > .modal-top {
    position: sticky;
    top: -24px;
    z-index: 2;
    width: calc(100% + 60px);
    min-height: 54px;
    margin: -24px -30px 14px;
    padding: 16px 30px;
    box-sizing: border-box;
    background: rgba(255,255,255,.98);
    border-bottom: 1px solid #e0ece5;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  .form-modal:not(.compact) .listing-form {
    width: 100%;
    min-width: 0;
    gap: 16px;
  }
  .form-modal:not(.compact) .form-grid {
    min-width: 0;
    gap: 14px 16px;
  }
  .form-modal:not(.compact) .davr-extra-characteristics {
    padding: 18px 20px;
    border-radius: 17px;
    background: #fbfdfb;
  }
}
@media (min-width: 1024px) and (max-height: 690px) {
  .form-modal:not(.compact) {
    max-height: calc(100dvh - 26px) !important;
    padding-top: 18px !important;
  }
}
