/* AI 맞춤 매물 추천 — 아이콘 + 클릭 시 패널 */
.site-ai-sidebar {
    position: fixed;
    top: 50%;
    right: 0;
    z-index: 9800;
    display: flex;
    align-items: center;
    transform: translateY(-50%) translateX(calc(100% + 12px));
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    /* 닫힌 패널 높이로 aside hit-area가 커져 매물 상세 갤러리 다음 버튼을 가로채지 않도록 */
    pointer-events: none;
}

.site-ai-sidebar.is-ready {
    transform: translateY(-50%) translateX(0);
}

.site-ai-sidebar[hidden] {
    display: none !important;
}

/* ── 런처 (닫힘: AI 추천 차량 라벨 / 썸네일 있을 때: 차량 사진) ── */
.site-ai-sidebar__launcher {
    position: relative;
    flex-shrink: 0;
    display: block;
    width: 78px;
    min-height: 96px;
    padding: 0;
    border: none;
    border-radius: 16px 0 0 16px;
    overflow: hidden;
    pointer-events: auto;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(165deg, #0ea5e9 0%, #2563eb 48%, #1d4ed8 100%);
    box-shadow:
        -6px 0 28px rgba(37, 99, 235, 0.42),
        -2px 4px 14px rgba(15, 23, 42, 0.18),
        inset 0 0 0 1px rgba(255, 255, 255, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease, width 0.25s ease, min-height 0.25s ease;
    animation: site-ai-launcher-glow 2.8s ease-in-out infinite;
}

@keyframes site-ai-launcher-glow {
    0%, 100% {
        box-shadow:
            -6px 0 28px rgba(37, 99, 235, 0.42),
            -2px 4px 14px rgba(15, 23, 42, 0.18),
            inset 0 0 0 1px rgba(255, 255, 255, 0.22);
    }
    50% {
        box-shadow:
            -8px 0 34px rgba(14, 165, 233, 0.55),
            -2px 6px 18px rgba(15, 23, 42, 0.22),
            inset 0 0 0 1px rgba(255, 255, 255, 0.34);
    }
}

.site-ai-sidebar__launcher:hover {
    transform: translateX(-3px);
    animation: none;
    box-shadow:
        -10px 0 36px rgba(37, 99, 235, 0.5),
        -3px 6px 16px rgba(15, 23, 42, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.site-ai-sidebar__launcher:hover .site-ai-sidebar__launcher-img {
    transform: scale(1.06);
}

.site-ai-sidebar.is-open .site-ai-sidebar__launcher {
    border-radius: 0;
    width: 52px;
    min-height: 72px;
    animation: none;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.12);
}

.site-ai-sidebar__launcher.has-thumb {
    width: 82px;
    min-height: 108px;
    border-radius: 18px 0 0 18px;
    box-shadow:
        -8px 0 32px rgba(37, 99, 235, 0.45),
        -2px 4px 12px rgba(15, 23, 42, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.site-ai-sidebar.is-open .site-ai-sidebar__launcher.has-thumb {
    width: 52px;
    min-height: 72px;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

.site-ai-sidebar__launcher-media {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.site-ai-sidebar__launcher-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 42%;
    transform: scale(1.02);
    transition: transform 0.35s ease, opacity 0.3s ease;
    opacity: 0;
}

.site-ai-sidebar__launcher.has-thumb .site-ai-sidebar__launcher-img {
    opacity: 1;
}

.site-ai-sidebar__launcher-img[hidden] {
    display: none !important;
}

.site-ai-sidebar__launcher-overlay {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.site-ai-sidebar__launcher.has-thumb .site-ai-sidebar__launcher-overlay {
    opacity: 1;
    background:
        linear-gradient(180deg,
            rgba(15, 23, 42, 0.04) 0%,
            rgba(15, 23, 42, 0.1) 38%,
            rgba(29, 78, 216, 0.45) 68%,
            rgba(15, 23, 42, 0.92) 100%);
}

.site-ai-sidebar__launcher-content {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px 10px;
    pointer-events: none;
}

.site-ai-sidebar__launcher.has-thumb .site-ai-sidebar__launcher-content {
    justify-content: flex-end;
    gap: 4px;
    padding: 0 8px 10px;
}

.site-ai-sidebar__launcher-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    line-height: 0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.site-ai-sidebar__launcher.has-thumb .site-ai-sidebar__launcher-icon {
    display: none;
}

.site-ai-sidebar__launcher-spark {
    display: block;
    font-size: 12px;
    line-height: 1;
    color: #fde68a;
    text-shadow: 0 1px 8px rgba(251, 191, 36, 0.65);
    animation: site-ai-spark 2.4s ease-in-out infinite;
}

.site-ai-sidebar__launcher.has-thumb .site-ai-sidebar__launcher-spark {
    display: block;
    font-size: 10px;
}

@keyframes site-ai-spark {
    0%, 100% { opacity: 0.75; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.12); }
}

.site-ai-sidebar__launcher-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    text-align: center;
}

.site-ai-sidebar__launcher-text-main,
.site-ai-sidebar__launcher-text-sub {
    display: block;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
}

.site-ai-sidebar__launcher-text-main {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.site-ai-sidebar__launcher-text-sub {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    opacity: 0.95;
    white-space: nowrap;
}

.site-ai-sidebar__launcher.has-thumb .site-ai-sidebar__launcher-text {
    width: 100%;
    padding: 4px 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.site-ai-sidebar__launcher.has-thumb .site-ai-sidebar__launcher-text-main {
    font-size: 12px;
}

.site-ai-sidebar__launcher.has-thumb .site-ai-sidebar__launcher-text-sub {
    font-size: 9px;
}

.site-ai-sidebar.is-open .site-ai-sidebar__launcher-text {
    display: none;
}

.site-ai-sidebar.is-open .site-ai-sidebar__launcher-icon {
    display: flex;
    width: 30px;
    height: 30px;
}

.site-ai-sidebar.is-open .site-ai-sidebar__launcher-spark {
    display: none;
}

.site-ai-sidebar__launcher-count {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 3;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #fbbf24;
    color: #1e293b;
    font-size: 10px;
    font-weight: 800;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.site-ai-sidebar__launcher.has-thumb .site-ai-sidebar__launcher-count {
    top: 7px;
    right: 7px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    line-height: 18px;
    background: linear-gradient(180deg, #fcd34d 0%, #f59e0b 100%);
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.55);
}

.site-ai-sidebar__launcher-count[hidden] {
    display: none;
}

/* ── 패널 (클릭 시 펼침) ── */
.site-ai-sidebar__panel {
    width: 0;
    max-width: 0;
    height: 0;
    max-height: 0;
    min-width: 0;
    opacity: 0;
    overflow: hidden;
    flex-shrink: 0;
    pointer-events: none;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(47, 111, 214, 0.18);
    border-right: none;
    border-radius: 14px 0 0 14px;
    box-shadow:
        -8px 0 32px rgba(37, 99, 235, 0.12),
        -2px 4px 12px rgba(15, 23, 42, 0.08);
    transition:
        max-width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        max-height 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.22s ease;
}

.site-ai-sidebar.is-open .site-ai-sidebar__panel {
    width: 168px;
    max-width: 168px;
    height: auto;
    max-height: min(80vh, 560px);
    opacity: 1;
    pointer-events: auto;
}

.site-ai-sidebar__panel[hidden] {
    display: block !important;
}

.site-ai-sidebar__panel-inner {
    width: 168px;
}

.site-ai-sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 11px 12px 10px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%);
    color: #fff;
    position: relative;
}

.site-ai-sidebar__head::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, transparent 60%);
    pointer-events: none;
}

.site-ai-sidebar__head-text {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.site-ai-sidebar__badge {
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
}

.site-ai-sidebar__head strong {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.site-ai-sidebar__head-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.site-ai-sidebar__help,
.site-ai-sidebar__close {
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: background 0.15s ease;
}

.site-ai-sidebar__help:hover,
.site-ai-sidebar__close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.site-ai-sidebar__help {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.45);
    font-size: 11px;
    font-weight: 700;
}

.site-ai-sidebar__close {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.site-ai-sidebar__body {
    padding: 10px 10px 12px;
    max-height: min(64vh, 460px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.site-ai-sidebar__body::-webkit-scrollbar {
    width: 4px;
}

.site-ai-sidebar__body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.site-ai-sidebar__loading {
    margin: 10px 0 4px;
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
}

.site-ai-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.site-ai-item {
    opacity: 0;
    transform: translateX(6px);
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.site-ai-item.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.site-ai-item a {
    display: block;
    padding: 8px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e8eef5;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.site-ai-item a:hover {
    border-color: #bfdbfe;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.site-ai-item-thumb {
    display: block;
    width: 100%;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
    margin-bottom: 7px;
}

.site-ai-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.site-ai-item a:hover .site-ai-item-thumb img {
    transform: scale(1.04);
}

.site-ai-item-title {
    display: block;
    font-size: 12px;
    line-height: 1.4;
    color: #1e293b;
    font-weight: 600;
    letter-spacing: -0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-ai-item-meta {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-ai-item-price {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #2563eb;
}

.site-ai-sidebar__more {
    display: block;
    margin-top: 10px;
    padding: 9px 8px;
    border-radius: 8px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    border: 1px solid #bfdbfe;
}

.site-ai-sidebar__more[hidden] {
    display: none;
}

/* 운영관리자 디버그 */
.site-ai-debug {
    position: fixed;
    inset: 0;
    z-index: 9900;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
    pointer-events: auto;
}

.site-ai-debug[hidden] {
    display: none !important;
}

.site-ai-debug__panel {
    width: min(520px, 100%);
    max-height: min(80vh, 640px);
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.site-ai-debug__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #334155, #1e293b);
    color: #fff;
}

.site-ai-debug__close {
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

.site-ai-debug__body {
    padding: 16px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.55;
    color: #334155;
}

.site-ai-debug__section {
    margin-bottom: 16px;
}

.site-ai-debug__section h4 {
    margin: 0 0 8px;
    font-size: 12px;
    color: #64748b;
}

.site-ai-debug__section pre {
    margin: 0;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 12px;
    white-space: pre-wrap;
    border: 1px solid #e2e8f0;
}

.site-ai-debug__reason {
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}

.site-ai-debug__reason strong {
    display: block;
    margin-bottom: 4px;
    color: #0f172a;
}

@media (max-width: 999px) {
    .site-ai-sidebar {
        top: auto;
        bottom: 80px;
        transform: translateY(0) translateX(calc(100% + 12px));
    }

    .site-ai-sidebar.is-ready {
        transform: translateY(0) translateX(0);
    }

    .site-ai-sidebar.is-open .site-ai-sidebar__panel,
    .site-ai-sidebar__panel-inner {
        width: 152px;
        max-width: 152px;
    }

    .site-ai-sidebar__launcher {
        width: 72px;
        min-height: 88px;
    }

    .site-ai-sidebar__launcher.has-thumb {
        width: 76px;
        min-height: 96px;
    }

    .site-ai-sidebar__launcher-text-main {
        font-size: 14px;
    }

    .site-ai-sidebar__launcher-text-sub {
        font-size: 10px;
    }

    .site-ai-item-thumb {
        height: 64px;
    }
}

/* UA 모바일 레이아웃(넓은 뷰포트 포함)에서도 우측 중앙이 아닌 하단 고정 */
body.epc-layout-mobile .site-ai-sidebar {
    top: auto;
    bottom: 80px;
    transform: translateY(0) translateX(calc(100% + 12px));
}

body.epc-layout-mobile .site-ai-sidebar.is-ready {
    transform: translateY(0) translateX(0);
}

/* PC 우측 퀵메뉴(.epc-right-quick)와 AI 런처 겹침 방지 */
@media (min-width: 1000px) {
    body:has(.epc-right-quick) .epc-right-quick {
        transition: right 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    }

    body:has(.epc-right-quick):has(.site-ai-sidebar.is-ready) .epc-right-quick {
        right: 112px;
    }

    body:has(.epc-right-quick):has(.site-ai-sidebar.is-open) .epc-right-quick {
        right: 244px;
    }
}
