/* ═══════════════════════════════════════════════════════
   MGest Enhanced UX CSS — v5.5.1
   Features: mini-carousel, grid/list, chips, animations,
   quick view, blur, QR, PDF print, ARIA
   ═══════════════════════════════════════════════════════ */

/* ───────────────────────────────────
   1. MINI-CAROUSEL ON CARD HOVER
   ─────────────────────────────────── */
.mgest-card-img, .mgest-mp-img {
    position: relative;
    overflow: hidden;
}
.mgest-mini-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity .3s;
    z-index: 3;
    pointer-events: none;
}
.mgest-card-img:hover .mgest-mini-dots,
.mgest-mp-img:hover .mgest-mini-dots {
    opacity: 1;
}
.mgest-mini-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,.5);
    transition: background .2s;
}
.mgest-mini-dot.active {
    background: #fff;
    box-shadow: 0 0 4px rgba(0,0,0,.4);
}
.mgest-mini-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,.45);
    color: #fff;
    font-size: 18px;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity .3s;
    z-index: 3;
    padding: 0;
}
.mgest-mini-arrow:hover {
    background: rgba(0,0,0,.7);
}
.mgest-mini-arrow-l { left: 6px; }
.mgest-mini-arrow-r { right: 6px; }
.mgest-card-img:hover .mgest-mini-arrow,
.mgest-mp-img:hover .mgest-mini-arrow {
    opacity: 1;
}

/* ───────────────────────────────────
   2. GRID / LIST TOGGLE
   ─────────────────────────────────── */
