/*
 * Ciudad Home - Comparador de propiedades
 * Este archivo debe conservar una copia publicada en:
 * public/themes/flex-home/css/property-compare.css
 */

:root {
    --ch-compare-primary: var(--primary-color, #ff3e0c);
    --ch-compare-primary-dark: var(--primary-color-hover, #df3609);
    --ch-compare-text: #262626;
    --ch-compare-muted: #747474;
    --ch-compare-border: #e9e9e9;
    --ch-compare-soft: #fff4f2;
    --ch-compare-shadow: 0 12px 32px rgba(35, 35, 35, 0.16);
}

/* Botones de selección: tarjetas y ficha pública */
.ch-compare-toggle {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    z-index: 8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 15px;
    border: 1px solid #dde1e5;
    border-radius: 9px;
    background: #fff;
    color: #ff3e0c;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: none;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
    touch-action: manipulation;
}

.ch-compare-toggle:hover,
.ch-compare-toggle:focus {
    border-color: #ff3e0c;
    background: var(--ch-compare-soft);
    color: var(--ch-compare-primary-dark);
    box-shadow: 0 5px 14px rgba(255, 75, 57, .16);
    outline: none;
}

.ch-compare-toggle:focus-visible {
    outline: 3px solid rgba(255, 75, 57, .22);
    outline-offset: 2px;
}

.ch-compare-toggle:active {
    transform: translateY(1px);
}

.ch-compare-toggle i {
    font-size: 13px;
    line-height: 1;
}

.ch-compare-toggle__remove {
    display: none;
}

.ch-compare-toggle[aria-pressed="true"] {
    border-color: var(--ch-compare-primary);
    background: var(--ch-compare-primary);
    color: #fff;
}

.ch-compare-toggle[aria-pressed="true"]:hover,
.ch-compare-toggle[aria-pressed="true"]:focus {
    border-color: var(--ch-compare-primary-dark);
    background: var(--ch-compare-primary-dark);
    color: #fff;
}

.ch-compare-toggle[aria-pressed="true"] .ch-compare-toggle__add {
    display: none;
}

.ch-compare-toggle[aria-pressed="true"] .ch-compare-toggle__remove {
    display: inline;
}

.ch-compare-toggle--card {
    width: 100%;
    margin-top: 12px;
}

.item .description .ch-compare-toggle--card {
    display: flex;
}

.ch-compare-toggle--detail {
    width: auto;
    min-height: 34px;
    margin: 0;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
}

.ch-property-price-row .ch-compare-toggle--detail {
    flex: 0 0 auto;
}

/* Barra flotante */
.ch-compare-bar {
    position: fixed;
    z-index: 1055;
    right: 22px;
    bottom: 22px;
    left: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    max-width: 760px;
    min-height: 68px;
    margin: 0 auto;
    padding: 12px 14px 12px 18px;
    border: 1px solid rgba(255, 75, 57, .2);
    border-radius: 15px;
    background: rgba(255, 255, 255, .98);
    box-shadow: var(--ch-compare-shadow);
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px);
    transition: opacity .22s ease, visibility .22s ease, transform .22s ease;
}

.ch-compare-bar.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ch-compare-bar__info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ch-compare-bar__icon {
    display: inline-flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ch-compare-soft);
    color: #ff3e0c;
    font-size: 16px;
}

.ch-compare-bar__copy {
    min-width: 0;
}

.ch-compare-bar__copy strong,
.ch-compare-bar__copy span {
    display: block;
}

.ch-compare-bar__copy strong {
    color: var(--ch-compare-text);
    font-size: 14px;
    font-weight: 700;
}

