/* ============================================================
   OPEN DOORWAY, Extended Component Library
   Revolut × Apple design language
   ============================================================ */

/* -- Bottom Sheet (Mobile) -- */
.bottom-sheet-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.bottom-sheet-overlay.active { opacity: 1; visibility: visible; }

.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 410;
  background: var(--surface-base);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.12);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);
  max-height: 85vh; overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-sheet.active { transform: translateY(0); }
.bottom-sheet-handle {
  width: 36px; height: 4px; background: var(--border-strong);
  border-radius: 2px; margin: 8px auto 4px;
}
.bottom-sheet-header {
  padding: 0.75rem 1.25rem 0.5rem; font-size: 0.8125rem;
  font-weight: 700; color: var(--text-primary);
}
.bottom-sheet-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.875rem 1.25rem; font-size: 0.875rem;
  color: var(--text-primary); cursor: pointer;
  transition: background 0.1s ease;
}
.bottom-sheet-item:active { background: var(--surface-overlay); }
.bottom-sheet-item .material-symbols-outlined { font-size: 20px; color: var(--text-secondary); }
.bottom-sheet-divider { height: 1px; background: var(--border-subtle); margin: 0.375rem 0; }
.bottom-sheet-cancel {
  display: block; width: 100%; padding: 0.875rem; text-align: center;
  font-size: 0.875rem; font-weight: 600; color: var(--text-secondary);
  background: none; border: none; border-top: 1px solid var(--border-subtle);
  cursor: pointer;
}

/* -- Toast / Snackbar -- */
.toast-container {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  z-index: 500; display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; background: var(--text-primary);
  color: var(--surface-base); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); font-size: 0.8125rem; font-weight: 500;
  pointer-events: auto; animation: toastIn 0.3s cubic-bezier(0.16,1,0.3,1) forwards;
  max-width: 400px;
}
.toast.toast-out { animation: toastOut 0.2s ease forwards; }
.toast-undo {
  margin-left: auto; background: none; border: none; color: var(--brand-primary-light);
  font-size: 0.75rem; font-weight: 700; cursor: pointer; padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-8px) scale(0.95); } }

/* -- Filter Chips -- */
.filter-chip {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.375rem 0.75rem; font-size: 0.75rem; font-weight: 600;
  color: var(--text-secondary); background: var(--surface-base);
  border: 1px solid var(--border-default); border-radius: var(--radius-full);
  cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
}
.filter-chip:hover { border-color: var(--brand-primary-ink); color: var(--brand-primary-ink); }
.filter-chip.active {
  background: var(--brand-primary); color: var(--text-on-brand);
  border-color: var(--brand-primary-ink);
}
.filter-chip .material-symbols-outlined { font-size: 14px; }

