/* Lead capture: viewer Enquire button + form, editor settings, share-modal
   upsell, dashboard leads inbox. Loaded on tour.php and dashboard.php. */

/* ----- Viewer: Enquire button (top-right control row) ----- */

.tour-leads-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  height: 3rem;
  margin-left: 10px;
  padding: 0 18px 0 15px;
  border: none;
  border-radius: 10rem;
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  color: #fff;
  font-family: 'Lato', sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s ease;
}

.tour-leads-toggle.visible {
  display: inline-flex;
}

.tour-leads-toggle:hover {
  background: rgba(0, 0, 0, 0.55);
  transform: scale(1.05);
}

.tour-leads-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.tour-leads-toggle svg {
  flex-shrink: 0;
}

.tour-leads-toggle__label {
  max-width: 14em;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fallback when a page has no control row */
.tour-leads-toggle--floating {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 13;
}

/* Mid widths: a long custom label must not push the row into the floor plan */
@media screen and (max-width: 899px) {
  .tour-leads-toggle__label {
    max-width: 8em;
  }
}

/* Small viewports and narrow embeds: same 3rem circle as gyro/VR/fullscreen,
   so the row never grows into the logo or floor plan on the left. */
@media screen and (max-width: 639px) {
  .tour-leads-toggle {
    width: 3rem;
    padding: 0;
    justify-content: center;
  }
  .tour-leads-toggle__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

body[data-vr-mode='true'] .tour-leads-toggle,
body[data-vr-mode='true'] #tour-leads-root,
body:has(#splash-screen.visible) .tour-leads-toggle {
  display: none !important;
}

/* ----- Viewer: enquiry dialog ----- */

#tour-leads-root[hidden],
.tour-leads-form[hidden],
.tour-leads-success[hidden],
.tour-leads-note[hidden],
.tour-leads-error[hidden],
.tour-leads-dialog__sub[hidden] {
  display: none !important;
}

.tour-leads-root {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: 'Lato', sans-serif;
}

.tour-leads-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  animation: tour-leads-fade 0.2s ease-out;
}

.tour-leads-dialog {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  color: #0f172a;
  animation: tour-leads-pop 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.tour-leads-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 12px;
  flex-shrink: 0;
}

.tour-leads-dialog__heading {
  min-width: 0;
}

.tour-leads-dialog__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  color: #0f172a;
}

.tour-leads-dialog__sub {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: #64748b;
  overflow-wrap: anywhere;
}

.tour-leads-dialog__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: -6px -8px 0 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.tour-leads-dialog__close:hover {
  background: #f1f5f9;
}

.tour-leads-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin: 0;
}

.tour-leads-dialog__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 20px 12px;
}

.tour-leads-field {
  margin-top: 12px;
}

.tour-leads-field:first-of-type {
  margin-top: 4px;
}

.tour-leads-field[hidden] {
  display: none !important;
}

.tour-leads-label {
  display: block;
  margin: 0 0 5px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

/* 16px stops iOS Safari zooming the page (and the embed) on focus */
.tour-leads-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 11px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.4;
  /* Empty date inputs collapse on iOS Safari; keep every control the same height */
  min-height: 46px;
}

/* Date/select/text all render at the same height (date pickers add their own padding) */
.tour-leads-input:not(.tour-leads-textarea) {
  height: 46px;
}

.tour-leads-input:focus {
  outline: none;
  border-color: #389af0;
  box-shadow: 0 0 0 3px rgba(56, 154, 240, 0.18);
}

.tour-leads-textarea {
  min-height: 96px;
  resize: vertical;
}

.tour-leads-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.tour-leads-consent {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #64748b;
}

.tour-leads-consent a {
  color: #389af0;
  text-decoration: underline;
}

.tour-leads-note {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef3c7;
  color: #92400e;
  font-size: 13px;
  line-height: 1.45;
}

.tour-leads-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.45;
}