.ch-compare-bar__copy span {
    margin-top: 2px;
    overflow: hidden;
    color: var(--ch-compare-muted);
    font-size: 12px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-compare-bar__actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.ch-compare-bar__clear,
.ch-compare-bar__open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 9px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.ch-compare-bar__clear {
    padding: 8px 10px;
    border: 0;
    background: transparent;
    color: #747474;
}

.ch-compare-bar__clear:hover,
.ch-compare-bar__clear:focus {
    color: var(--ch-compare-text);
    outline: none;
}

.ch-compare-bar__open {
    padding: 9px 16px;
    border: 1px solid var(--ch-compare-primary);
    background: var(--ch-compare-primary);
    color: #fff !important;
}

.ch-compare-bar__open:hover,
.ch-compare-bar__open:focus {
    border-color: var(--ch-compare-primary-dark);
    background: var(--ch-compare-primary-dark);
    color: #fff !important;
    outline: none;
}

.ch-compare-bar__open.is-disabled {
    border-color: #d7d7d7;
    background: #d7d7d7;
    color: #777 !important;
    cursor: not-allowed;
    pointer-events: none;
}

/* Avisos breves */
.ch-compare-toast {
    position: fixed;
    z-index: 1060;
    top: 86px;
    right: 22px;
    max-width: min(360px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: 10px;
    background: #262626;
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .2);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}

.ch-compare-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Página de comparación */
.ch-compare-page {
    padding: 42px 0 70px;
    background: #f8f8f8;
}

.ch-compare-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.ch-compare-eyebrow {
    display: block;
    margin-bottom: 6px;
    color: var(--ch-compare-primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.ch-compare-heading h1 {
    margin: 0 0 7px;
    color: var(--ch-compare-text);
    font-size: clamp(26px, 3vw, 38px);
    font-weight: 700;
    line-height: 1.15;
}

.ch-compare-heading p {
    margin: 0;
    color: var(--ch-compare-muted);
    font-size: 14px;
}

.ch-compare-back,
.ch-compare-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none !important;
}

.ch-compare-back {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid var(--ch-compare-primary);
    background: #fff;
    color: var(--ch-compare-primary) !important;
}

.ch-compare-back:hover,
.ch-compare-back:focus {
    background: var(--ch-compare-primary);
    color: #fff !important;
}

.ch-compare-scroll {
    overflow-x: auto;
    width: 100%;
    border: 1px solid var(--ch-compare-border);
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 7px 22px rgba(36, 36, 36, .06);
    -webkit-overflow-scrolling: touch;
}

.ch-compare-scroll:focus {
    outline: 3px solid rgba(255, 75, 57, .18);
    outline-offset: 2px;
}

.ch-compare-table {
    width: 100%;
    min-width: 760px;
    margin: 0;
    border: 0;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    color: var(--ch-compare-text);
}

.ch-compare-table th,
.ch-compare-table td {
    padding: 15px 17px;
    border-right: 1px solid var(--ch-compare-border);
    border-bottom: 1px solid var(--ch-compare-border);
    background: #fff;
    font-size: 13px;
    line-height: 1.45;
    vertical-align: middle;
}

.ch-compare-table tr:last-child th,
.ch-compare-table tr:last-child td {
    border-bottom: 0;
}

.ch-compare-table th:last-child,
.ch-compare-table td:last-child {
    border-right: 0;
}

.ch-compare-label {
    position: sticky;
    left: 0;
    z-index: 3;
    width: 190px;
    min-width: 190px;
    color: #555;
    font-weight: 700;
    text-align: left;
}

.ch-compare-label--top {
    z-index: 5;
    vertical-align: bottom !important;
}

.ch-compare-label--top span,
.ch-compare-label--top small {
    display: block;
}

.ch-compare-label--top span {
    color: var(--ch-compare-text);
    font-size: 14px;
}

.ch-compare-label--top small {
    margin-top: 5px;
    color: var(--ch-compare-muted);
    font-size: 11px;
    font-weight: 500;
}

.ch-compare-property-head {
    width: 245px;
    min-width: 245px;
    padding: 0 !important;
    vertical-align: top !important;
}

.ch-compare-card {
    position: relative;
    min-height: 100%;
    background: #fff;
}

.ch-compare-card__image {
    display: block;
    overflow: hidden;
    height: 155px;
    background: #eee;
}

.ch-compare-card__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .25s ease;
}

.ch-compare-card__image:hover img {
    transform: scale(1.025);
}

.ch-compare-card__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 14px 16px 17px;
}

