/**
 * Rental Calculator page styles
 * Extracted from Views/Home/NewRentalCalculator.cshtml
 */

/* Page layout */
.calc-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 32px 80px;
}

.calc-page__hero {
    text-align: center;
    margin-bottom: 48px;
}

.calc-page__tag {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--sam-red);
    margin-bottom: 12px;
}

.calc-page__title {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.1;
    margin: 0 0 14px;
}

.calc-page__desc {
    font-size: var(--text-md);
    color: var(--sam-brown-dark);
    max-width: 520px;
    margin: 0 auto;
}

/* One centred line of selling points under the intro, each with a leading
   middle dot; wraps onto further lines on narrow screens. */
.calc-page__usps {
    list-style: none;
    margin: var(--s-4) 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s-1) var(--s-3);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--sam-dark);
}

.calc-page__usps li::before {
    content: "·";
    margin-right: var(--s-3);
    color: var(--sam-red);
    font-weight: 700;
}

/* Calculator grid */
.calc-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 28px;
    align-items: start;
}

/* Form card - scoped to calculator */
.calc-card {
    background: var(--sam-white);
    border: 1px solid var(--sam-light);
    border-radius: var(--radius-xl);
    padding: 28px;
    margin-bottom: 20px;
}

.calc-adjust {
    margin-top: var(--s-4);
    padding-top: var(--s-4);
    border-top: 1px solid var(--border-default);
}

.calc-adjust__title {
    font-size: var(--text-base);
    font-weight: 800;
    margin: 0 0 var(--s-3);
}

.calc-card__title {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.01em;
    margin: 0 0 20px;
}

.calc-input--with-icon {
    padding-right: 42px;
}

/* Select pickers. The native <select> popup is drawn by the browser/OS, not
   the page, so it ignores our CSS and can come out wider than the field
   (e.g. under browser zoom or fractional display scaling) and spill over the
   result card. Where customizable selects are supported, render the picker
   in-page instead and pin it to the field's width; elsewhere the native popup
   stays as the fallback. Picker look mirrors .calc-autocomplete. */
@supports (appearance: base-select) {
    .calc-card select.field__select,
    .calc-card select.field__select::picker(select) {
        appearance: base-select;
    }

    .calc-card select.field__select {
        display: flex;
        align-items: center;
        color: var(--text-primary);
    }

    /* The design-system chevron is the field's background image. */
    .calc-card select.field__select::picker-icon {
        display: none;
    }

    .calc-card select.field__select::picker(select) {
        box-sizing: border-box;
        width: anchor-size(width);
        max-height: 300px;
        margin-block: 4px;
        padding: 0;
        background: var(--sam-white);
        border: 1.5px solid var(--sam-light);
        border-radius: 10px;
        box-shadow: var(--shadow-2);
    }

    .calc-card select.field__select option {
        padding: 12px 14px;
        transition: background 0.15s;
    }

    .calc-card select.field__select option::checkmark {
        display: none;
    }

    .calc-card select.field__select option:checked {
        font-weight: 700;
    }

    .calc-card select.field__select option:hover,
    .calc-card select.field__select option:focus-visible {
        background: var(--sam-brown-light);
    }

    /* Inset the focus ring; the picker clips an outset one at its edges. */
    .calc-card select.field__select option:focus-visible {
        outline-offset: -2px;
    }
}

/* Autocomplete wrapper - must be position:relative for dropdown positioning */
.calc-field__autocomplete-wrap {
    position: relative;
}

/* Input wrapper for loader positioning */
.calc-input-wrap {
    position: relative;
}

.calc-input__loader {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    color: var(--sam-medium);
}

.calc-input__loader.is-loading {
    display: flex;
}

.calc-input__spinner {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-dasharray: 32;
    stroke-dashoffset: 12;
    animation: calc-spin 0.8s linear infinite;
}

/* Chip buttons */
.chip-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip-btn {
    padding: 8px 16px;
    border: 1.5px solid var(--sam-light);
    border-radius: var(--radius-pill);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    background: var(--sam-white);
    color: var(--sam-brown-dark);
    transition: all .12s;
}