.tour-leads-dialog__actions {
  flex-shrink: 0;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.tour-leads-dialog .button.full-width {
  display: block;
  width: 100%;
  margin: 0;
  padding: 15px 20px;
  border-radius: 14px;
  text-align: center;
  font-size: 16px;
  /* .button capitalizes each word; keep sentence case in every language */
  text-transform: none;
}

.tour-leads-submit[disabled] {
  opacity: 0.7;
  cursor: progress;
}

.tour-leads-success {
  padding: 8px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  overflow-y: auto;
}

.tour-leads-success__icon {
  width: 56px;
  height: 56px;
  margin: 4px auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #379af0, #898bff);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  line-height: 56px;
}

.tour-leads-success__title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
}

.tour-leads-success__body {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.5;
  color: #475569;
  overflow-wrap: anywhere;
}

/* Phones and short embeds: bottom sheet that scrolls internally */
@media screen and (max-width: 639px) {
  .tour-leads-root {
    align-items: flex-end;
    padding: 0;
  }
  .tour-leads-dialog {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    animation-name: tour-leads-sheet;
  }
}

@media screen and (max-height: 480px) {
  .tour-leads-root {
    align-items: stretch;
    padding: 8px;
  }
  .tour-leads-dialog {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    margin: 0 auto;
    border-radius: 16px;
  }
  .tour-leads-dialog__header {
    padding: 14px 16px 8px;
  }
  .tour-leads-textarea {
    min-height: 64px;
  }
}

@keyframes tour-leads-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tour-leads-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes tour-leads-sheet {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .tour-leads-backdrop,
  .tour-leads-dialog {
    animation: none;
  }
}

/* ----- Editor: tour settings ----- */

.lead-capture-config-wrap {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.lead-capture-config-wrap[hidden],
#lead-capture-publish-note[hidden] {
  display: none !important;
}

.lead-capture-config-wrap .input-field {
  margin-bottom: 6px;
}

.lead-capture-inbox-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: #389af0;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.lead-capture-inbox-link:hover {
  text-decoration: underline;
}

/* ----- Share modal: free-owner upsell (sits under the share tools) ----- */

.share-lead-upsell {
  margin-top: 16px;
  margin-bottom: 0;
}

.share-lead-upsell__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  color: #389af0;
  box-shadow: 0 2px 8px rgba(55, 154, 240, 0.18);
}

.share-lead-upsell__text {
  color: #334155;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.share-lead-upsell__cta {
  display: inline-block;
  border: none;
  background: linear-gradient(135deg, #379af0 0%, #898bff 100%);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.share-lead-upsell__cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(55, 154, 240, 0.35);
}

/* ----- Dashboard: leads tab + inbox ----- */

/* Tab: label + one badge (PRO for free owners, else the enquiry count) */
#dashboard-tab-leads {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dashboard-tab:focus {
  outline: none;
}

.dashboard-tab:focus-visible {
  outline: 2px solid #389af0;
  outline-offset: 2px;
}

.dashboard-tab__count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  color: #111;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.dashboard-tab.is-active .dashboard-tab__count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.dashboard-tab__pro[hidden],
.dashboard-tab__count[hidden] {
  display: none !important;
}

.dashboard-tabs {
  flex-wrap: wrap;
}

.dashboard-leads-section {
  margin-bottom: 2rem;
}

.dashboard-leads-section [hidden] {
  display: none !important;
}

