/* ================================================================
   Page « Comparer les voitures »
   ================================================================ */

.tv-compare {
    --tv-compare-label: 200px;
    --tv-compare-col: 240px;
    --tv-compare-border: #e9eceb;
    --tv-compare-best: #f3f8e6;
    padding-block: 32px 80px;
}

/* ---------- En-tête ---------- */

.tv-compare__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 32px;
    margin-bottom: 28px;
}

.tv-compare .tv-compare__title {
    margin: 0;
    color: var(--heading-color, #1c1c1c);
    font-size: clamp(1.6rem, 2.6vw, 2.25rem);
    font-weight: 800;
    line-height: 1.2;
}

.tv-compare .tv-compare__lead {
    margin: 8px 0 0;
    color: #6b7280;
    font-size: 1rem;
    line-height: 1.6;
}

.tv-compare .tv-compare__add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid rgba(152, 188, 42, .45);
    border-radius: 999px;
    color: var(--primary-color, #98bc2a);
    font-size: .95rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background-color .2s ease, color .2s ease;
}

.tv-compare .tv-compare__add:hover {
    background: var(--primary-color, #98bc2a);
    color: #fff;
}

.tv-compare__add svg {
    width: 18px;
    height: 18px;
}

/* ---------- Tableau ---------- */

.tv-compare__scroll {
    overflow-x: auto;
    border: 1px solid var(--tv-compare-border);
    border-radius: 16px;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

.tv-compare .tv-compare__table {
    width: 100%;
    min-width: calc(var(--tv-compare-label) + var(--tv-compare-cols, 2) * var(--tv-compare-col));
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.tv-compare__table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--tv-compare-border);
    border-left: 1px solid var(--tv-compare-border);
    color: #1c1c1c;
    font-size: .95rem;
    line-height: 1.4;
    text-align: center;
    vertical-align: middle;
}

.tv-compare__table tr:last-child td {
    border-bottom: 0;
}

/* Colonne des libellés : reste visible quand on fait défiler les voitures */
.tv-compare .tv-compare__label {
    position: sticky;
    left: 0;
    z-index: 2;
    width: var(--tv-compare-label);
    border-left: 0;
    background: #f8f9fa;
    color: #4b5563;
    font-size: .9rem;
    font-weight: 600;
    text-align: left;
}

.tv-compare__label > svg {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    color: var(--primary-color, #98bc2a);
    vertical-align: -3px;
}

.tv-compare__table tr:nth-child(even):not(.tv-compare__cars):not(.tv-compare__actions-row) td:not(.tv-compare__label) {
    background: #fcfcfc;
}

.tv-compare__value {
    font-weight: 600;
}

.tv-compare__value.is-empty {
    color: #b0b6b4;
    font-weight: 400;
}

/* Meilleure valeur de la ligne */
.tv-compare .tv-compare__value.is-best {
    background: var(--tv-compare-best) !important;
    color: #4d6a0e;
}

.tv-compare__value.is-best::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 8px;
    border-radius: 50%;
    background: var(--primary-color, #98bc2a);
    vertical-align: 2px;
}

/* ---------- Ligne des voitures ---------- */

.tv-compare__cars td {
    padding: 20px;
    vertical-align: top;
}

.tv-compare .tv-compare__corner {
    vertical-align: bottom;
}

.tv-compare__count {
    color: #6b7280;
    font-size: .85rem;
    font-weight: 600;
}

.tv-compare__car {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    text-align: left;
}

.tv-compare__media {
    display: block;
    overflow: hidden;
    margin-bottom: 8px;
    border-radius: 12px;
    background: #f2f4f3;
    aspect-ratio: 4 / 3;
}

.tv-compare .tv-compare__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.tv-compare__media:hover .tv-compare__img {
    transform: scale(1.04);
}

.tv-compare .tv-compare__name {
    display: -webkit-box;
    overflow: hidden;
    color: #1c1c1c;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.tv-compare .tv-compare__name:hover {
    color: var(--primary-color, #98bc2a);
}

.tv-compare .tv-compare__price {
    margin: 0;
    color: #1c1c1c;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.3;
}

.tv-compare .tv-compare__price.is-best {
    color: #5b7d12;
}

.tv-compare__badge {
    align-self: flex-start;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--tv-compare-best);
    color: #4d6a0e;
    font-size: .75rem;
    font-weight: 700;
}

/* Bouton ✕ sur la photo */
.tv-compare .tv-compare__remove {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    color: #1c1c1c;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}

.tv-compare .tv-compare__remove:hover {
    background: #1c1c1c;
    color: #fff;
}

.tv-compare__remove svg {
    width: 16px;
    height: 16px;
    color: inherit;
}

/* ---------- Boutons de contact ---------- */

.tv-compare__actions-row td {
    vertical-align: top;
}

.tv-compare__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tv-compare .tv-compare__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 700;
    line-height: 1.2;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.tv-compare__btn svg {
    width: 18px;
    height: 18px;
    color: inherit;
}

.tv-compare .tv-compare__btn--whatsapp {
    background: #25d366;
    color: #fff;
}

.tv-compare .tv-compare__btn--whatsapp:hover {
    background: #1ebe5b;
    color: #fff;
}

.tv-compare .tv-compare__btn--phone {
    border-color: var(--primary-color, #98bc2a);
    color: #4d6a0e;
}

.tv-compare .tv-compare__btn--phone:hover {
    background: var(--primary-color, #98bc2a);
    color: #fff;
}

.tv-compare .tv-compare__btn--link {
    border-color: #dfe3e2;
    color: #1c1c1c;
}

.tv-compare .tv-compare__btn--link:hover {
    border-color: #1c1c1c;
}

/* ---------- Aucune voiture ---------- */

.tv-compare__empty {
    max-width: 520px;
    margin: 0 auto;
    padding: 56px 24px;
    border: 1px dashed #d7dcda;
    border-radius: 16px;
    text-align: center;
}

.tv-compare__empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: var(--tv-compare-best);
    color: #5b7d12;
}

.tv-compare__empty-icon svg {
    width: 34px;
    height: 34px;
}

.tv-compare .tv-compare__empty-title {
    margin: 0 0 8px;
    font-size: 1.35rem;
    font-weight: 800;
}

.tv-compare .tv-compare__empty-text {
    margin: 0 0 24px;
    color: #6b7280;
}

.tv-compare__empty-text svg {
    width: 18px;
    height: 18px;
    vertical-align: -3px;
}

.tv-compare .tv-compare__cta {
    display: inline-flex;
    padding: 12px 24px;
    border-radius: 10px;
    background: #1c1c1c;
    color: #fff;
    font-weight: 700;
}

.tv-compare .tv-compare__cta:hover {
    background: var(--primary-color, #98bc2a);
    color: #fff;
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
    .tv-compare {
        --tv-compare-label: 112px;
        --tv-compare-col: 168px;
        padding-block: 20px 56px;
    }

    .tv-compare__head {
        margin-bottom: 20px;
    }

    .tv-compare .tv-compare__lead {
        font-size: .92rem;
    }

    .tv-compare__scroll {
        margin-inline: -16px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .tv-compare__table td {
        padding: 12px 10px;
        font-size: .875rem;
    }

    .tv-compare__cars td {
        padding: 12px 10px;
    }

    .tv-compare .tv-compare__label {
        font-size: .8rem;
        box-shadow: 4px 0 8px -6px rgba(0, 0, 0, .25);
    }

    /* Libellés seuls (sans icône) : lignes moins hautes */
    .tv-compare__label > svg {
        display: none;
    }

    .tv-compare .tv-compare__name {
        font-size: .92rem;
    }

    .tv-compare .tv-compare__price {
        font-size: 1rem;
    }

    .tv-compare .tv-compare__btn {
        min-height: 36px;
        padding: 6px 8px;
        font-size: .82rem;
    }

    .tv-compare .tv-compare__remove {
        width: 28px;
        height: 28px;
    }
}

/* ================================================================
   Ajout direct d'une voiture (boutons + fenêtre de recherche)
   ================================================================ */

.tv-compare .tv-compare__add,
.tv-compare .tv-compare__slot,
.tv-compare .tv-compare__cta {
    cursor: pointer;
}

.tv-compare .tv-compare__add {
    background: #fff;
}

/* Coin du tableau : case « Ajouter une voiture » */
.tv-compare .tv-compare__corner {
    vertical-align: top;
}

.tv-compare .tv-compare__slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 12px;
    padding: 20px 8px;
    border: 1.5px dashed #c9d4b0;
    border-radius: 12px;
    background: #fff;
    color: #4d6a0e;
    font-size: .85rem;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
    aspect-ratio: 4 / 3;
    transition: border-color .2s ease, background-color .2s ease;
}

.tv-compare .tv-compare__slot:hover {
    border-color: var(--primary-color, #98bc2a);
    background: var(--tv-compare-best);
}

.tv-compare__slot-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color, #98bc2a);
    color: #fff;
}

.tv-compare__slot-icon svg {
    width: 22px;
    height: 22px;
    color: inherit;
}

.tv-compare__empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.tv-compare .tv-compare__cta {
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
}

.tv-compare__cta svg {
    width: 18px;
    height: 18px;
    color: inherit;
}

.tv-compare .tv-compare__cta--ghost {
    border-color: #dfe3e2;
    background: #fff;
    color: #1c1c1c;
}

.tv-compare .tv-compare__cta--ghost:hover {
    border-color: #1c1c1c;
    background: #fff;
    color: #1c1c1c;
}

/* ---------- Fenêtre de recherche ---------- */

.tv-picker {
    /* Le thème met « * { margin: 0 } » : on rétablit le centrage natif de <dialog> */
    margin: auto;
    width: min(560px, calc(100vw - 32px));
    max-height: min(680px, calc(100vh - 48px));
    padding: 0;
    border: 0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .25);
    color: #1c1c1c;
}

.tv-picker::backdrop {
    background: rgba(15, 23, 42, .55);
}

.tv-picker__box {
    display: flex;
    flex-direction: column;
    max-height: inherit;
}

.tv-picker__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 12px;
}

.tv-picker .tv-picker__title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.3;
}

.tv-picker .tv-picker__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f2f4f3;
    color: #1c1c1c;
    cursor: pointer;
}

.tv-picker .tv-picker__close:hover {
    background: #e5e8e7;
}

.tv-picker__close svg {
    width: 18px;
    height: 18px;
    color: inherit;
}

.tv-picker .tv-picker__search {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 20px;
    padding: 0 14px;
    border: 1.5px solid #dfe3e2;
    border-radius: 12px;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.tv-picker .tv-picker__search:focus-within {
    border-color: var(--primary-color, #98bc2a);
    box-shadow: 0 0 0 3px rgba(152, 188, 42, .18);
}

.tv-picker__search > svg {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    color: #6b7280;
}

/* Les styles d'input du thème ajoutent une bordure : le cadre est porté par .tv-picker__search */
.tv-picker input.tv-picker__input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 48px;
    padding: 0;
    border: 0 !important;
    border-radius: 0;
    outline: 0 !important;
    background: transparent;
    box-shadow: none !important;
    font-size: 1rem;
}

.tv-picker .tv-picker__status {
    margin: 12px 20px 0;
    color: #6b7280;
    font-size: .85rem;
    font-weight: 600;
}

.tv-picker__list {
    flex: 1 1 auto;
    overflow-y: auto;
    margin: 8px 0 0;
    padding: 0 12px 8px;
    list-style: none;
}

.tv-picker__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-bottom: 1px solid #f0f2f1;
}

.tv-picker__item:last-child {
    border-bottom: 0;
}

.tv-picker .tv-picker__img {
    flex: 0 0 72px;
    width: 72px;
    height: 54px;
    border-radius: 8px;
    background: #f2f4f3;
    object-fit: cover;
}

.tv-picker__body {
    flex: 1 1 auto;
    min-width: 0;
}

.tv-picker .tv-picker__name {
    overflow: hidden;
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-picker .tv-picker__meta {
    overflow: hidden;
    margin: 2px 0 0;
    color: #6b7280;
    font-size: .8rem;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-picker .tv-picker__btn {
    flex: 0 0 auto;
    min-width: 92px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--primary-color, #98bc2a);
    border-radius: 999px;
    background: #fff;
    color: #4d6a0e;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}

.tv-picker .tv-picker__btn:hover:not(:disabled) {
    background: var(--primary-color, #98bc2a);
    color: #fff;
}

.tv-picker .tv-picker__btn:disabled {
    cursor: default;
}

.tv-picker__item.is-added .tv-picker__btn {
    border-color: transparent;
    background: #f3f8e6;
}

/* Comparaison complète : les voitures non ajoutées sont grisées */
.tv-picker__list.is-full .tv-picker__item:not(.is-added) {
    opacity: .45;
}

.tv-picker__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid #eef0ef;
}

.tv-picker__counter {
    color: #6b7280;
    font-size: .85rem;
    font-weight: 600;
}

.tv-picker .tv-picker__done {
    height: 42px;
    padding: 0 20px;
    border: 0;
    border-radius: 10px;
    background: #1c1c1c;
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}

.tv-picker .tv-picker__done:hover {
    background: var(--primary-color, #98bc2a);
}

@media (max-width: 767px) {
    .tv-compare .tv-compare__slot {
        padding: 12px 4px;
        font-size: .75rem;
    }

    .tv-compare__slot-icon {
        width: 32px;
        height: 32px;
    }

    /* Mobile : la fenêtre s'ouvre comme un panneau en bas de l'écran */
    .tv-picker {
        width: 100vw;
        max-width: 100vw;
        max-height: 88vh;
        margin: auto 0 0;
        border-radius: 18px 18px 0 0;
    }

    .tv-picker__foot {
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }
}