/* -- Time Range Selector -- */
.time-range-pills {
  display: inline-flex; background: var(--surface-overlay);
  border-radius: var(--radius-full); padding: 2px; gap: 2px;
}
.time-range-pill {
  padding: 0.25rem 0.625rem; font-size: 0.6875rem; font-weight: 600;
  color: var(--text-muted); background: transparent; border: none;
  border-radius: var(--radius-full); cursor: pointer;
  transition: all 0.15s ease;
}
.time-range-pill:hover { color: var(--text-primary); }
.time-range-pill.active {
  background: var(--surface-base); color: var(--brand-primary-ink);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* -- View Toggle (Grid/List/Map) -- */
.view-toggle {
  display: inline-flex; background: var(--surface-overlay);
  border-radius: var(--radius-md); padding: 2px; gap: 2px;
}
.view-toggle-btn {
  padding: 0.375rem 0.5rem; background: transparent; border: none;
  border-radius: calc(var(--radius-md) - 2px); cursor: pointer;
  color: var(--text-muted); transition: all 0.15s ease;
  display: flex; align-items: center; justify-content: center;
}
.view-toggle-btn:hover { color: var(--text-primary); }
.view-toggle-btn.active {
  background: var(--surface-base); color: var(--brand-primary-ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.view-toggle-btn .material-symbols-outlined { font-size: 18px; }

/* -- Property Card (Enhanced) -- */
.property-card-v2 {
  background: var(--surface-base); border: 1px solid var(--border-default);
  border-radius: var(--radius-xl); overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16,1,0.3,1); cursor: pointer;
}
.property-card-v2:hover {
  border-color: var(--brand-primary-ink);
  box-shadow: var(--shadow-lg); transform: translateY(-2px);
}
.property-card-v2 .card-image {
  position: relative; height: 180px; overflow: hidden;
}
.property-card-v2 .card-image img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.16,1,0.3,1);
}
.property-card-v2:hover .card-image img { transform: scale(1.05); }
.property-card-v2 .card-badge {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  padding: 0.25rem 0.625rem; border-radius: var(--radius-full);
  font-size: 0.6875rem; font-weight: 700; color: var(--brand-primary-ink);
}
.property-card-v2 .card-confidence {
  position: absolute; bottom: 0.75rem; left: 0.75rem;
  padding: 0.25rem 0.5rem; border-radius: var(--radius-sm);
  font-size: 0.625rem; font-weight: 700;
}
.confidence-high { background: rgba(5,150,105,0.12); color: var(--color-success, #16a34a); }
.confidence-mid { background: rgba(59,130,246,0.12); color: #3b82f6; }
.confidence-low { background: rgba(217,119,6,0.12); color: var(--color-amber, #d97706); }
.property-card-v2 .card-body { padding: 1rem; }
.property-card-v2 .card-title {
  font-size: 0.8125rem; font-weight: 700; color: var(--text-primary);
  margin-bottom: 0.125rem;
}
.property-card-v2 .card-subtitle {
  font-size: 0.6875rem; color: var(--text-muted); margin-bottom: 0.75rem;
}
.property-card-v2 .card-price {
  font-size: 1.125rem; font-weight: 800; color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.property-card-v2 .card-yield {
  font-size: 0.6875rem; font-weight: 600; color: var(--color-success, #16a34a);
  background: rgba(5,150,105,0.08); padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
}
.property-card-v2 .card-forecast {
  display: flex; align-items: center; gap: 0.375rem;
  padding-top: 0.75rem; margin-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.6875rem; color: var(--text-muted);
}
.property-card-v2 .card-forecast .value {
  font-weight: 700; color: var(--color-success, #16a34a);
}

/* -- List View Property Card -- */
.property-list-item {
  display: flex; gap: 1rem; padding: 1rem;
  background: var(--surface-base); border: 1px solid var(--border-default);
  border-radius: var(--radius-xl); transition: all 0.2s ease;
  cursor: pointer;
}
.property-list-item:hover {
  border-color: var(--brand-primary-ink); box-shadow: var(--shadow-md);
}
.property-list-item .list-image {
  width: 120px; height: 90px; border-radius: var(--radius-lg);
  overflow: hidden; flex-shrink: 0;
}
.property-list-item .list-image img {
  width: 100%; height: 100%; object-fit: cover;
}
.property-list-item .list-body { flex: 1; min-width: 0; }
.property-list-item .list-title {
  font-size: 0.8125rem; font-weight: 700; color: var(--text-primary);
}
.property-list-item .list-subtitle {
  font-size: 0.6875rem; color: var(--text-muted); margin-top: 0.125rem;
}
.property-list-item .list-metrics {
  display: flex; gap: 1rem; margin-top: 0.5rem;
}
.property-list-item .list-metric {
  font-size: 0.6875rem; color: var(--text-secondary);
}
.property-list-item .list-metric .val {
  font-weight: 700; color: var(--text-primary);
}

/* -- Empty State -- */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 3rem 1.5rem; text-align: center;
}
.empty-state-icon {
  width: 64px; height: 64px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-primary-light); border-radius: var(--radius-xl);
  margin-bottom: 1rem;
}
.empty-state-icon .material-symbols-outlined {
  font-size: 28px; color: var(--brand-primary-ink);
}
.empty-state-title {
  font-size: 1rem; font-weight: 700; color: var(--text-primary);
  margin-bottom: 0.375rem;
}
.empty-state-desc {
  font-size: 0.8125rem; color: var(--text-muted); max-width: 320px;
  margin-bottom: 1.25rem; line-height: 1.5;
}

/* -- Error State -- */
.error-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 3rem 1.5rem; text-align: center;
}
.error-state-icon {
  width: 64px; height: 64px; display: flex; align-items: center; justify-content: center;
  background: var(--color-amber-bg); border-radius: var(--radius-xl);
  margin-bottom: 1rem;
}
.error-state-icon .material-symbols-outlined {
  font-size: 28px; color: var(--color-amber);
}

/* -- Micro Sparkline (CSS-only) -- */
.sparkline {
  display: inline-flex; align-items: flex-end; gap: 1px;
  height: 20px; opacity: 0.6;
}
.sparkline-bar {
  width: 3px; background: var(--brand-primary);
  border-radius: 1px; transition: height 0.3s ease;
}

/* -- Skeleton Variants -- */
.skeleton-card {
  background: var(--surface-base); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl); padding: 1rem; overflow: hidden;
}
.skeleton-line {
  height: 12px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-overlay) 25%, var(--surface-sunken) 50%, var(--surface-overlay) 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
.skeleton-line-sm { height: 8px; width: 60%; }
.skeleton-line-lg { height: 20px; width: 40%; }
.skeleton-circle {
  border-radius: 50%;
  background: linear-gradient(90deg, var(--surface-overlay) 25%, var(--surface-sunken) 50%, var(--surface-overlay) 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
.skeleton-image {
  height: 180px; border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--surface-overlay) 25%, var(--surface-sunken) 50%, var(--surface-overlay) 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* -- Staggered Entrance -- */
.stagger-child { opacity: 0; transform: translateY(8px); }
.stagger-child.visible {
  animation: slideUp 0.35s cubic-bezier(0.16,1,0.3,1) forwards;
}

/* -- Comparison Tray (Mobile) -- */
.compare-tray {
  position: fixed; bottom: 60px; left: 0; right: 0; z-index: 45;
  background: var(--text-primary); color: var(--surface-base);
  padding: 0.625rem 1rem; display: none;
  align-items: center; justify-content: space-between;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
}
.compare-tray.active { display: flex; }
.compare-tray-count { font-size: 0.8125rem; font-weight: 600; }
.compare-tray-btn {
  padding: 0.375rem 0.875rem; background: var(--brand-primary);
  color: var(--text-on-brand); border: none; border-radius: var(--radius-md);
  font-size: 0.75rem; font-weight: 700; cursor: pointer;
}

/* -- Progress Bar -- */
.progress-bar {
  height: 6px; background: var(--surface-overlay);
  border-radius: 3px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.16,1,0.3,1);
}

/* -- Pull to Refresh -- */
.pull-indicator {
  display: flex; align-items: center; justify-content: center;
  padding: 0.5rem; color: var(--text-muted); font-size: 0.75rem;
  transform: translateY(-100%); transition: transform 0.2s ease;
}
.pull-indicator.active { transform: translateY(0); }
.pull-indicator .material-symbols-outlined {
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -- Reduced Motion -- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   FORECAST UNCERTAINTY COMPONENTS
   (PREMIUM-TIER-DESIGN-BRIEF.md, uncertainty made explicit)
   A range, not a point; the downside, not just the upside.
   All colors via CSS variables → theme-aware (incl. Nocturne).
   ============================================================ */

/* -- Forecast band bar: P10 ── median ── P90 on a -10..+20% scale -- */
.forecast-band {
  margin-top: 0.5rem;
}
.forecast-band-track {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-overlay, #f1f3f9);
  overflow: hidden;
}
.forecast-band-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 3px;
  background: linear-gradient(90deg,
    rgb(var(--c-amber, 217 119 6) / 0.35),
    rgb(var(--c-success, 5 150 105) / 0.55));
  transition: left 0.4s var(--ease-out, ease), width 0.4s var(--ease-out, ease);
}
.forecast-band-median {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 2px;
  border-radius: 1px;
  background: rgb(var(--c-primary, 36 9 82));
  transform: translateX(-1px);
}
.forecast-band-zero {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: rgb(var(--c-outline-variant, 228 231 238));
}
.forecast-band-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
  font-size: 0.625rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.forecast-band-labels .band-low  { color: rgb(var(--c-amber, 217 119 6)); font-weight: 600; }
.forecast-band-labels .band-mid  { color: var(--text-primary); font-weight: 700; }
.forecast-band-labels .band-high { color: rgb(var(--c-success, 5 150 105)); font-weight: 600; }

/* -- Risk chip row (downside scenarios) -- */
.risk-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}
.risk-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.625rem;
  font-weight: 600;
  background: rgb(var(--c-error-bg, 220 38 38) / 0.08);
  color: rgb(var(--c-error, 220 38 38));
}
.risk-chip.warn {
  background: rgb(var(--c-amber-bg, 217 119 6) / 0.08);
  color: rgb(var(--c-amber, 217 119 6));
}
.risk-chip .material-symbols-outlined { font-size: 12px; }

/* -- Downside scenario block (property detail) -- */
.downside-scenario {
  border-left: 3px solid rgb(var(--c-amber, 217 119 6));
  background: rgb(var(--c-amber-bg, 255 251 235) / 0.35);
  border-radius: 0 var(--radius-lg, 0.75rem) var(--radius-lg, 0.75rem) 0;
  padding: 1rem 1.25rem;
}
.downside-scenario .scenario-impact {
  font-size: 1.5rem;
  font-weight: 800;
  color: rgb(var(--c-amber, 217 119 6));
  font-variant-numeric: tabular-nums;
}
