/* ===== Compare Feature Styles ===== */

/* Make Bootstrap row stretch all columns to equal height */
#facilities-content {
    align-items: stretch;
}

#facilities-content .col-md-3,
#facilities-content .col-sm-6 {
    display: flex;
    flex-direction: column;
}

/* Card fills full column height */
.product-item-container {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 420px;
}

/* Anchor fills remaining space, pushing compare-btn-wrapper to bottom */
.product-item-container > a {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0;
    text-decoration: none;
    color: inherit;
}

/* Bottom content fills available space inside anchor so button is always at bottom */
.product-item-container > a .product-item-bottom {
    flex: 1 !important;
}

/* --- Add to Compare button on listing cards --- */
.compare-btn-wrapper {
    padding: 12px 20px 20px;
}

.btn-add-compare {
    display: block;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    text-align: center;
    border-radius: 12px;
    border: 1.5px solid #002B4E;
    background-color: transparent;
    color: #002B4E;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-add-compare:hover:not(:disabled) {
    background-color: #002B4E;
    color: #fff;
}

.btn-add-compare.active {
    background-color: #002B4E;
    color: #fff;
    border-color: #002B4E;
}

.btn-add-compare:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Button on detail page (inline, auto-width) */
.blog-header-bottom .btn-add-compare {
    width: auto;
    display: inline-block;
    padding: 6px 18px;
    font-size: 14px;
}

/* --- Selected card highlight --- */
.product-item-container.compare-selected {
    border-color: #002B4E !important;
    border-width: 2px !important;
}

/* Checkmark badge on image corner when selected */
.product-item-container.compare-selected .image::after {
    content: '';
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #002B4E;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-size: 18px 18px;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
}

/* Plus badge on image corner when compare bar is visible and NOT selected */
.compare-bar-visible .product-item-container:not(.compare-selected) .image::after {
    content: '';
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.85);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2.5' stroke-linecap='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E");
    background-size: 16px 16px;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
}

/* --- Compare Bar --- */
.compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    border-top: 1px solid #e0e8f0;
    box-shadow: 0 -4px 24px rgba(0,43,78,0.10);
    z-index: 1050;
    padding: 14px 0;
}

.compare-bar-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.compare-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.compare-bar-label {
    display: flex;
    flex-direction: column;
    min-width: 110px;
}

.compare-bar-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.2em;
    color: #0B4F6C;
    text-transform: uppercase;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.compare-bar-count {
    font-size: 13px;
    color: rgb(148, 163, 184);
    margin: 2px 0 0;
}

.compare-bar-thumbnails {
    display: flex;
    align-items: center;
}

/* Thumbnail slot — stacked/overlapping */
.compare-thumb {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: visible;
    position: relative;
    flex-shrink: 0;
    margin-left: -14px;
}

.compare-thumb:first-child {
    margin-left: 0;
}

.compare-thumb--filled {
    z-index: 2;
}

.compare-thumb:hover {
    z-index: 10;
}

.compare-thumb--filled img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.compare-thumb--empty {
    background: #f0f4f8;
    border: 2px dashed #b0bec5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Remove (×) button on thumbnail — hidden until hover */
.compare-thumb-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e53935;
    color: #fff;
    border: none;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.compare-thumb:hover .compare-thumb-remove,
.compare-thumb-remove:focus {
    opacity: 1;
}

.compare-thumb-remove:hover {
    background: #b71c1c;
}

/* Facility name tooltip on thumbnail hover */
.compare-thumb[data-name]::after {
    content: attr(data-name);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.92);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 20;
}

.compare-thumb[data-name]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(30, 30, 30, 0.92);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 20;
}

.compare-thumb[data-name]:hover::after,
.compare-thumb[data-name]:hover::before {
    opacity: 1;
}

/* Right side buttons */
.compare-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.compare-bar-reset {
    background: none;
    border: none;
    color: #515C67;
    font-size: 15px;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    padding: 6px 4px;
}

.compare-bar-reset:hover {
    color: #002B4E;
}

.compare-bar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 50px;
    background-color: #002B4E;
    color: #fff;
    border: none;
    font-size: 15px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.compare-bar-btn:hover:not(:disabled) {
    background-color: #0B4F6C;
}

.compare-bar-btn:disabled {
    background-color: #d0d8e0;
    color: #8a9aaa;
    cursor: not-allowed;
}

/* Body padding so last card isn't hidden behind bar */
body.compare-bar-visible {
    padding-bottom: 88px;
}

