/* ========================================================
   Phase K.D — Properties surface
   List view (/properties), detail view (/properties/:id),
   add-by-MLS modal.
   Uses existing design tokens from styles.css.
   ======================================================== */

/* ── Toolbar ─────────────────────────────────────────────── */

.properties-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.properties-toolbar .messages-search-wrap {
  flex: 1 1 280px;
  min-width: 220px;
}
.properties-toolbar .messages-filter-chips {
  flex: 1 1 auto;
  flex-wrap: wrap;
}
.properties-sort-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.properties-sort-wrap select {
  background: var(--bg-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
}

/* ── List card ───────────────────────────────────────────── */

.properties-list-card { padding: 0; overflow: hidden; }
.properties-list-card .properties-result-count {
  padding: 0.75rem 1.25rem 0;
}
.properties-list-card .empty-state,
.properties-list-card .loading,
.properties-list-card .alert {
  margin: 1rem 1.25rem;
}
.properties-list-card #properties-list-body { padding-bottom: 0.5rem; }

.properties-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.properties-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.25rem 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 120ms ease;
}
.properties-row:last-child { border-bottom: none; }
.properties-row:hover { background: var(--bg-2); }

.property-color-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--st-gray);
}
.property-color-red    .property-color-bar { background: var(--st-coral); }
.property-color-yellow .property-color-bar { background: var(--st-amber); }
.property-color-green  .property-color-bar { background: var(--st-green2); }
.property-color-gray   .property-color-bar { background: var(--st-gray); }

.property-row-main {
  flex: 1 1 auto;
  min-width: 0;
}
.property-row-headline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.property-address {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.95rem;
}
.property-row-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.property-row-secondary .property-sep { opacity: 0.5; }
.property-mls {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}
.property-no-mls { font-style: italic; opacity: 0.7; }

.property-lock {
  font-size: 0.95rem;
  line-height: 1;
}
.property-lock.no-info { opacity: 0.85; }

.property-row-action { flex: 0 0 auto; }

.properties-row.is-highlight {
  animation: prop-highlight 2.5s ease-out;
}
@keyframes prop-highlight {
  0%   { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* ── Status pill colors (mapped onto existing badge palette) ── */

.badge.property-status-available { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.25); }
.badge.property-status-pending   { background: rgba(251,146,60,.14); color: #fdba74; border-color: rgba(251,146,60,.28); }
.badge.property-status-taken     { background: rgba(248,113,113,.14); color: #fca5a5; border-color: rgba(248,113,113,.28); }
.badge.property-status-withdrawn { background: rgba(248,113,113,.14); color: #fca5a5; border-color: rgba(248,113,113,.28); }
.badge.property-status-unknown   { background: rgba(107,114,128,.14); color: #d1d5db; border-color: rgba(107,114,128,.3); }

[data-theme="light"] .badge.property-status-available { color: #b45309; background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); }
[data-theme="light"] .badge.property-status-pending   { color: #b45309; background: rgba(251, 146, 60, 0.12); border-color: rgba(251, 146, 60, 0.32); }
[data-theme="light"] .badge.property-status-taken,
[data-theme="light"] .badge.property-status-withdrawn { color: #b91c1c; background: rgba(220, 38, 38, 0.08); border-color: rgba(220, 38, 38, 0.28); }

/* Dot indicator for the row's color-bar status (used in detail headlines too) */

.badge {
  display: inline-flex;
  align-items: center;
}

/* ── Detail page ─────────────────────────────────────────── */

.property-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
}
.property-header h1 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.25;
  color: var(--text-primary);
}
.property-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.property-header-meta code {
  font-size: 0.8rem;
}
.property-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}
.property-header-status {
  grid-column: 1 / -1;
  margin-top: 0.5rem;
}
.property-header-status.success {
  background: rgba(16,185,129,.12);
  border: 1px solid rgba(16,185,129,.32);
  color: var(--success);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.875rem;
}

.property-listing-agent .kv-grid + .property-reached-out {
  margin-top: 1rem;
}
.property-reached-out {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  display: grid;
  gap: 0.4rem;
}
.property-reached-out-headline { color: var(--text-primary); }
.property-reached-out a { display: inline-block; margin-top: 0.25rem; }

.property-agent-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}
.property-agent-actions .primary { width: auto; padding: 0.6rem 1rem; }

.property-block { margin-top: 1rem; }
.property-block h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.property-block-text {
  color: var(--text-secondary);
  white-space: pre-wrap;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.875rem;
  font-size: 0.875rem;
}
.property-lockbox-line code {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ── Interests table ─────────────────────────────────────── */

.property-interests .card-header { padding-bottom: 0.5rem; }
.property-interests-table th,
.property-interests-table td { padding: 0.55rem 0.75rem; }

.property-link-picker {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: grid;
  gap: 0.5rem;
}
.property-link-results { min-height: 1.5rem; }
.property-link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.25rem;
}
.property-link-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
}
.property-link-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.property-link-picker-actions {
  display: flex;
  justify-content: flex-end;
}

.property-notes textarea {
  width: 100%;
  min-height: 80px;
  background: var(--bg-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}
.property-notes textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.property-notes .field-hint { margin-top: 0.25rem; }

/* ── Add Property modal — pending state spinner ─────────── */

.add-prop-pending {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
  text-align: center;
  padding: 0.5rem 0;
}
.add-prop-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: prop-spin 0.9s linear infinite;
}
@keyframes prop-spin {
  to { transform: rotate(360deg); }
}

.field-hint.is-error { color: var(--danger); }

/* ── Toast ───────────────────────────────────────────────── */

.properties-toast-host {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  display: grid;
  gap: 0.5rem;
  z-index: 200;
  pointer-events: none;
}
.properties-toast {
  pointer-events: auto;
  background: var(--bg-3);
  color: var(--text-primary);
  border: 1px solid var(--success);
  box-shadow: var(--shadow-md);
  padding: 0.65rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  animation: prop-toast-in 200ms ease-out;
}
.properties-toast.is-leaving {
  animation: prop-toast-out 350ms ease-in forwards;
}
@keyframes prop-toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
@keyframes prop-toast-out {
  to { transform: translateY(8px); opacity: 0; }
}

/* ── Mobile ─────────────────────────────────────────────── */

@media (max-width: 720px) {
  .property-header {
    grid-template-columns: 1fr;
  }
  .property-header-actions {
    justify-content: flex-start;
  }
  .properties-toolbar {
    gap: 0.5rem;
  }
  .properties-row {
    padding: 0.75rem 1rem 0.75rem 1.25rem;
  }
  .property-row-action { display: none; }
}