.chip-btn:hover {
    border-color: var(--text-primary);
}

.chip-btn.on {
    background: var(--sam-dark);
    color: #fff;
    border-color: var(--text-primary);
}

/* Toggle row */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--sam-light);
}

.toggle-row:last-child {
    border-bottom: none;
}

.toggle-row .label {
    font-size: 14px;
    font-weight: 600;
}

.toggle-row .sub {
    font-size: 12.5px;
    color: var(--sam-medium);
}

/* Toggle switch */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle .track {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--sam-light);
    transition: background .2s;
    position: relative;
    flex-shrink: 0;
}

.toggle input:checked ~ .track {
    background: var(--sam-dark);
}

.toggle .thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-1);
    transition: transform .2s;
}

.toggle input:checked ~ .track .thumb {
    transform: translateX(20px);
}

/* Result column layout */
.calc-result-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Result card: a light card like the form, figure first */
.result-card {
    background: var(--sam-white);
    border: 1px solid var(--sam-light);
    border-radius: var(--radius-xl);
    padding: 28px;
}

.result-card__eyebrow {
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--sam-red-dark, var(--sam-red));
    margin-bottom: 12px;
}

.result-card__label {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.result-card__price {
    display: flex;
    align-items: baseline;
    gap: 0 8px;
    white-space: nowrap;
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
}

.result-card__unit {
    font-size: var(--text-lg);
    font-weight: 700;
}

.result-card__range {
    margin: 4px 0 0;
    font-size: var(--text-sm);
    color: var(--sam-brown-dark);
}

.result-card__period {
    font-size: var(--text-base);
    color: rgba(255, 255, 255, .5);
    margin-bottom: 24px;
}

/* Breakdown rows */
.result-card__breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.result-card__row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.result-card__row-key {
    color: rgba(255, 255, 255, .6);
}

.result-card__row-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.result-card__row--total {
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding-top: 10px;
    font-size: var(--text-base);
}

.result-card__row--total .result-card__row-key {
    color: rgba(255, 255, 255, .9);
}

.result-card__row--total .result-card__row-value {
    color: var(--sam-red);
    font-size: 18px;
}

/* Comparison bar */
.result-card__comp-bar {
    margin-bottom: 20px;
}

.result-card__comp-label {
    font-size: 12px;
    color: rgba(255, 255, 255, .5);
    margin-bottom: 6px;
}

.result-card__bar-track {
    height: 6px;
    background: rgba(255, 255, 255, .12);
    border-radius: 3px;
    overflow: hidden;
}

.result-card__bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--sam-red);
    transition: width .5s ease;
}

.result-card__bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: rgba(255, 255, 255, .35);
    margin-top: 4px;
}


/* Variant F's broad range stays on one line: the size follows the viewport on narrow screens. */
.result-card__price--range {
    flex-wrap: wrap;
    font-size: clamp(1.5rem, 6.5vw, 32px);
}

.result-card__basis {
    margin: 4px 0 16px;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--sam-brown-dark);
}

.result-card__weak {
    margin-bottom: 16px;
}

/* "När vill du hyra ut?" and "flera bostäder" above the actions */
.calc-lead {
    margin: 0 0 16px;
}

.calc-lead .field__label {
    margin-bottom: 8px;
}

.calc-lead__several {
    margin-top: 12px;
    font-size: var(--text-sm);
    line-height: 1.45;
}

.result-card__actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card__create {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-card__note {
    margin: 0;
    font-size: var(--text-sm);
    text-align: center;
    color: var(--text-secondary);
}

/* Weak basis: talking to an adviser comes first */
.result-card__actions--contact-first .calc-alts__item--contact {
    order: -1;
    padding-top: 0;
    border-top: 0;
}

.result-card__more {
    margin-top: 16px;
    border: 1px solid var(--sam-light);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
}

.result-card__more summary {
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 700;
}

.result-card__more-text {
    margin: 12px 0 8px;
    font-size: var(--text-sm);
    line-height: 1.55;
    color: var(--sam-brown-dark);
}

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

.result-card__comp {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid var(--sam-light);
    font-size: var(--text-sm);
}

.result-card__comp:last-child {
    border-bottom: 0;
}

.result-card__comp strong {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.result-card__disclaimer {
    margin: 12px 0 0;
    font-size: var(--text-xs);
    line-height: 1.55;
    color: var(--text-secondary);
}

/* Contact and rent watch inside the result card */
.calc-alts__item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--sam-light);
}