/* --- Compare Bar: Tablet (≤768px) --- */
@media (max-width: 768px) {
    .compare-bar {
        padding: 12px 0;
    }

    .compare-bar-inner {
        flex-wrap: wrap;
        gap: 10px;
        padding: 0 16px;
        justify-content: center;
    }

    .compare-bar-left {
        flex: 1 1 100%;
        gap: 12px;
        justify-content: center;
    }

    .compare-bar-label {
        min-width: auto;
        align-items: center;
    }

    .compare-bar-right {
        flex: 1 1 100%;
        gap: 10px;
        justify-content: center;
    }

    .compare-bar-btn {
        flex: 1;
        justify-content: center;
        padding: 12px 16px;
        font-size: 14px;
    }

    body.compare-bar-visible {
        padding-bottom: 120px;
    }
}

/* --- Compare Bar: Mobile (≤480px) --- */
@media (max-width: 480px) {
    .compare-bar-inner {
        padding: 0 12px;
    }

    .compare-thumb {
        width: 44px;
        height: 44px;
        margin-left: -12px;
    }

    .compare-thumb--filled img {
        width: 44px;
        height: 44px;
    }

    .compare-thumb--empty {
        width: 44px;
        height: 44px;
    }

    .compare-bar-reset {
        font-size: 14px;
        white-space: nowrap;
    }

    .compare-bar-btn {
        font-size: 13px;
        padding: 11px 12px;
    }

    body.compare-bar-visible {
        padding-bottom: 130px;
    }
}

/* ===== Compare Modal (Phase 3) ===== */

body.compare-modal-open {
    overflow: hidden;
}

.compare-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.compare-modal-backdrop {
    display: none;
}

.compare-modal-content {
    position: relative;
    z-index: 2;
    background: #f5f7fa;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.compare-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 28px;
    background: #fff;
    border-bottom: 1px solid #e8edf2;
    flex-shrink: 0;
}

.compare-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #515C67;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.compare-modal-close:hover {
    background: #f0f4f8;
    color: #002B4E;
}

.compare-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: #002B4E;
    margin: 0;
}

/* Scrollable body */
.compare-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 24px;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
}

.compare-modal-body .compare-table-wrapper {
    width: 100%;
    flex: 1;
}

/* Table wrapper — horizontal scroll on mobile, shrinks to content */
.compare-table-wrapper {
    background: #fff;
    border-radius: 20px;
    overflow-x: auto;
    box-shadow: 0 2px 16px rgba(0,43,78,0.06);
    display: inline-block;
    width: 100%;
}

/* Table — no vertical column dividers, only horizontal row dividers */
.compare-table {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    min-width: 500px;
    table-layout: fixed;
}

/* Label column (left) — fixed narrow width, does not shrink or grow */
.compare-label-cell {
    width: 140px;
    min-width: 140px;
    white-space: nowrap;
    padding: 20px 24px 20px 24px;
    vertical-align: middle;
}

/* Facility columns share remaining space equally */
.compare-facility-cell:last-child {
    padding-right: 24px;
}

.compare-spec-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #8a9aaa;
    text-transform: uppercase;
}

.compare-row-label {
    font-size: 14px;
    font-weight: 600;
    color: #515C67;
}

