/* ============================================================
   Units page — styles from _design/.../Units.html (inline <style>).
   Class names prefixed with `units-` / `u-` to avoid cross-page collision.
   ============================================================ */

.units-page-hd {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.units-page-hd h1 {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1;
}
.units-page-hd .hd-r {
  display: flex;
  gap: 8px;
  align-items: center;
}

.units-btn {
  height: var(--btn-md);
  min-width: var(--btn-w-md);
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.units-btn:hover { border-color: var(--brand-dim); color: var(--brand); }
.units-btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.units-btn.primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #fff;
}

.units-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.units-filters select,
.units-filters input[type=text] {
  height: 32px;
  padding: 0 11px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  width: auto;
  flex-shrink: 0;
  box-sizing: border-box;
}
.units-filters select { min-width: 140px; }
.units-filters input[type=text] { flex: 1 1 240px; min-width: 220px; }
.units-filters select:focus,
.units-filters input:focus { border-color: var(--brand); }

.units-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: stretch;
}
.units-grid > * { height: 100%; min-width: 0; }

.u-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-sm);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms, transform 120ms, box-shadow 120ms;
  display: flex;
  flex-direction: column;
}
.u-card:hover {
  background: var(--hover);
  border-left-color: var(--brand);
  border-color: var(--border);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.u-card.is-selected {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.u-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}
.u-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.u-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}
.tag {
  display: inline-flex;
  align-items: center;
  height: var(--pill-h);
  padding: 0 var(--pill-px);
  border-radius: var(--r-pill);
  font-size: var(--pill-fs);
  font-weight: var(--pill-fw);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.tag.avail    { background: var(--brand-soft); color: var(--brand); }
.tag.reserved { background: rgba(212, 165, 116, 0.14); color: #d4a574; }
.tag.sold     { background: rgba(0, 0, 0, 0.2); color: var(--text-secondary); border: 1px solid var(--border); }
.tag.ready    { background: var(--brand-soft); color: var(--brand); }
.tag.date     { background: var(--brand-soft); color: var(--brand); }
.tag.no-ads   { background: rgba(120, 120, 120, 0.14); color: var(--text-tertiary); }

.u-code {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}
.u-specs {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 18px;
  text-transform: lowercase;
}
.u-specs .sep {
  color: var(--text-tertiary);
  margin: 0 5px;
}

.u-prices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}
.u-price-l {
  font-size: 9.5px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.u-price-v {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.005em;
}
.u-price-v .cur {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 3px;
}

/* Drag handle — bottom-right, fades in only while hovering the card. */
.u-drag-handle {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  color: var(--text-tertiary);
  cursor: grab;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms, color 120ms, background 120ms;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.u-drag-handle:active { cursor: grabbing; }
.u-drag-handle svg { width: 14px; height: 14px; }

/* Sortable ghost / chosen / drag states */
.sortable-ghost { opacity: 0.3; }
.sortable-chosen { transform: scale(1.02); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.sortable-drag { z-index: 100; }

/* Export dropdown */
.units-export-wrap { position: relative; }
.units-export-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px;
  min-width: 160px;
  z-index: 20;
  box-shadow: var(--shadow-md);
  display: none;
}
.units-export-menu.on { display: block; }
.units-export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.units-export-menu button:hover { background: var(--hover); color: var(--brand); }

@media (max-width: 1024px) { .units-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .units-grid { grid-template-columns: 1fr; } }

/* Reveal the drag handle only while the card is hovered. */
.u-card:hover .u-drag-handle {
  opacity: 1;
  pointer-events: auto;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid var(--brand-dim);
}
.u-drag-handle:hover {
  opacity: 1;
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ----- Compare modal ----- */
.cmp-wrap { display: flex; flex-direction: column; gap: 14px; }
.cmp-grid {
  display: grid;
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  overflow: hidden;
}
.cmp-hdr,
.cmp-label,
.cmp-val {
  background: var(--card);
  padding: 12px 16px;
  min-width: 0;
}
.cmp-hdr { padding: 14px 16px; }
.cmp-hdr-label { background: var(--bg); }
.cmp-name { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.cmp-sub { font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cmp-section {
  background: var(--bg);
  padding: 8px 16px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-weight: 500;
}

.cmp-label {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}
.cmp-val {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmp-val.cmp-num {
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
}
.cmp-val.cmp-hot { color: var(--brand); font-weight: 600; }

.cmp-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================================
   Responsive (tablet / phone / touch) — additive only.
   Card grid already collapses 3→2→1 above; this section refines
   the page header, filter bar, drag handle and compare modal.
   ============================================================ */
@media (max-width: 1024px) {
  .units-page-hd { flex-wrap: wrap; align-items: flex-start; }
  .units-page-hd .hd-r { flex-wrap: wrap; }
  /* Drag handle: hover-reveal becomes visible by default on touch/tablet */
  .u-drag-handle { opacity: 1; pointer-events: auto; color: var(--brand); background: var(--brand-soft); border: 1px solid var(--brand-dim); }
  /* Compare modal — collapse extra-wide grid to scroll horizontally */
  .cmp-grid { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 640px) {
  .units-page-hd h1 { font-size: 19px; }
  .units-page-hd .hd-r { width: 100%; }
  .units-page-hd .hd-r .units-btn { flex: 1 1 auto; }

  .units-filters { gap: 6px; margin-bottom: 14px; }
  .units-filters select,
  .units-filters input[type=text] {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
    height: 40px;
    font-size: 16px; /* prevents iOS zoom */
  }
  .units-filters select { min-width: 0; }

  .u-card { padding: 14px 16px; }
  .u-name { font-size: 14px; }
  .u-prices { gap: 10px; }
  .u-price-v { font-size: 13px; }

  /* Export dropdown: full width below the button */
  .units-export-menu { left: 0; right: 0; min-width: 0; }
}

@media (hover: none) and (pointer: coarse) {
  .units-btn { min-height: 36px; }
  .units-export-menu button { min-height: 36px; }
  /* Touch: ensure inputs don't zoom */
  .units-filters select,
  .units-filters input[type=text] { font-size: 16px; }
}

/* ============================================================
   Additional refinements — compare grid scroll hint, card touch
   ergonomics, drag handle visibility on coarse pointers.
   ============================================================ */
@media (max-width: 1024px) {
  /* Compare modal — give scrolling columns a sensible min size */
  .cmp-hdr, .cmp-label, .cmp-val { min-width: 140px; }
  .cmp-name { font-size: 13px; }
}

@media (max-width: 640px) {
  /* Card content: compact tags so status chips don't overlap name */
  .u-top { gap: 8px; }
  .u-tags { gap: 4px; }
  .tag { font-size: 9.5px; }

  /* Compare modal — tighter cells on phone */
  .cmp-hdr, .cmp-label, .cmp-val { padding: 10px 12px; min-width: 120px; }
  .cmp-footer { flex-wrap: wrap; }
  .cmp-footer .units-btn { flex: 1 1 calc(50% - 4px); }
}

@media (hover: none) and (pointer: coarse) {
  /* Drag handle: visible on any coarse pointer (no hover affordance) */
  .u-drag-handle {
    opacity: 1;
    pointer-events: auto;
    color: var(--brand);
    background: var(--brand-soft);
    border: 1px solid var(--brand-dim);
  }
  /* Slightly larger card padding for fat-finger taps */
  .u-card { min-height: 140px; }
}