.calc-alts__title {
    margin: 0;
    font-size: var(--text-base);
    font-weight: 800;
}

.calc-alts__optional {
    font-weight: 400;
    color: var(--text-secondary);
}

.calc-alts__toggle,
.calc-alts__submit,
.result-card__btn {
    width: 100%;
    justify-content: center;
    white-space: normal;
    text-wrap: balance;
}

.calc-alts__panel {
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--surface-warm);
}

.calc-alts__panel form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.calc-alts__panel .field {
    margin-bottom: 0;
}

.calc-alts__lead {
    margin: 0;
    font-size: var(--text-sm);
    line-height: 1.55;
    color: var(--sam-brown-dark);
}

.calc-alts__when .field__label {
    margin-bottom: 8px;
}

.calc-alts__error {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-danger);
}

.calc-alts__done {
    margin: 0;
    font-size: var(--text-sm);
    line-height: 1.55;
    font-weight: 600;
}

.calc-alts__done p {
    margin: 0;
}

.calc-alts__done:focus {
    outline: none;
}

.calc-alts__handover {
    margin-top: 8px;
    font-size: var(--text-xs);
    font-weight: 400;
}

.calc-alts__handover summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text-link);
}

.calc-alts__handover-list {
    margin: 4px 0 0;
    padding-left: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* The figure as a bar at the bottom while the result card (phones) or the figure (desktop) is out of view */
.calc-sticky {
    position: fixed;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    width: min(560px, calc(100% - 24px));
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--sam-light);
    border-radius: var(--radius-lg);
    background: var(--sam-white);
    color: var(--sam-dark);
    box-shadow: var(--shadow-3);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.calc-sticky__label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
}

.calc-sticky__price {
    flex: 1;
    font-size: var(--text-lg);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.calc-sticky__show {
    font-size: var(--text-sm);
    font-weight: 700;
    text-decoration: underline;
}

/* [hidden] must win over the display rules above */
.calc-page [hidden],
.calc-sticky[hidden] {
    display: none !important;
}

/* Comparables */
.comps {
    margin-top: 4px;
}

.comps__title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(255, 255, 255, .4);
    margin-bottom: 12px;
}

.comp-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.comp-row:last-child {
    border-bottom: none;
}

.comp-row__thumb {
    width: 36px;
    height: 28px;
    border-radius: 5px;
    flex-shrink: 0;
}

.comp-row__info {
    flex: 1;
    font-size: 12.5px;
    color: rgba(255, 255, 255, .65);
}

.comp-row__info b {
    color: #fff;
    display: block;
    font-size: var(--text-sm);
}

.comp-row__price {
    font-size: var(--text-sm);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Placeholder card */
/* Before an address is picked: one compact row. On phones, where the column sits
   under the form, the empty state is hidden; "too little data" still shows. */
.result-placeholder {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--sam-white);
    border: 1px solid var(--sam-light);
    border-radius: var(--radius-xl);
    padding: 16px 20px;
}

.result-placeholder[hidden] {
    display: none;
}

.result-placeholder__icon {
    flex: none;
    width: 40px;
    height: 40px;
    background: rgba(255, 109, 89, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sam-red);
}

.result-placeholder__icon svg {
    width: 20px;
    height: 20px;
}

.result-placeholder__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 2px;
    color: var(--sam-dark);
}

.result-placeholder__text {
    font-size: 14px;
    color: var(--sam-medium);
    margin: 0;
    line-height: 1.45;
}

@media (max-width: 900px) {
    .result-placeholder--empty {
        display: none;
    }
}

/* Trustpilot reviews - must not be sticky, stays behind result card */
.calc-reviews {
    margin-top: 16px;
    position: relative;
    z-index: 1;
}