/* Facility data cells — no left border */
.compare-facility-cell {
    padding: 20px 20px;
    vertical-align: top;
    min-width: 180px;
    max-width: 260px;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Only horizontal dividers between rows (not image/name rows, they flow together) */
.compare-row--rating .compare-label-cell,
.compare-row--rating .compare-facility-cell,
.compare-row--services .compare-label-cell,
.compare-row--services .compare-facility-cell,
.compare-row--insurance .compare-label-cell,
.compare-row--insurance .compare-facility-cell,
.compare-row--rehab-type .compare-label-cell,
.compare-row--rehab-type .compare-facility-cell,
.compare-row--accreditation .compare-label-cell,
.compare-row--accreditation .compare-facility-cell,
.compare-row--beds .compare-label-cell,
.compare-row--beds .compare-facility-cell,
.compare-row--cost .compare-label-cell,
.compare-row--cost .compare-facility-cell,
.compare-row--actions .compare-label-cell,
.compare-row--actions .compare-facility-cell {
    border-top: 1px solid #f0f4f8;
}

.compare-row--image .compare-facility-cell {
    text-align: center;
}

/* Image row */
.compare-facility-img-wrap {
    position: relative;
    display: flex;
    justify-content: center;
}

.compare-facility-img-wrap img {
    width: 100%;
    max-width: 200px;
    height: 140px;
    border-radius: 18px;
    object-fit: cover;
    display: block;
    background: #e8edf2;
}

/* Remove column button (top-right of image) */
.compare-remove-col {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #dde3ea;
    color: #515C67;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    transition: background 0.15s, color 0.15s;
}

.compare-remove-col:hover {
    background: #e53935;
    color: #fff;
    border-color: #e53935;
}

.compare-remove-col--disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.compare-remove-col--disabled:hover {
    background: #fff;
    color: #515C67;
    border-color: #dde3ea;
}

/* Name + location */
.compare-facility-name {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #002B4E;
    text-decoration: none;
    line-height: 1.3;
    margin-bottom: 6px;
}

.compare-facility-name:hover {
    color: #0B4F6C;
}

.compare-facility-location {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #0B9E8A;
    text-transform: uppercase;
}

.compare-facility-location svg {
    stroke: #0B9E8A;
    flex-shrink: 0;
}

/* Stars */
.compare-stars {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 3px;
}

.compare-star {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.compare-star.filled polygon {
    fill: #F5A623;
    stroke: #F5A623;
}

.compare-star.half polygon {
    stroke: #F5A623;
}

.compare-star.empty polygon {
    fill: #e0e0e0;
    stroke: #e0e0e0;
}

.compare-rating-num {
    font-size: 16px;
    font-weight: 700;
    color: #002B4E;
    margin-left: 6px;
}

/* Service tags */
.compare-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.compare-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid #b0bec5;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #515C67;
    text-transform: uppercase;
    white-space: normal;
    word-break: break-word;
}

.compare-plain-text {
    font-size: 14px;
    color: #1a1a1a;
    word-break: break-word;
}

/* Insurance */
.compare-insurance {
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.compare-check {
    color: #0B9E8A;
    font-weight: 700;
    font-size: 15px;
}

/* No data placeholder */
.compare-no-data {
    color: #b0bec5;
    font-size: 14px;
}

.compare-row-value {
    font-size: 14px;
    color: #333;
}

/* Full Details button */
.compare-full-details-btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 12px;
    background-color: #002B4E !important;
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    text-decoration: none !important;
    text-align: center;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.compare-full-details-btn:hover {
    background-color: #0B4F6C !important;
    color: #fff !important;
}

/* ===== Phase 4: Animations & UX Polish ===== */

/* Compare bar — slide up on show */
.compare-bar {
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.compare-bar.compare-bar--visible {
    transform: translateY(0);
}

/* Add-to-Compare button — smooth state transitions */
.btn-add-compare {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.btn-add-compare:active:not(:disabled) {
    transform: scale(0.97);
}

/* Card selected highlight — smooth border transition */
.product-item-container {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Thumbnail slide-in animation */
@keyframes compare-thumb-in {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}

.compare-thumb--filled {
    animation: compare-thumb-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Modal — fade + slide up on open */
.compare-modal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.compare-modal.compare-modal--open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ===== Phase 4: Modal Responsive ===== */

/* Small desktop / large tablet: 769px–885px */
@media (max-width: 885px) and (min-width: 769px) {
    .compare-modal-body {
        padding: 16px;
        overflow-x: auto;
    }

    .compare-label-cell {
        width: 110px;
        min-width: 110px;
        padding: 14px 10px 14px 14px;
        font-size: 12px;
    }

    .compare-facility-cell {
        min-width: 160px;
        width: 160px;
        padding: 14px 12px;
    }

    .compare-table {
        min-width: unset;
        table-layout: fixed;
    }

    .compare-table-wrapper {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .compare-star {
        width: 15px;
        height: 15px;
    }

    .compare-rating-num {
        font-size: 14px;
    }

    .compare-facility-name {
        font-size: 14px;
    }

    .compare-full-details-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* Tablet: reduce padding, shrink images */
@media (max-width: 768px) {
    .compare-modal-header {
        padding: 16px 20px;
    }

    .compare-modal-title {
        font-size: 18px;
    }

    .compare-modal-body {
        padding: 16px;
        overflow-x: auto;
    }

    .compare-label-cell {
        width: 100px;
        min-width: 100px;
        padding: 14px 10px 14px 12px;
        font-size: 12px;
    }

    .compare-facility-cell {
        padding: 14px 12px;
        min-width: 160px;
        width: 160px;
    }

    .compare-table {
        min-width: unset;
        table-layout: fixed;
    }

    .compare-table-wrapper {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .compare-facility-img-wrap img {
        max-width: 140px;
        width: 100%;
        height: 100px;
    }

    .compare-facility-name {
        font-size: 14px;
    }

    .compare-full-details-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Mobile: hide label column, stack is handled by horizontal scroll */
@media (max-width: 480px) {
    .compare-modal-body {
        padding: 12px;
        min-width: 0;
    }

    .compare-label-cell {
        width: 100px;
        min-width: 100px;
        padding: 12px 8px 12px 12px;
        font-size: 11px;
    }

    .compare-row-label {
        font-size: 12px;
    }

    .compare-facility-cell {
        padding: 14px 12px;
        min-width: 160px;
        width: 160px;
    }

    .compare-table {
        min-width: unset;
        table-layout: fixed;
    }

    .compare-facility-img-wrap img {
        max-width: 140px;
        width: 100%;
        height: 100px;
        border-radius: 12px;
    }

    .compare-table-wrapper {
        border-radius: 14px;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .compare-tag {
        font-size: 10px;
        padding: 3px 8px;
    }

    .compare-full-details-btn {
        padding: 9px 12px;
        font-size: 12px;
    }
}