.mgest-view-toggle {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--mgest-border, #dee2e6);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
}
.mgest-view-toggle button {
    border: none;
    background: var(--mgest-card-bg, #fff);
    color: var(--mgest-text, #333);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: background .2s, color .2s;
}
.mgest-view-toggle button.active {
    background: var(--mgest-accent, #2563eb);
    color: #fff;
}
.mgest-view-toggle button:hover:not(.active) {
    background: var(--mgest-accent, #2563eb);
    opacity: .15;
}

/* List view mode */
[data-view-mode="list"] .mgest-card-grid {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
}
[data-view-mode="list"] .mgest-card-grid .mgest-card {
    display: flex !important;
    flex-direction: row;
    max-width: 100%;
    height: auto;
}
[data-view-mode="list"] .mgest-card-grid .mgest-card-img {
    width: 220px;
    min-width: 220px;
    max-height: 160px;
}
[data-view-mode="list"] .mgest-card-grid .mgest-card-img img {
    height: 100%;
    object-fit: cover;
}
[data-view-mode="list"] .mgest-card-grid .mgest-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 16px;
}
[data-view-mode="list"] .mgest-card-grid .mgest-card-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

/* Responsive list: revert to card on small screens */
@media (max-width: 576px) {
    [data-view-mode="list"] .mgest-card-grid .mgest-card {
        flex-direction: column;
    }
    [data-view-mode="list"] .mgest-card-grid .mgest-card-img {
        width: 100%;
        min-width: 0;
        max-height: 200px;
    }
}

/* ───────────────────────────────────
   3. ACTIVE FILTER CHIPS
   ─────────────────────────────────── */
#mgestActiveChips {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 14px;
    padding: 0;
}
.mgest-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--mgest-accent, #2563eb);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
}
.mgest-chip b {
    font-weight: 600;
}
.mgest-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.3);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    transition: background .2s;
}
.mgest-chip-x:hover {
    background: rgba(255,255,255,.55);
}
.mgest-chip-clear {
    background: var(--mgest-text-secondary, #6b7280);
    cursor: pointer;
    border: none;
    font-weight: 600;
}
.mgest-chip-clear:hover {
    opacity: .85;
}

/* ───────────────────────────────────
   5. QUICK VIEW MODAL
   ─────────────────────────────────── */
.mgest-qv-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: mgestFadeIn .25s ease;
}
@keyframes mgestFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.mgest-qv-content {
    position: relative;
    background: var(--mgest-card-bg, #fff);
    color: var(--mgest-text, #333);
    border-radius: 12px;
    max-width: 880px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    animation: mgestSlideUp .3s ease;
}
@keyframes mgestSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.mgest-qv-close {
    position: absolute;
    top: 10px;
    right: 14px;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,.5);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mgest-qv-close:hover {
    background: rgba(0,0,0,.75);
}
.mgest-qv-gallery {
    flex: 0 0 50%;
    min-width: 280px;
}
.mgest-qv-img {
    width: 100%;
    height: 320px;
    object-fit: cover;
    border-radius: 12px 0 0 0;
}
.mgest-qv-thumbs {
    display: flex;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
}
.mgest-qv-thumb {
    width: 56px;
    height: 42px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: .6;
    transition: opacity .2s;
    border: 2px solid transparent;
}
.mgest-qv-thumb.active,
.mgest-qv-thumb:hover {
    opacity: 1;
    border-color: var(--mgest-accent, #2563eb);
}
.mgest-qv-info {
    flex: 1;
    padding: 24px;
    min-width: 240px;
}
.mgest-qv-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 8px;
}
.mgest-qv-price {
    font-size: 24px;
    font-weight: 800;
    color: var(--mgest-accent, #2563eb);
    margin-bottom: 16px;
}
.mgest-qv-specs {
    list-style: none;
    padding: 0;
    margin: 0 0 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    font-size: 14px;
}
.mgest-qv-specs li b {
    color: var(--mgest-text-secondary, #6b7280);
    font-weight: 500;
}
.mgest-qv-desc {
    font-size: 14px;
    color: var(--mgest-text-secondary, #6b7280);
    line-height: 1.5;
    margin: 0 0 14px;
}
.mgest-qv-detail-btn {
    display: inline-block;
    padding: 10px 24px;
    background: var(--mgest-accent, #2563eb);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    border-radius: 8px;
    text-decoration: none;
    transition: opacity .2s;
}
.mgest-qv-detail-btn:hover {
    opacity: .85;
    color: #fff;
    text-decoration: none;
}
@media (max-width: 640px) {
    .mgest-qv-gallery { flex: 0 0 100%; }
    .mgest-qv-img { border-radius: 12px 12px 0 0; height: 240px; }
}

/* Quick View button in card */
.mgest-quickview-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--mgest-accent, #2563eb);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: transform .2s, background .2s;
    padding: 0;
}
.mgest-quickview-btn:hover {
    transform: scale(1.1);
    background: var(--mgest-accent-hover, #1d4ed8);
}

/* ───────────────────────────────────
   6. FILTER COUNTS BADGE
   ─────────────────────────────────── */
.mgest-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--mgest-accent, #2563eb);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
    vertical-align: middle;
}

/* ───────────────────────────────────
   8. BLUR PLACEHOLDER transition
   ─────────────────────────────────── */
#wp_mgest_risultati img[loading="lazy"] {
    transition: filter .5s ease;
}

/* ───────────────────────────────────
   9. PRINT STYLES
   ─────────────────────────────────── */
@media print {
    body * { visibility: hidden; }
    .com-mgest-vehicle-detail,
    .com-mgest-vehicle-detail * {
        visibility: visible !important;
    }
    .com-mgest-vehicle-detail {
        position: absolute;
        left: 0; top: 0;
        width: 100%;
    }
    .mgest-theme-toggle-wrap,
    .mgest-cta-bar,
    .mgest-contact-section,
    .mgest-share-bar,
    .mgest-qr-section,
    .mgest-print-btn {
        display: none !important;
    }
    .mgest-detail-gallery img {
        max-height: 300px;
        object-fit: contain;
    }
}

/* Print button */
.mgest-print-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--mgest-border, #dee2e6);
    border-radius: 6px;
    background: var(--mgest-card-bg, #fff);
    color: var(--mgest-text, #333);
    cursor: pointer;
    font-size: 14px;
    transition: background .2s;
}
.mgest-print-btn:hover {
    background: var(--mgest-accent, #2563eb);
    color: #fff;
    border-color: var(--mgest-accent, #2563eb);
}

/* ───────────────────────────────────
   10. QR CODE
   ─────────────────────────────────── */
.mgest-qr-section {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    margin-top: 16px;
    background: var(--mgest-card-bg, #fff);
    border: 1px solid var(--mgest-border, #dee2e6);
    border-radius: 8px;
}
.mgest-qr-section img {
    border-radius: 6px;
}
.mgest-qr-label {
    font-size: 13px;
    color: var(--mgest-text-secondary, #6b7280);
    line-height: 1.4;
}

/* ───────────────────────────────────
   11. VISUALLY HIDDEN (accessibility)
   ─────────────────────────────────── */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ───────────────────────────────────
   DARK MODE overrides for new features
   ─────────────────────────────────── */
[data-mgest-theme="dark"] .mgest-chip {
    background: var(--mgest-accent, #3b82f6);
}
[data-mgest-theme="dark"] .mgest-qv-content {
    background: var(--mgest-card-bg, #1e293b);
    color: var(--mgest-text, #e2e8f0);
}
[data-mgest-theme="dark"] .mgest-qv-close {
    background: rgba(255,255,255,.2);
}
[data-mgest-theme="dark"] .mgest-print-btn {
    border-color: var(--mgest-border, #334155);
    background: var(--mgest-card-bg, #1e293b);
    color: var(--mgest-text, #e2e8f0);
}
[data-mgest-theme="dark"] .mgest-qr-section {
    background: var(--mgest-card-bg, #1e293b);
    border-color: var(--mgest-border, #334155);
}