/* Upsell card (free owners). .is-compact = banner above existing enquiries */
.dashboard-leads-upgrade {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  padding: 1.75rem 2rem;
  border-radius: 16px;
  background: linear-gradient(135deg, #e8f4fd 0%, #f0e8ff 100%);
  border: 1px solid rgba(55, 154, 240, 0.15);
}

.dashboard-leads-upgrade__body {
  flex: 1;
  min-width: 0;
}

.dashboard-leads-upgrade__title {
  margin: 0 0 0.375rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  color: #111;
}

.dashboard-leads-upgrade__stat,
.dashboard-leads-upgrade__sub {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.dashboard-leads-upgrade__stat {
  margin-bottom: 0.25rem;
  font-weight: 700;
  color: #111;
}

.dashboard-leads-upgrade__sub {
  color: #555;
}

.dashboard-leads-section .dashboard-leads-upgrade__cta {
  flex-shrink: 0;
  margin: 0;
  padding: 0.75rem 1.375rem;
  border-radius: 999px;
  text-transform: none;
  white-space: nowrap;
}

.dashboard-leads-upgrade.is-compact {
  padding: 1rem 1.25rem;
  border-radius: 12px;
}

.dashboard-leads-upgrade.is-compact .dashboard-leads-upgrade__title {
  font-size: 1rem;
  margin-bottom: 0.125rem;
}

.dashboard-leads-upgrade.is-compact .dashboard-leads-upgrade__sub {
  font-size: 0.875rem;
}

/* Toolbar: tour filter · count · export */
.dashboard-leads-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.dashboard-leads-filter {
  flex: 0 1 360px;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  background-color: #fff;
  color: #111;
  font-family: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

.dashboard-leads-summary {
  margin: 0 0 0 auto;
  color: #666;
  font-size: 0.875rem;
  white-space: nowrap;
}

.dashboard-leads-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid #111;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.dashboard-leads-export:hover {
  background: #333;
}

.dashboard-leads-export[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Lead rows */
.dashboard-leads-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dashboard-lead-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.625rem 1rem;
  padding: 1.125rem 1.25rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.dashboard-lead-row__who {
  min-width: 0;
}

.dashboard-lead-row__name {
  margin: 0 0 0.25rem;
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1.3;
  color: #111;
  overflow-wrap: anywhere;
}

.dashboard-lead-row__contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.875rem;
}

.dashboard-lead-row__contact a {
  color: #389af0;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.dashboard-lead-row__contact a:hover {
  text-decoration: underline;
}

.dashboard-lead-row__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.125rem;
  font-size: 0.8125rem;
  color: #666;
  white-space: nowrap;
}

.dashboard-lead-row__tour {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  color: #333;
}

.dashboard-lead-row__extra {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dashboard-lead-row__extra li {
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 0.8125rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.dashboard-lead-row__extra-label {
  color: #64748b;
}

.dashboard-lead-row__message {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.75rem 0.875rem;
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 0.9375rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dashboard-lead-row__source {
  grid-column: 1 / -1;
  font-size: 0.8125rem;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-lead-row__source a {
  color: inherit;
}

.dashboard-leads-empty,
.dashboard-leads-loading,
.dashboard-leads-error {
  padding: 2rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.dashboard-leads-empty p {
  margin: 0;
  color: #666;
}

.dashboard-leads-empty__title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

@media (max-width: 700px) {
  .dashboard-leads-upgrade {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
  }
  .dashboard-leads-upgrade__title {
    font-size: 1.25rem;
  }
  .dashboard-leads-upgrade.is-compact {
    flex-direction: row;
    align-items: center;
  }
}

@media (max-width: 600px) {
  .dashboard-lead-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .dashboard-lead-row__meta {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.5rem;
    white-space: normal;
  }
  .dashboard-lead-row__tour {
    max-width: 100%;
  }
  .dashboard-leads-filter {
    flex: 1 1 100%;
  }
  .dashboard-leads-summary {
    margin-left: 0;
  }
  .dashboard-leads-export {
    margin-left: auto;
  }
  .dashboard-leads-upgrade.is-compact {
    flex-direction: column;
    align-items: flex-start;
  }
  .dashboard-leads-empty,
  .dashboard-leads-loading,
  .dashboard-leads-error {
    padding: 1.25rem;
  }
}

/* Tour card: envelope button next to Preview / Comments (owners, lead capture on) */
.tours-grid .tour-item .button.leads-tour {
  position: relative;
  background: #f5f5f7;
  color: #888;
  text-align: center;
  border: none;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tours-grid .tour-item .button.leads-tour svg {
  width: 20px;
  height: 20px;
}

.tours-grid .tour-item .button.leads-tour:hover {
  background: #ede9fe;
  color: #6d5bd0;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(109, 91, 208, 0.12);
}

.tours-grid .tour-item .button.leads-tour .leads-tour-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.tours-grid .tour-item .button.leads-tour[data-tooltip]:before,
.tours-grid .tour-item .button.leads-tour[data-tooltip]:after {
  left: 50%;
  right: auto;
  bottom: calc(100% + var(--arrow-size));
  top: auto;
}
