/* ============================================================
   PropertyDesk — Floating cost calculator (js/cost-calculator.js)
   Uses design tokens from propertydesk.css
   ============================================================ */

.pdc-launcher {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 100px;
  background: var(--amber);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  transition: background 0.15s ease, transform 0.15s ease;
}
.pdc-launcher:hover { background: var(--amber-hover); transform: translateY(-1px); }
.pdc-launcher:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.pdc-launcher svg { width: 18px; height: 18px; }
[data-theme="dark"] .pdc-launcher { color: #0A0A0A; }

.pdc-panel {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 60px);
  z-index: 901;
  width: 400px;
  max-height: min(680px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
  font-family: var(--font-body);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.pdc-panel[hidden] { display: none; }
.pdc-panel--in { opacity: 1; transform: translateY(0); }

.pdc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--c-border);
}
.pdc-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--c-text);
}
.pdc-sub { font-size: 0.8125rem; color: var(--c-text-2); margin-top: 2px; }
.pdc-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text-2);
  cursor: pointer;
}
.pdc-close:hover { background: var(--c-bg-alt); color: var(--c-text); }
.pdc-close svg { width: 18px; height: 18px; }

.pdc-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pdc-field { display: flex; flex-direction: column; gap: 6px; }
.pdc-field > label,
.pdc-label { font-size: 0.8125rem; font-weight: 600; color: var(--c-text); }
.pdc-hint { font-size: 0.75rem; color: var(--c-text-2); }

.pdc-input {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--c-text);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
}
.pdc-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--c-teal-bg); }
.pdc-input--sm { width: 76px; }

.pdc-range-row { display: flex; align-items: center; gap: 12px; }
.pdc-range-row input[type="range"] { flex: 1; accent-color: var(--teal); }

.pdc-prefix { position: relative; }
.pdc-prefix span {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: var(--c-text-2);
}
.pdc-prefix .pdc-input { padding-left: 22px; }

.pdc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pdc-chip {
  padding: 6px 11px;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--c-text-4);
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: 100px;
  cursor: pointer;
}
.pdc-chip:hover { border-color: var(--c-text-3); }
.pdc-chip[aria-checked="true"] { background: var(--c-teal-bg); border-color: var(--teal); color: var(--teal); font-weight: 600; }

.pdc-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 4px; }
.pdc-custom[hidden] { display: none; }
.pdc-custom label,
.pdc-more__grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--c-text-4);
}

.pdc-toggles { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

.pdc-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8125rem; color: var(--c-text-4); cursor: pointer; }
.pdc-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pdc-switch__track {
  position: relative;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 100px;
  background: var(--c-border);
  transition: background 0.15s ease;
}
.pdc-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.pdc-switch input:checked + .pdc-switch__track { background: var(--teal); }
.pdc-switch input:checked + .pdc-switch__track::after { transform: translateX(14px); }
.pdc-switch input:focus-visible + .pdc-switch__track { outline: 2px solid var(--teal); outline-offset: 2px; }

.pdc-seg { display: inline-flex; border: 1px solid var(--c-border); border-radius: var(--r-sm); overflow: hidden; }
.pdc-seg[hidden] { display: none; }
.pdc-seg button {
  padding: 5px 10px;
  font: inherit;
  font-size: 0.75rem;
  color: var(--c-text-2);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.pdc-seg button + button { border-left: 1px solid var(--c-border); }
.pdc-seg button[aria-checked="true"] { background: var(--c-teal-bg); color: var(--teal); font-weight: 600; }
.pdc-seg em { font-style: normal; color: var(--amber); font-weight: 600; }

.pdc-more summary { font-size: 0.8125rem; color: var(--teal); font-weight: 500; cursor: pointer; }
.pdc-more__grid { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }

/* Results */
.pdc-results { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; border-top: 1px solid var(--c-border); }
.pdc-verdict {
  margin-top: 10px;
  padding: 10px 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--c-text-4);
  background: var(--c-bg-alt);
  border-radius: var(--r);
}
.pdc-verdict a { color: var(--teal); font-weight: 600; text-decoration: underline; }
.pdc-verdict--win { background: var(--c-teal-bg); color: var(--c-text); }
.pdc-verdict--win strong { color: var(--teal); }
.pdc-verdict--lose { background: var(--c-amber-bg); color: var(--c-text); }

.pdc-us { padding: 12px 14px; border: 1.5px solid var(--teal); border-radius: var(--r); }
.pdc-us__top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pdc-us__name { font-size: 0.875rem; font-weight: 600; color: var(--teal); }
.pdc-us__total { font-size: 1.25rem; font-weight: 700; color: var(--c-text); }
.pdc-us__total small,
.pdc-comp__total small { font-size: 0.75rem; font-weight: 400; color: var(--c-text-2); }
.pdc-us__annual { font-size: 0.75rem; color: var(--c-text-2); text-align: right; }
.pdc-us__extras { margin-top: 8px; font-size: 0.75rem; line-height: 1.45; color: var(--teal); }

.pdc-breakdown { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.pdc-breakdown li { display: flex; justify-content: space-between; gap: 8px; font-size: 0.75rem; color: var(--c-text-2); }

.pdc-comp { list-style: none; display: flex; flex-direction: column; }
.pdc-comp__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--c-border-sub);
}
.pdc-comp__row:last-child { border-bottom: 0; }
.pdc-comp__row > div { display: flex; flex-direction: column; }
.pdc-comp__name { font-size: 0.875rem; font-weight: 600; color: var(--c-text); }
.pdc-comp__note { font-size: 0.75rem; color: var(--c-text-2); }
.pdc-comp__total { font-size: 0.9375rem; font-weight: 600; color: var(--c-text); white-space: nowrap; }
.pdc-comp__row--na .pdc-comp__total { font-size: 0.8125rem; font-weight: 500; color: var(--c-text-3); }

.pdc-disclaimer { font-size: 0.6875rem; line-height: 1.5; color: var(--c-text-3); }

.pdc-cta {
  display: block;
  padding: 11px 16px;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--amber);
  border-radius: var(--r);
  transition: background 0.15s ease;
}
.pdc-cta:hover { background: var(--amber-hover); }
[data-theme="dark"] .pdc-cta { color: #0A0A0A; }

.pdc-email { display: flex; flex-direction: column; gap: 6px; }
.pdc-email__row { display: flex; gap: 8px; }
.pdc-email__btn {
  flex-shrink: 0;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--teal);
  background: transparent;
  border: 1px solid var(--teal);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.pdc-email__btn:hover { background: var(--c-teal-bg); }
.pdc-email__btn:disabled { opacity: 0.6; cursor: default; }
.pdc-email__msg { font-size: 0.75rem; color: var(--c-text-2); min-height: 1em; }

/* Mobile: bottom sheet */
@media (max-width: 640px) {
  .pdc-launcher { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); padding: 11px 16px; }
  .pdc-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 88vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  html.pdc-open .pdc-launcher { display: none; }
  html.pdc-open body { overflow: hidden; }
  .pdc-body { padding: 14px 16px 18px; }
  .pdc-head { padding: 16px 16px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .pdc-panel, .pdc-launcher { transition: none; }
}
