/* ── MondoAuto Plugin – scoped styles ──────────────────────── */
/* Tutte le regole sono racchiuse in .mondoauto-wrap per evitare
   conflitti con il tema WordPress attivo.                       */

.mondoauto-wrap {
    --bg-1: #1a3a5c;
    --bg-2: #1e4a70;
    --surface: #f8fbff;
    --text: #0e2342;
    --muted: #5c6f8b;
    --line: #cdd7e8;
    --primary: #0f3f78;
    --primary-soft: #dfeeff;
    --ok: #1f7a58;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* Theme-agnostic full-bleed mode (exact alignment refined via JS). */
.mondoauto-wrap.ma-full-bleed {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

@supports (width: 100dvw) {
    .mondoauto-wrap.ma-full-bleed {
        width: 100dvw;
        max-width: 100dvw;
        margin-left: calc(50% - 50dvw);
        margin-right: calc(50% - 50dvw);
    }
}

.mondoauto-wrap *,
.mondoauto-wrap *::before,
.mondoauto-wrap *::after {
    box-sizing: border-box;
}

.mondoauto-wrap .page-wrap {
    padding: 22px clamp(12px, 2.5vw, 34px);
}

.mondoauto-wrap .container-fluid.page-wrap {
    padding-left: clamp(20px, 4vw, 60px);
    padding-right: clamp(20px, 4vw, 60px);
}

.mondoauto-wrap .error {
    border: 1px solid #ffc9c9;
    background: #fff2f2;
    color: #8f1d1d;
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 22px;
    line-height: 1.5;
}

/* ── Barra filtri ───────────────────────────────────────────── */

.mondoauto-wrap .filters-bar {
    background: rgba(248, 251, 255, 0.94);
    border: 1px solid rgba(205, 215, 232, 0.9);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 28px;
    box-shadow: 0 8px 20px rgba(7, 26, 54, 0.12);
}

.mondoauto-wrap .filters-form {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.mondoauto-wrap .filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
}

.mondoauto-wrap .filters-divider {
    width: 1px;
    align-self: stretch;
    min-height: 46px;
    background: linear-gradient(to bottom, rgba(23, 70, 127, 0.1), rgba(23, 70, 127, 0.55), rgba(23, 70, 127, 0.1));
    margin: 0 10px;
}

.mondoauto-wrap .filter-field label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: #365784;
}

.mondoauto-wrap .filter-field select {
    width: 165px;
    border: 1px solid #bcd0ec;
    border-radius: 10px;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 0.9rem;
    color: #0e2342;
    background: #fff;
}

.mondoauto-wrap #filterMake,
.mondoauto-wrap #filterModel {
    width: 190px;
}

.mondoauto-wrap #filterCondition {
    width: 120px;
}

.mondoauto-wrap #filterSortBy {
    width: 180px;
}

.mondoauto-wrap #filterSortDir {
    width: 145px;
}

.mondoauto-wrap .filter-field select:focus {
    outline: none;
    border-color: #2a5f9f;
    box-shadow: 0 0 0 3px rgba(42, 95, 159, 0.18);
}

.mondoauto-wrap .filter-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    align-items: end;
    margin-left: auto;
}

.mondoauto-wrap .btn-filter-reset {
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    border: 2px solid #17467f;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #17467f;
}

.mondoauto-wrap .btn-filter-reset:hover {
    background: #eef4ff;
}

/* ── Card veicolo ───────────────────────────────────────────── */

.mondoauto-wrap .car {
    height: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(7, 26, 54, 0.14);
    animation: ma-fadeUp 0.55s ease both;
}

.mondoauto-wrap .car img {
    width: 100%;
    height: 210px;
    object-fit: cover;
    background: #eaf2ff;
}

.mondoauto-wrap .gallery-main {
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    cursor: zoom-in;
    line-height: 0;
    width: 100%;
}

.mondoauto-wrap .car-body {
    padding: 16px;
    display: grid;
    gap: 12px;
}

.mondoauto-wrap .title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.35;
}

.mondoauto-wrap .badge {
    display: inline-block;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid #bfd9ff;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    width: fit-content;
}

.mondoauto-wrap .badge-km0 {
    background: #d4edda;
    color: #155724;
    border-color: #b8dfc6;
}

.mondoauto-wrap .badge-usato {
    background: #fff3cd;
    color: #856404;
    border-color: #ffc107;
}

.mondoauto-wrap .car-image-wrap {
    position: relative;
}

.mondoauto-wrap .photo-count {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border-radius: 20px;
    padding: 3px 9px;
    font-size: 0.78rem;
    font-weight: 600;
    pointer-events: none;
    line-height: 1.4;
}

.mondoauto-wrap .car-no-photo {
    height: 210px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #eaf2ff;
    color: #8aaad4;
    gap: 6px;
}

.mondoauto-wrap .car-no-photo svg {
    width: 48px;
    height: 48px;
    opacity: 0.6;
}

.mondoauto-wrap .car-no-photo span {
    font-size: 0.85rem;
}

.mondoauto-wrap .results-count {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    margin-bottom: 12px;
    padding: 0 2px;
}

.mondoauto-wrap #filterFuel,
.mondoauto-wrap #filterPriceMin,
.mondoauto-wrap #filterPriceMax {
    min-width: 130px;
}

.mondoauto-wrap .price-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.mondoauto-wrap .price {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #7a0000, #b00010);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    padding: 7px 12px;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(100, 0, 0, 0.4);
    flex: 1 1 50%;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
}

.mondoauto-wrap .btn-details {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #fff;
    color: var(--primary);
    border: 2px solid var(--primary);
    font-size: 0.88rem;
    font-weight: 700;
    padding: 7px 18px;
    flex: 1 1 50%;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s;
}

