/* Alberlet-only styles. Everything shared (buttons, cards, forms, prose,
 * flash messages, header/footer) lives in common-web's style.css. This file
 * ONLY holds patterns unique to the listings browser — listing grid layout,
 * per-listing chips, filter-form grid.
 *
 * Rule: no element overrides here (`h1`, `a`, `code`, …). If a common
 * element looks wrong on alberlet pages, the fix goes in common-web's
 * style.css so every consumer benefits.
 */

/* ── Listing grid ────────────────────────────────────────────────────── */
.listings {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .listings { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1080px) {
  .listings { grid-template-columns: repeat(3, 1fr); }
}

/* Card top row — thumb on the LEFT (fixed 140px slot), info column on
 * the right (city+title+price). Chips + date footer sits below on a
 * new row. `min-width: 0` on `.listing-info` lets the ellipsis on the
 * title work when the card is narrow. */
.listing-top {
  display: flex; align-items: flex-start; gap: 0.75rem;
}
.listing-top .cw-card-carousel { flex: 0 0 140px; width: 140px; border-radius: 6px; overflow: hidden; }
@media (max-width: 480px) {
  .listing-top { flex-direction: column; gap: 0.4rem; }
  .listing-top .cw-card-carousel { flex: 0 0 auto; width: 100%; }
}
.listing-info {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; gap: 0.35rem;
}

/* Card thumbnail — first available photo, opens the fullscreen browser
 * via common-web/static/photos.js when clicked. Fixed 140×110 slot to
 * the left of the text; `scale-down` never upscales so small sources
 * sit letterboxed on the surface2 background instead of blurring. */
/* listing-thumb-link, listing-thumb now in common-web/static/style.css */
.listing-thumb { height: 110px; object-fit: scale-down; }
.listing-thumb-link { flex: 0 0 140px; }

/* Detail view — location line + price on the same row, price pinned right. */
.listing-loc-price {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: 0.5rem;
}
.listing-loc-price > p { margin: 0; }

/* Detail-view gallery — single horizontally-scrollable row.
 * `flex-shrink: 0` on each item keeps them at their native width even
 * when the row overflows; the container scrolls in one direction only. */
/* listing-gallery now in common-web/static/style.css */
.listing-gallery .listing-thumb { height: 150px; width: 200px; }

/* People strip — agent / team-member portraits shown only in the detail
 * window, below the property gallery. Round thumbs signal "this is a
 * person, not a room". */
.listing-contact { margin: 1rem 0; padding: 0.75rem 1rem; border-radius: 8px; background: var(--surface2, #1e293b); }
.listing-contact h3 { margin: 0 0 0.5rem 0; font-size: 1rem; color: var(--muted); }
.listing-contact p { margin: 0.25rem 0; }
.listing-contact a { color: var(--accent, #4895ef); }
.contact-name { font-weight: 600; font-size: 1.05rem; }
.contact-agency { font-size: 0.85rem; color: var(--muted, #94a3b8); }
.listing-people { margin: 0.75rem 0; }
.listing-people h3 { margin: 0 0 0.4rem 0; font-size: 1rem; color: var(--muted); }
.listing-people-strip {
  display: flex; gap: 0.5rem;
  padding-bottom: 0.3rem; flex-shrink: 0;
}
.contact-row {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: nowrap;
}
.contact-row > .listing-people-strip { max-width: 120px; flex-shrink: 0; }
.contact-row > .contact-details { flex: 1; min-width: 0; }
.listing-contact .listing-person { width: 48px; height: 48px; }
.listing-person-link {
  flex: 0 0 auto; display: block; line-height: 0;
  border-radius: 50%; overflow: hidden;
  background: var(--surface2);
}
.listing-person {
  width: 72px; height: 72px; object-fit: cover;
  transition: transform .15s;
}
.listing-person-link:hover .listing-person { transform: scale(1.05); }

/* Individual listing tile — extends common-web's .card.
 * The WHOLE card is the click target (data-window-open on the article),
 * so the cursor is a pointer and hover lifts the border for feedback.
 * `min-width: 0` overrides grid children's default `min-width: auto`
 * (which uses content min-width) so a long unwrappable string can't
 * push the card past its 1fr column. `position: relative` anchors the
 * ⧉ open-hint in the top-right corner. */
.listing-card {
  gap: 0.5rem; min-width: 0;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.listings .listing-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
/* ⧉ open-in-window hint pinned to the top-right corner of the card. */
.listing-open-hint {
  position: absolute; top: 0.45rem; right: 0.55rem;
  color: var(--muted); font-size: 1rem;
  pointer-events: none;
  transition: color .15s, transform .15s;
}
.listing-card:hover .listing-open-hint {
  color: var(--accent); transform: translate(1px, -1px);
}
@media (max-width: 480px) {
  .listing-open-hint {
    pointer-events: auto; z-index: 2;
    background: var(--surface, #fff); border-radius: 4px;
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
  }
}
.listing-card .meta { color: var(--muted); font-size: 1.2rem; }

/* City + title header row — one line, city fixed-width-ish, title
 * fills remainder and truncates with ellipsis. Full title is exposed
 * via `title=` (browser tooltip) AND the detail-view h1 (no truncation). */
.listing-head {
  /* City owns line 1; title flows on its own line(s) below. `column`
   * with a small vertical gap; the ellipsis clipping is gone (title
   * wraps freely via .listing-title-link's overflow-wrap). */
  display: flex; flex-direction: column; gap: 0.2rem;
  margin: 0;
}
.listing-card .listing-city {
  color: var(--accent); font-weight: 600;
  flex: 0 0 auto; white-space: nowrap;
}
.listing-district {
  color: var(--muted); font-weight: 400; font-size: 0.9rem;
}
/* Title is plain text (whole card is the click target); wraps freely. */
.listing-title-text {
  color: var(--text); font-weight: 500;
  overflow-wrap: anywhere; word-break: break-word;
}

.listing-card .price {
  font-size: 1.15rem; font-weight: 600; color: var(--accent);
}
.listing-card .money-unit { color: var(--muted); font-weight: 400; margin-left: 0.35rem; }
.listing-card .summary { color: var(--muted); }

/* Attribute chips (m², rooms, furnished, …). See .listing-card-footer
 * for the bottom-of-card pinning; `.chips` on its own is layout-only. */
.listing-card-footer {
  align-items: baseline; justify-content: space-between;
  gap: 0.75rem; margin-top: auto;
}
@media (max-width: 480px) {
  .listing-card-footer {
    display: flex; flex-wrap: wrap; gap: 0.2rem 0.3rem;
    align-items: center; justify-content: flex-start;
  }
  .listing-card-footer .chips {
    display: contents;
  }
  .listing-card-footer .chip { padding: 0.1rem 0.4rem; }
  .listing-card-footer .listing-date {
    margin-left: auto;
  }
}
.listing-date { white-space: nowrap; color: var(--muted); margin-left: auto; }
.listing-date-fresh  { color: #ff4d6a; font-weight: 600; }
.listing-date-recent { color: #5b9bd5; }
.listing-date-normal { color: #8a8a9a; }
.listing-date-stale  { color: #5a5a6a; opacity: 0.7; }

/* Source tag on cards + detail-view — favicon + friendly name. */
.source-favicon {
  display: inline-block; vertical-align: middle;
  width: 14px; height: 14px; margin-right: 0.2rem;
  border-radius: 2px;
}
.listing-source .source-favicon { width: 16px; height: 16px; margin-right: 0.3rem; }
.listing-source-tag {
  display: inline-flex; align-items: center;
  color: var(--muted); text-decoration: none;
  font-size: 0.8rem; white-space: nowrap;
}
.listing-source-tag:hover { color: var(--accent); }
/* ── Filter form ─────────────────────────────────────────────────────── */
/* Flex (not grid) so a wide price cell PUSHES its siblings — grid tracks
 * with `1fr` clamp every column to an equal share and let content overlap,
 * flex-wrap grows the wide child and wraps siblings onto the next row. */
/* filter-form, pagination, city-picker-trigger, filter-reset now in
   common-web/static/style.css — only alberlet-specific overrides below. */

/* Price field widget — inline-editable amount flanked by step arrows.
 * Rendered by common-web/static/price_field.js from a `.price-field` div.
 * `justify-content: space-between` pins the ◂ / ▸ arrows to the left and
 * right edges; the value + currency-symbol sit in the centered .pf-mid. */
.price-field {
  display: flex; align-items: stretch; justify-content: space-between;
  border: 1px solid var(--surface2, #ddd); border-radius: 4px;
  background: var(--surface, #fff); overflow: hidden;
}
.price-field .pf-mid {
  display: inline-flex; align-items: center;
  padding: 0 0.25rem; min-width: 0;
}
.price-field .pf-arr {
  border: 0; background: var(--surface2); color: var(--muted);
  padding: 0 0.4rem; cursor: pointer; line-height: 1;
  font-size: 0.95rem; transition: background .15s, color .15s;
}
.price-field .pf-arr:hover { background: var(--accent); color: #fff; }
.price-field .pf-arr:disabled,
.price-field .pf-arr[disabled] {
  opacity: 0.4; cursor: not-allowed;
  background: var(--surface2); color: var(--muted);
}
.price-field .pf-input {
  /* NO `flex: 1` — the input's `size` attribute must control width so
   * autosize() can grow it to show the whole number. */
  flex: 0 1 auto; min-width: 3ch; width: auto;
  border: 0; background: transparent; color: var(--text);
  padding: 0.35rem 0.4rem; text-align: right;
  font-variant-numeric: tabular-nums;
}
.price-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.price-field .pf-input:focus { outline: none; background: rgba(255,255,255,0.06); }
.price-field .pf-cur {
  display: inline-flex; align-items: center; padding: 0 0.4rem 0 0.15rem;
  color: var(--muted); font-size: 0.9rem;
}

/* Advanced-filter reveal toggle. Hidden by default; the little link
 * next to Sort flips `.filter-form.show-more` on the form, which
 * un-hides every `.filter-more` cell. */
.external-links {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0 0.75rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.external-links-label {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.external-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  background: var(--surface2);
  border-radius: 4px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.external-link:hover { background: var(--accent); color: #fff; }
.external-link img { flex-shrink: 0; }

.filter-form .filter-more { display: none; }
.filter-form.show-more .filter-more { display: flex; }
/* The bordered advanced panel — a fieldset takes the whole row (flex
 * basis 100%) and lays out its four fields inside a box that visually
 * attaches to the More/Less toggle. Border matches the toggle's accent
 * color so the pairing reads at a glance. */
.filter-form .filter-advanced {
  flex: 1 1 100%;
  flex-direction: row;         /* override the `column` default set on `.filter-form > *` */
  border: 1px solid var(--accent); border-radius: 4px;
  padding: 0.6rem 0.8rem;
  margin: 0;
  gap: 0.5rem; align-items: end; flex-wrap: wrap;
}
.filter-form .filter-advanced > div { flex: 1 1 140px; min-width: 0; }
/* More toggle now in common-web/static/style.css (.more-toggle-btn) */

/* pagination, city-picker-trigger now in common-web/static/style.css */

/* Source multi-select (TomSelect) — no checkboxes, compact, stay-open */
.filter-form .ts-wrapper.multi .ts-control {
  flex-wrap: nowrap !important;
  overflow-x: auto;
  min-height: 0 !important;
}
.filter-form .ts-wrapper.multi .ts-control .item {
  white-space: nowrap;
}
.filter-form .ts-wrapper.multi .ts-control > input {
  font-size: 0.85rem !important;
  padding: 2px 4px !important;
  min-width: 60px !important;
  width: 60px !important;
  flex: 0 0 auto !important;
  order: -1;
}
.ts-wrapper.multi .ts-dropdown .option.selected {
  background: rgba(72, 149, 239, 0.2) !important;
  border-left: 3px solid var(--accent, #4895ef);
}
.ts-wrapper.multi .ts-dropdown .option { padding: 6px 10px; cursor: pointer; }
.ts-wrapper.multi .ts-dropdown .option:hover { background: rgba(255,255,255,0.08); }
.ts-wrapper.multi .ts-dropdown .option.selected:hover { background: rgba(72, 149, 239, 0.3) !important; }
/* cp-trigger-label, cp-trigger-icon now in common-web/static/style.css */
.cp-readonly-tree { min-width: 180px; font-size: .85rem; }
.cp-readonly-tree .cp-county summary,
.cp-readonly-tree .cp-sub-group summary {
  font-size: .8rem; padding: .15rem .3rem;
}
.cp-readonly-tree .cp-city-item { font-size: .78rem; padding: .1rem .2rem; }
.cp-readonly-tree .cp-city-item input { display: none; }

/* ── Listing detail page ─────────────────────────────────────────────── */
.listing-source {
  padding: 0.75rem 1rem; margin: 0.5rem 0;
  background: var(--surface, #f9f9f9);
  border-left: 3px solid var(--accent, #3498db);
  border-radius: 0 4px 4px 0;
}
.listing-source .meta { font-size: 0.85rem; color: var(--muted); }

/* ── User listing create/edit ────────────────────────────────────────── */
/* Icon — sits in the nav bar next to the brand title. */
#ul-create-icon {
  display: inline-flex; align-items: center; gap: 0.1rem;
  font-size: 1.25rem; cursor: pointer; padding: 0.2rem 0.35rem;
  border: none; border-radius: 4px;
  background: transparent; color: var(--text);
  transition: color .15s, transform .15s;
  text-decoration: none; line-height: 1;
  position: relative;
}
#ul-create-icon:hover {
  color: var(--accent); transform: scale(1.1);
}
.ul-icon-badge {
  font-size: 0.6em; position: absolute;
  bottom: -0.1rem; right: -0.1rem; line-height: 1;
}

/* Price field inside user-listing form — input fills remaining space.
 * In the filter form the input auto-sizes; here the container is wide
 * so the number input must stretch between the arrows + currency. */
.ul-fields-step .price-field { width: 100%; }
.ul-fields-step .price-field .pf-mid { flex: 1 1 auto; }
.ul-fields-step .price-field .pf-input { flex: 1 1 auto; }

/* Textarea step */
.ul-textarea-step { padding: 0.5rem; }
.ul-textarea {
  width: 100%; box-sizing: border-box;
  padding: 0.6rem; border: 1px solid var(--surface2, #ddd);
  border-radius: 4px; background: var(--surface, #fff);
  color: var(--text); font-family: inherit; font-size: 0.95rem;
  resize: vertical;
}
.ul-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* Fields step */
.ul-fields-step { padding: 0.5rem; }
.ul-field { flex: 1 1 140px; min-width: 0; margin-bottom: 0.5rem; }
.ul-field label {
  display: block; font-size: 0.8rem; color: var(--muted);
  margin-bottom: 0.15rem;
}
/* Required field indicator — accent left border on the field + label color */
.ul-required label {
  color: var(--accent, #3498db);
  font-weight: 600;
}
.ul-required label::after {
  content: " *"; color: var(--accent, #3498db);
}
.ul-required .ul-input,
.ul-required .price-field,
.ul-required .ts-wrapper .ts-control {
  border-left: 3px solid var(--accent, #3498db);
}
.ul-field-narrow { flex: 0 1 100px; }
.ul-field-row {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.ul-input {
  width: 100%; box-sizing: border-box;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--surface2, #ddd); border-radius: 4px;
  background: var(--surface, #fff); color: var(--text);
}
.ul-input[readonly] {
  opacity: 0.55; cursor: not-allowed;
  background: var(--surface2, #eee);
}

/* intl-tel-input inside user listing form */
.ul-field .iti { width: 100%; }
.ul-field .iti__tel-input { width: 100%; }
/* Profile edit link next to Contact information heading */
.ul-profile-link {
  font-size: 0.8rem; font-weight: 400; color: var(--accent, #4895ef);
  margin-left: 0.5rem;
}
/* Email validation error styling */
.ul-email-input:invalid { border-color: #ef4444; }

/* Action bar */
.ul-actions {
  display: flex; gap: 0.5rem; justify-content: flex-end;
  margin-top: 0.75rem; padding-top: 0.5rem;
  border-top: 1px solid var(--surface2, #eee);
}

/* Own listing card — visually distinct from scraped listings */
main > .listing-card, .cw-window-body .listing-card {
  border: none;
  cursor: inherit;
  color: inherit;
  background: none;
  box-shadow: none;
  transform: none;
}
.listing-card-mine {
  border-color: var(--accent, #3498db);
  box-shadow: 0 0 0 1px var(--accent, #3498db), 0 2px 8px rgba(52, 152, 219, 0.15);
}
.listing-card-mine .listing-open-hint { color: var(--accent); }
.listing-edit-btn {
  position: absolute; top: 0.4rem; left: 0.5rem; z-index: 1;
  background: var(--surface, #fff); border: none; border-radius: 4px;
  padding: 0.25rem 0.4rem; font-size: 0.85rem;
  cursor: pointer; pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .15s;
}
.listing-edit-btn:hover { transform: scale(1.1); }

/* Edit/delete buttons in window header — match .cw-window-btn style */
.ul-header-btn {
  font-size: 0.9rem;
  margin-right: 0.15rem;
}

/* EasyMDE dark theme in user-listing window */
.ul-textarea-step .EasyMDEContainer {
  border: 1px solid var(--surface2, #ddd); border-radius: 4px;
  overflow: hidden;
}
.ul-required .EasyMDEContainer { border-left: 3px solid var(--accent, #3498db); }

/* Char counter for textarea */
.ul-char-counter {
  display: block; text-align: right;
  font-size: 0.75rem; margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}
.ul-counter-short { color: #ef4444; }
.ul-counter-ok { color: var(--muted); }

/* Inline description textarea in fields view */
.ul-desc-inline {
  width: 100%; box-sizing: border-box; resize: vertical;
  font-family: inherit; font-size: 0.9rem;
}

/* Photo upload — reuses mediator's .image-queue-* classes */
.ul-photos { margin-bottom: 0.5rem; }
.ul-photos > label:first-child {
  display: block; font-size: 0.8rem; color: var(--muted);
  margin-bottom: 0.15rem;
}

/* Validation error */
.ul-error {
  color: #ef4444; font-size: 0.9rem; margin: 0.5rem 0 0;
  padding: 0.4rem 0.6rem; background: rgba(239,68,68,0.1);
  border-radius: 4px;
}

/* TomSelect county header in city dropdown */
.ul-ts-county {
  font-weight: 600; font-size: 0.8rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.03em;
  padding: 0.4rem 0.5rem 0.15rem;
}

/* ── Mobile: icon + fullscreen window ───────────────────────────────── */
@media (max-width: 720px) {
  #ul-create-icon { font-size: 1.1rem; padding: 0.15rem 0.25rem; }
  /* User-listing windows always fullscreen on mobile */
  .cw-window { inset: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; }
  .cw-window .cw-window-max { display: none; }
}

/* ── Admin ──────────────────────────────────────────────────────────── */
.admin-summary { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.admin-summary .stat { font-size: 1.1rem; }
.admin-summary .stat strong { display: block; font-size: 1.5rem; }

.fb-city summary {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  margin: 0.25rem 0;
  background: var(--surface, #f8f9fa);
  border-left: 3px solid var(--accent, #007bff);
  border-radius: 0 4px 4px 0;
  font-weight: 500;
}
.fb-city ul { list-style: none; margin: 0.5rem 0 1rem 1.5rem; padding: 0; }
.fb-city li { padding: 0.25rem 0; border-bottom: 1px solid var(--surface2, #eee); font-size: 0.9rem; }
.fb-city .niche {
  background: var(--surface2, #e7f3ff);
  color: var(--accent, #0066cc);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.8em;
  margin-left: 0.25rem;
}