.ch-compare-card__code {
    color: var(--ch-compare-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.ch-compare-card__title {
    display: -webkit-box;
    overflow: hidden;
    color: var(--ch-compare-text) !important;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    text-decoration: none !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.ch-compare-card__title:hover {
    color: var(--ch-compare-primary) !important;
}

.ch-compare-card__location {
    display: -webkit-box;
    overflow: hidden;
    color: var(--ch-compare-muted);
    font-size: 12px;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.ch-compare-card__location i {
    margin-right: 4px;
    color: var(--ch-compare-primary);
}

.ch-compare-card__price {
    margin-top: 3px;
    color: var(--ch-compare-primary);
    font-size: 16px;
    font-weight: 800;
}

.ch-compare-remove {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    z-index: 2;
    top: 9px;
    right: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 50%;
    background: rgba(255, 255, 255, .95);
    color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .14);
    cursor: pointer;
}

.ch-compare-remove:hover,
.ch-compare-remove:focus {
    border-color: var(--ch-compare-primary);
    background: var(--ch-compare-primary);
    color: #fff;
    outline: none;
}

.ch-compare-section-row th {
    position: static;
    padding: 12px 17px;
    background: var(--ch-compare-soft);
    color: var(--ch-compare-primary-dark);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .02em;
    text-align: left;
}

.ch-compare-value-strong,
.ch-compare-price {
    color: var(--ch-compare-text);
    font-weight: 700;
}

.ch-compare-muted {
    color: var(--ch-compare-muted);
}

.ch-compare-actions-row td {
    text-align: left;
}

.ch-compare-view {
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--ch-compare-primary);
    background: var(--ch-compare-primary);
    color: #fff !important;
}

.ch-compare-view:hover,
.ch-compare-view:focus {
    border-color: var(--ch-compare-primary-dark);
    background: var(--ch-compare-primary-dark);
    color: #fff !important;
}

.ch-compare-note {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 18px 0 0;
    padding: 13px 15px;
    border: 1px solid #f0e5e3;
    border-radius: 10px;
    background: #fff;
    color: var(--ch-compare-muted);
    font-size: 12px;
    line-height: 1.5;
}

.ch-compare-note i {
    margin-top: 2px;
    color: var(--ch-compare-primary);
}

@media (max-width: 767px) {
    .ch-compare-toggle--detail {
        width: auto;
        min-height: 32px;
        margin: 0;
        padding: 6px 11px;
        font-size: 12px;
    }

    .ch-compare-bar {
        right: 10px;
        bottom: 10px;
        left: 10px;
        gap: 10px;
        min-height: 62px;
        padding: 10px 10px 10px 12px;
        border-radius: 13px;
    }

    .ch-compare-bar__icon,
    .ch-compare-bar__clear {
        display: none;
    }

    .ch-compare-bar__info {
        gap: 0;
        max-width: calc(100% - 112px);
    }

    .ch-compare-bar__copy strong {
        font-size: 13px;
    }

    .ch-compare-bar__copy span {
        font-size: 11px;
    }

    .ch-compare-bar__open {
        min-width: 102px;
        padding: 8px 12px;
    }

    .ch-compare-toast {
        top: 72px;
        right: 16px;
        left: 16px;
        max-width: none;
        text-align: center;
    }

    .ch-compare-page {
        padding: 28px 0 54px;
    }

    .ch-compare-heading {
        display: block;
        margin-bottom: 18px;
    }

    .ch-compare-heading h1 {
        font-size: 27px;
    }

    .ch-compare-heading p {
        font-size: 13px;
    }

    .ch-compare-back {
        width: 100%;
        margin-top: 15px;
    }

    .ch-compare-table {
        min-width: 690px;
    }

    .ch-compare-label {
        width: 145px;
        min-width: 145px;
        padding: 13px 11px !important;
        box-shadow: 4px 0 10px rgba(0, 0, 0, .04);
    }

    .ch-compare-property-head {
        width: 220px;
        min-width: 220px;
    }

    .ch-compare-table td {
        padding: 13px 12px;
    }

    .ch-compare-card__image {
        height: 135px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ch-compare-toggle,
    .ch-compare-bar,
    .ch-compare-toast,
    .ch-compare-card__image img {
        transition: none;
    }
}