.mondoauto-wrap .btn-details:hover {
    background: var(--primary);
    color: #fff;
}

.mondoauto-wrap .details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 0.94rem;
    color: var(--muted);
}

.mondoauto-wrap .details strong {
    color: var(--text);
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.mondoauto-wrap .details-value {
    color: #2f4669;
}

.mondoauto-wrap .empty {
    background: #f4f8ff;
    border: 1px dashed #9eb8dd;
    border-radius: 14px;
    padding: 20px;
    color: #365784;
}

/* ── Lightbox ───────────────────────────────────────────────── */

.mondoauto-wrap .lightbox {
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 29, 0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 24px;
}

.mondoauto-wrap .lightbox.open {
    display: flex;
}

.mondoauto-wrap .lightbox-figure {
    margin: 0;
    max-width: min(1100px, 100%);
    width: 100%;
    text-align: center;
}

.mondoauto-wrap .lightbox-image {
    width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 12px;
    background: #111;
}

.mondoauto-wrap .lightbox-caption {
    color: #fff;
    margin-top: 10px;
    font-size: 0.92rem;
}

.mondoauto-wrap .lightbox-thumbs {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 2px;
}

.mondoauto-wrap .lightbox-thumb {
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    padding: 0;
    background: transparent;
    cursor: pointer;
    line-height: 0;
    opacity: 0.8;
    flex: 0 0 auto;
}

.mondoauto-wrap .lightbox-thumb.active {
    border-color: #fff;
    opacity: 1;
}

.mondoauto-wrap .lightbox-thumb img {
    width: 70px;
    height: 52px;
    object-fit: cover;
    border-radius: 7px;
}

.mondoauto-wrap .lightbox-btn {
    position: absolute;
    border: 0;
    background: rgba(14, 63, 120, 0.7);
    color: #fff;
    font-size: 1.5rem;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.mondoauto-wrap .lightbox-btn:hover {
    background: rgba(23, 93, 174, 0.85);
}

.mondoauto-wrap .lightbox-close {
    top: 16px;
    right: 16px;
}

.mondoauto-wrap .lightbox-prev {
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.mondoauto-wrap .lightbox-next {
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

/* ── Paginazione ────────────────────────────────────────────── */

.mondoauto-wrap .pagination .page-link {
    color: #17467f;
    border-color: #9fbde7;
}

.mondoauto-wrap .pagination .page-item.active .page-link {
    background-color: #17467f;
    border-color: #17467f;
    color: #fff;
}

/* ── Modal dettagli veicolo ─────────────────────────────────── */

.mondoauto-wrap .car-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 20, 38, 0.82);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 99998;
    padding: 40px 16px;
    overflow-y: auto;
}

.mondoauto-wrap .car-modal-overlay.open {
    display: flex;
}

.mondoauto-wrap .car-modal-dialog {
    width: 100%;
    max-width: 760px;
    margin: auto;
}

.mondoauto-wrap .car-modal-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.mondoauto-wrap .car-modal-header {
    background: var(--primary);
    padding: 1.2rem 1.4rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.mondoauto-wrap .car-modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.3;
    margin: 0;
}

.mondoauto-wrap .car-modal-version {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.72);
    margin-top: 3px;
}

.mondoauto-wrap .car-modal-close {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s;
}

.mondoauto-wrap .car-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mondoauto-wrap .car-modal-body {
    padding: 1.4rem;
    background: var(--surface);
}

.mondoauto-wrap .cm-section {
    margin-bottom: 1.4rem;
}

.mondoauto-wrap .cm-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.35rem;
    margin-bottom: 0.65rem;
}

.mondoauto-wrap .cm-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 1rem;
    margin: 0;
}

.mondoauto-wrap .cm-label {
    font-size: 0.8rem;
    color: var(--muted);
    padding: 0.22rem 0;
    white-space: nowrap;
}

.mondoauto-wrap .cm-value {
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 600;
    padding: 0.22rem 0;
    border-bottom: 1px solid rgba(205, 215, 232, 0.4);
}

.mondoauto-wrap .cm-price {
    display: inline-block;
    background: linear-gradient(135deg, #7a0000, #b00010);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    padding: 3px 13px;
    border-radius: 8px;
}

.mondoauto-wrap .cm-options {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mondoauto-wrap .cm-options li {
    font-size: 0.78rem;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid #bfd9ff;
    border-radius: 999px;
    padding: 3px 11px;
}

.mondoauto-wrap .cm-notes {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.65;
    margin: 0;
    white-space: pre-line;
}

/* ── Animazione card ────────────────────────────────────────── */

@keyframes ma-fadeUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 720px) {
    .mondoauto-wrap .filters-form {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .mondoauto-wrap .filters-divider {
        width: 100%;
        min-height: 1px;
        height: 1px;
        background: rgba(23, 70, 127, 0.2);
        margin: 4px 0;
    }

    .mondoauto-wrap .filter-actions {
        justify-content: flex-start;
        margin-left: 0;
    }

    .mondoauto-wrap .filter-field,
    .mondoauto-wrap .filter-field select,
    .mondoauto-wrap #filterMake,
    .mondoauto-wrap #filterModel,
    .mondoauto-wrap #filterCondition,
    .mondoauto-wrap #filterSortBy,
    .mondoauto-wrap #filterSortDir {
        width: 100%;
    }

    .mondoauto-wrap .page-wrap {
        padding: 14px 16px;
    }

    .mondoauto-wrap .car img {
        height: 190px;
    }

    .mondoauto-wrap .lightbox {
        padding: 12px;
    }

    .mondoauto-wrap .lightbox-btn {
        width: 38px;
        height: 38px;
    }
}