/* Ensure Trustpilot iframe doesn't inherit sticky behavior */
.calc-reviews iframe,
.calc-reviews > div {
    position: relative !important;
}

/* Autocomplete dropdown */
.calc-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid var(--sam-light);
    border-radius: 10px;
    margin-top: 4px;
    box-shadow: var(--shadow-2);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.calc-autocomplete.is-open {
    display: block;
}

.calc-autocomplete__item {
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.calc-autocomplete__item:hover,
.calc-autocomplete__item.is-active {
    background: var(--sam-brown-light);
}

/* Spinner animation */
.spinner {
    animation: calc-spin 1s linear infinite;
}

@keyframes calc-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 900px) {
    .calc-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 480px) {
    .calc-page {
        padding: 24px 16px 60px;
    }

    .calc-page__title {
        font-size: 28px;
    }

    .calc-page__desc {
        font-size: 14px;
    }

    .calc-card {
        padding: 20px;
    }

    #rent-place-search::placeholder {
        font-size: 13px;
    }
}

/* Tweaks panel (dev mode) */
.calc-tweaks {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #fff;
    border: 1px solid var(--sam-light);
    border-radius: 14px;
    padding: 20px;
    width: 220px;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-3);
    z-index: 9999;
    font-size: 14px;
}

.calc-tweaks[hidden] {
    display: none;
}

.calc-tweaks:not([hidden]) {
    display: flex;
}

.calc-tweaks__title {
    font-weight: 700;
    font-size: 12px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--sam-medium);
}

.calc-tweaks__text {
    font-size: 13px;
    color: var(--sam-brown-dark);
}

/* ── Below-the-calculator bands ──────────────────────────────────────────────
   .calc-page is a narrow (1100px) centred column; the Trygghetspaket block and
   the two promo cards are full-bleed sections that sit after it, so they get
   their own vertical rhythm rather than inheriting the calculator's. */
.calc-band {
    padding: 56px 0;
}

.calc-promos {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-4);
    align-items: stretch;
}

.calc-promo {
    display: flex;
    background: var(--sam-white);
    border: 1px solid var(--sam-light);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

/* Photo keeps a fixed share of the card so both cards stay the same height
   whichever copy is longer. */
.calc-promo__img {
    width: 38%;
    object-fit: cover;
    flex-shrink: 0;
}

.calc-promo__body {
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.calc-promo__title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.01em;
    margin: 0;
}

.calc-promo__text {
    font-size: var(--text-sm);
    color: var(--sam-brown-dark);
    margin: 0 0 6px;
}

.calc-promo--dark {
    background: var(--sam-dark);
    border-color: var(--sam-dark);
    color: var(--sam-white);
}

.calc-promo--dark .calc-promo__text {
    color: color-mix(in oklab, var(--sam-white) 78%, transparent);
}

/* "Har du frågor?" card directly under the FAQ list. */
.calc-faq__contact {
    margin-top: var(--s-5);
}

@media (max-width: 900px) {
    .calc-band {
        padding: 36px 0;
    }

    .calc-promos {
        grid-template-columns: 1fr;
    }

    /* Stacked, the photo becomes a banner rather than a tall side panel. */
    .calc-promo {
        flex-direction: column;
    }

    .calc-promo__img {
        width: 100%;
        height: 180px;
    }
}

/* ── Mobile density ──────────────────────────────────────────────────────────
   On one column the result card sits below the whole form, so every gap in the
   form is scroll between the visitor and "Rekommenderad hyra". The desktop
   rhythm is kept; the phone layout is tightened. */
@media (max-width: 900px) {
    .calc-page {
        padding-top: 24px;
    }

    .calc-page__hero {
        margin-bottom: 24px;
    }

    .calc-grid {
        gap: 16px;
    }

    .calc-card {
        padding: 20px;
        margin-bottom: 16px;
    }

    .calc-card__title {
        margin-bottom: 14px;
    }
}

@media (max-width: 480px) {
    .calc-page {
        padding: 16px 16px 48px;
    }

    .calc-page__hero {
        margin-bottom: 20px;
    }

    .calc-card {
        padding: 16px;
    }

    .calc-promo__body {
        padding: 20px;
    }
}
