/* Dream Lands — EMI widget */
.emi-widget {
  margin: 1rem 0 .5rem;
  border-top: 1px solid var(--border);
  padding-top: .75rem;
}

/* Price + "Own this for ..." teaser sit side by side instead of stacked. */
.detail-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem .9rem;
}

.detail-price-row .detail-price {
  margin-bottom: 0;
}

.detail-price-row .emi-widget {
  margin: 0;
  border-top: none;
  padding-top: 0;
}

/* Collapsed 1-liner row */
.emi-teaser-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  cursor: pointer;
  user-select: none;
}

.emi-teaser-text {
  font-size: .85rem;
  font-weight: 600;
  color: var(--green-light);
}

.emi-teaser-expand {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  font-size: .72rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.emi-teaser-row:hover .emi-teaser-expand {
  color: var(--text);
}

/* ── EMI dialog (opened from the teaser row) ── */
.emi-dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  z-index: 3100;
  align-items: flex-end;
  justify-content: center;
}

.emi-dialog-overlay.open {
  display: flex;
}

.emi-dialog {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 460px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: dlg-slide-up .22s ease;
}

.emi-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-2);
}

.emi-dialog-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: .2rem;
  display: flex;
}

.emi-dialog-close:hover { color: var(--text); }

.emi-dialog-body {
  padding: 1.25rem;
}

@media (min-width: 480px) {
  .emi-dialog-overlay {
    align-items: center;
  }

  .emi-dialog {
    border-radius: 18px;
  }
}

.emi-widget-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}

.emi-widget-controls {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.emi-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--card-bg-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .28rem .55rem;
  font-size: .75rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.emi-edit-btn svg {
  color: var(--green-light);
  flex-shrink: 0;
}

.emi-edit-btn:hover {
  border-color: var(--green-light);
}

/* Price input editor */
.emi-price-editor {
  margin-bottom: .6rem;
}

.emi-editor-label {
  display: block;
  font-size: .7rem;
  color: var(--muted);
  margin-bottom: .3rem;
}

.emi-editor-input {
  width: 100%;
  background: var(--card-bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .45rem .7rem;
  font-size: .9rem;
  color: var(--text);
  font-family: inherit;
}

.emi-editor-input:focus {
  outline: none;
  border-color: var(--green-light);
}

/* Rate slider */
.emi-rate-editor {
  margin-bottom: .6rem;
}

.emi-slider-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.emi-slider-bound {
  font-size: .72rem;
  color: var(--muted);
  flex-shrink: 0;
}

.emi-slider {
  flex: 1;
  accent-color: var(--green-light);
  cursor: pointer;
}

/* EMI table */
.emi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.emi-table th {
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  padding: .3rem .4rem;
  border-bottom: 1px solid var(--border);
}

.emi-table td {
  padding: .45rem .4rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text);
}

.emi-table tr:last-child td {
  border-bottom: none;
}

.emi-val {
  font-weight: 700;
  color: var(--green-light);
}

.emi-interest {
  color: var(--muted);
}

/* ── Budget Finder dialog (reverse-EMI calculator, opened from Profile) ── */
.bf-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.bf-group {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.bf-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}

.bf-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bf-rate-value {
  font-size: .82rem;
  font-weight: 600;
  color: var(--green-light);
}

.bf-emi-slider {
  margin-top: .2rem;
}

.bf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.bf-chip {
  padding: .4rem .9rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card-bg-2);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}

.bf-chip.active {
  border-color: var(--green-light);
  background: rgba(76, 175, 80, .12);
  color: var(--text);
}

.bf-result {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  text-align: center;
}

.bf-result-label {
  font-size: .78rem;
  color: var(--muted);
}

.bf-result-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--green-light);
  margin: .2rem 0;
}

.bf-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin: .9rem 0 1rem;
}

.bf-result-stat {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  background: var(--card-bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem;
}

.bf-result-stat span {
  font-size: .68rem;
  color: var(--muted);
}

.bf-result-stat b {
  font-size: .92rem;
  color: var(--text);
}

.bf-cta {
  width: 100%;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .7rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}

.bf-cta:hover { background: #1b5e20; }

/* Two side-by-side outputs — home loan vs. loan against other property types —
   since the same EMI/tenure affords a different budget at each rate. */
.bf-loan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 560px) {
  .bf-loan-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.bf-loan-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.bf-loan-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
}

.bf-loan-section .bf-result-value {
  font-size: 1.5rem;
}

/* Budget Finder dialog itself: it's opened from Profile (a dropdown/overlay)
   but must also work while Explore/Map/Reels are open, all of which stack
   above the shared .prefs-dialog-backdrop z-index (1000) — so it needs to
   sit above every other overlay in the app regardless of which tab is active. */
#bf-dialog {
  z-index: 4100;
}

/* Icon swap: X to close on desktop, a back chevron on mobile (full page). */
.bf-close-icon-mobile {
  display: none;
}

@media (max-width: 768px) {
  .bf-close-icon-desktop { display: none; }
  .bf-close-icon-mobile { display: flex; }

  /* Back button sits before the title, left-aligned, like a mobile page header. */
  #bf-dialog .bf-dialog-header {
    justify-content: flex-start;
  }
  #bf-dialog .bf-close-btn {
    order: 0;
  }

  /* Full-page view on mobile, sliding in from the right (like the detail
     sheet's desktop panel) instead of the bottom-sheet dialog used elsewhere.
     The backdrop stays in the layout (not display:none) so the transform can
     animate; it's pushed off-screen via translateX when closed. */
  #bf-dialog.prefs-dialog-backdrop {
    display: flex;
    align-items: stretch;
    background: var(--bg);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .28s ease, visibility .28s ease;
  }
  #bf-dialog.prefs-dialog-backdrop.open {
    transform: translateX(0);
    visibility: visible;
  }
  #bf-dialog .prefs-dialog {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
    animation: none;
  }
}

/* Desktop: close button pinned to the far right via space-between (title
   comes first in the flex order, order:0, so it renders on the left). */
.bf-close-btn {
  order: 2;
}

/* Teaser line on reel cards */
.reel-card-emi {
  font-size: .72rem;
  color: rgba(255,255,255,.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: .1rem;
}
