/* ============================================================
 * TP V4 — AI Search Bar (hero "Pesquisa livre" mode)
 * Port adaptado do padrão tp-storefront — gradient animado, sparkles, glow,
 * resultado inline com specs técnicas reveladas em sequência.
 * ============================================================ */

.tp4-ai-bar {
    position: relative;
    margin: 0 auto;
    padding: 26px 28px;
    background:
        radial-gradient(680px 350px at 18% -10%, rgba(168, 85, 247, 0.65), transparent 60%),
        radial-gradient(580px 280px at 88% 110%, rgba(56, 189, 248, 0.55), transparent 60%),
        radial-gradient(420px 240px at 50% 50%, rgba(34, 211, 238, 0.22), transparent 70%),
        radial-gradient(300px 200px at 0% 100%, rgba(244, 114, 182, 0.30), transparent 75%),
        radial-gradient(280px 180px at 100% 0%, rgba(250, 204, 21, 0.20), transparent 75%),
        linear-gradient(135deg, #050823 0%, #0e1640 45%, #0a0e2e 100%);
    border: 1px solid rgba(167, 139, 250, 0.45);
    border-radius: 24px;
    overflow: hidden;
    box-shadow:
        0 40px 80px -20px rgba(124, 58, 237, 0.50),
        0 0 0 1px rgba(255, 255, 255, 0.07) inset,
        0 0 80px rgba(56, 189, 248, 0.25);
    isolation: isolate;
    animation: tp4AiPulse 6s ease-in-out infinite;
}

/* Aurora — orbs flutuantes coloridos com blur */
.tp4-ai-bar__aurora {
    position: absolute; inset: 0;
    pointer-events: none; z-index: 0;
    filter: blur(50px);
    opacity: 0.85;
    mix-blend-mode: screen;
}
.tp4-ai-bar__aurora::before,
.tp4-ai-bar__aurora::after {
    content: ''; position: absolute;
    width: 280px; height: 280px;
    border-radius: 50%;
}
.tp4-ai-bar__aurora::before {
    background: radial-gradient(circle, rgba(168, 85, 247, 0.9), transparent 70%);
    top: -100px; left: -50px;
    animation: tp4AiOrb1 14s ease-in-out infinite;
}
.tp4-ai-bar__aurora::after {
    background: radial-gradient(circle, rgba(56, 189, 248, 0.85), transparent 70%);
    bottom: -100px; right: -50px;
    animation: tp4AiOrb2 16s ease-in-out infinite;
}
@keyframes tp4AiOrb1 {
    0%   { transform: translate(0,0) scale(1); }
    33%  { transform: translate(180px, 80px) scale(1.15); }
    66%  { transform: translate(60px, 200px) scale(0.9); }
    100% { transform: translate(0,0) scale(1); }
}
@keyframes tp4AiOrb2 {
    0%   { transform: translate(0,0) scale(1); }
    33%  { transform: translate(-140px, -60px) scale(1.2); }
    66%  { transform: translate(-220px, 30px) scale(0.85); }
    100% { transform: translate(0,0) scale(1); }
}

/* Beam horizontal cruzando o bar (slow sweep) */
.tp4-ai-bar::after {
    content: ""; position: absolute;
    top: 0; bottom: 0; left: -30%; width: 30%;
    background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.08) 45%, rgba(167, 139, 250, 0.18) 50%, rgba(255, 255, 255, 0.08) 55%, transparent 100%);
    transform: skewX(-12deg);
    animation: tp4AiBeam 7s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}
@keyframes tp4AiBeam {
    0%   { left: -35%; opacity: 0; }
    18%  { opacity: 1; }
    50%  { left: 100%; opacity: 1; }
    65%  { opacity: 0; }
    100% { left: 100%; opacity: 0; }
}
@keyframes tp4AiPulse {
    0%, 100% { box-shadow: 0 30px 60px -20px rgba(37, 99, 235, 0.40), 0 0 0 1px rgba(255, 255, 255, 0.05) inset, 0 0 50px rgba(124, 58, 237, 0.15); }
    50%      { box-shadow: 0 30px 60px -20px rgba(124, 58, 237, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 0 80px rgba(37, 99, 235, 0.30); }
}
.tp4-ai-bar::before {
    content: ""; position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    background: conic-gradient(from 0deg,
        rgba(37, 99, 235, 0) 0%,
        rgba(124, 58, 237, 0.7) 25%,
        rgba(34, 211, 238, 0.7) 50%,
        rgba(168, 85, 247, 0.7) 75%,
        rgba(37, 99, 235, 0) 100%);
    border-radius: 20px;
    z-index: -1;
    filter: blur(8px);
    opacity: 0.55;
    animation: tp4AiSpin 10s linear infinite;
}
@keyframes tp4AiSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.tp4-ai-bar__glow {
    position: absolute; top: 50%; left: 0%;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.45) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: tp4AiGlowMove 8s ease-in-out infinite;
    z-index: 0;
}
@keyframes tp4AiGlowMove {
    0%   { left: 0%;   top: 0%; }
    50%  { left: 100%; top: 100%; }
    100% { left: 0%;   top: 0%; }
}
.tp4-ai-bar__sparkles { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.tp4-ai-bar__sparkles span {
    position: absolute; width: 4px; height: 4px;
    background: #fff; border-radius: 50%;
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.8);
    opacity: 0;
    animation: tp4AiSparkle 3s ease-in-out infinite;
}
.tp4-ai-bar__sparkles span:nth-child(1) { top: 18%; left: 8%;  animation-delay: 0s; }
.tp4-ai-bar__sparkles span:nth-child(2) { top: 65%; left: 22%; animation-delay: 0.5s; }
.tp4-ai-bar__sparkles span:nth-child(3) { top: 28%; left: 48%; animation-delay: 1.0s; }
.tp4-ai-bar__sparkles span:nth-child(4) { top: 72%; left: 68%; animation-delay: 1.5s; }
.tp4-ai-bar__sparkles span:nth-child(5) { top: 12%; left: 86%; animation-delay: 2.0s; }
.tp4-ai-bar__sparkles span:nth-child(6) { top: 88%; left: 92%; animation-delay: 2.5s; }
@keyframes tp4AiSparkle {
    0%, 100% { opacity: 0; transform: scale(0.4); }
    50%      { opacity: 1; transform: scale(1.4); }
}

.tp4-ai-bar__inner { position: relative; z-index: 2; }

.tp4-ai-bar__chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px 5px 10px;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    color: #fff;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.06em;
    border-radius: 999px;
    text-transform: uppercase;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.10) inset;
    max-width: calc(100% - 140px);  /* reserva espaço para powered chip à direita (desktop) */
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tp4-ai-bar__chip svg { color: #fde68a; }
@media (max-width: 640px) {
    .tp4-ai-bar__chip { max-width: 100%; }
}

.tp4-ai-bar__fields {
    display: flex; align-items: stretch; gap: 8px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(147, 197, 253, 0.22);
    border-radius: 14px;
    padding: 6px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.tp4-ai-bar__input,
input.tp4-ai-bar__input {
    flex: 1 1 auto; min-width: 0;
    appearance: none; -webkit-appearance: none;
    border: 0 !important; outline: none !important;
    background: transparent !important;
    padding: 12px 14px;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    caret-color: #fde68a;
    font: inherit; font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
}
.tp4-ai-bar__input::placeholder,
input.tp4-ai-bar__input::placeholder { color: rgba(226, 232, 240, 0.65); opacity: 1; }
.tp4-ai-bar__input::-webkit-input-placeholder { color: rgba(226, 232, 240, 0.65); }
.tp4-ai-bar__input::-moz-placeholder { color: rgba(226, 232, 240, 0.65); opacity: 1; }

.tp4-ai-bar__btn {
    appearance: none; border: none; cursor: pointer;
    width: 44px; height: 44px; padding: 0;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    position: relative;
    transition: background 180ms ease-out, transform 180ms ease-out;
}
.tp4-ai-bar__btn:hover { background: rgba(255, 255, 255, 0.16); }
.tp4-ai-bar__btn:active { transform: scale(0.95); }
.tp4-ai-bar__btn--photo input { display: none; }

.tp4-ai-bar__mic-pulse {
    position: absolute; inset: -3px; border-radius: 12px;
    background: rgba(239, 68, 68, 0.35);
    opacity: 0; transform: scale(0.85);
    pointer-events: none;
}
.tp4-ai-bar__btn--mic i.fa,
.tp4-ai-bar__btn--mic .fa-microphone {
    color: #fff;
    font-size: 20px;
    line-height: 1;
    display: inline-block;
}
.tp4-ai-bar__btn--mic.is-listening { background: rgba(239, 68, 68, 0.85); }
.tp4-ai-bar__btn--mic.is-listening .tp4-ai-bar__mic-pulse {
    animation: tp4AiMicPulse 1.4s ease-out infinite;
}
@keyframes tp4AiMicPulse {
    0%   { opacity: 0.7; transform: scale(0.85); }
    100% { opacity: 0;   transform: scale(1.5); }
}

.tp4-ai-bar__go {
    appearance: none; border: none; cursor: pointer;
    padding: 0 22px; min-width: 130px;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    color: #fff; font-weight: 800;
    font-size: 14.5px; letter-spacing: 0.02em;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: filter 180ms ease-out, transform 180ms ease-out;
}
.tp4-ai-bar__go:hover { filter: brightness(1.12); }
.tp4-ai-bar__go:active { transform: scale(0.97); }
.tp4-ai-bar__go-spinner svg { animation: tp4AiSpin 1s linear infinite; }

.tp4-ai-bar__hint {
    margin-top: 10px;
    font-size: 12.5px; color: rgba(226, 232, 240, 0.65);
    text-align: center; letter-spacing: 0.02em;
}

.tp4-ai-bar__status {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(37, 99, 235, 0.18);
    border: 1px solid rgba(147, 197, 253, 0.3);
    color: #c7d2fe;
    border-radius: 10px;
    font-size: 13px;
    text-align: center;
    animation: tp4AiFadeIn 200ms ease-out;
}
@keyframes tp4AiFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ── Powered by greenparts ─────────────────────────────────── *
 * Desktop: top-right corner chip absolute.
 * Mobile (≤640): NO absolute — vai para o fim do inner (rodapé do bar)
 * centrado, para não sobrepor o chip "A peça certa em segundos".
 */
.tp4-ai-bar__powered {
    position: absolute; top: 14px; right: 16px; z-index: 3;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.30);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    text-decoration: none; color: #cbd5e1;
    opacity: 0.92;
    transition: opacity 180ms ease-out, transform 180ms ease-out;
}
.tp4-ai-bar__powered:hover { opacity: 1; transform: translateY(-1px); }
.tp4-ai-bar__powered-prefix {
    font-size: 9.5px; color: #94a3b8;
    text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
    white-space: nowrap;
}
.tp4-ai-bar__powered-logo {
    height: 18px; width: auto; display: block;
    object-fit: contain;
}

@media (max-width: 640px) {
    .tp4-ai-bar { padding: 18px 14px 56px; /* reserva espaço inferior para powered */ }
    .tp4-ai-bar__powered {
        position: absolute; top: auto; bottom: 12px; left: 50%; right: auto;
        transform: translateX(-50%);
        padding: 5px 10px;
    }
    .tp4-ai-bar__powered:hover { transform: translateX(-50%) translateY(-1px); }
    .tp4-ai-bar__powered-logo { height: 14px; }
    .tp4-ai-bar__powered-prefix { font-size: 8.5px; }
}

/* ── Result panel container ─────────────────────────────────── */
.tp4-ai-bar__result {
    position: relative;
    margin-top: 14px;
    text-align: left;
    animation: tp4AiResultIn 350ms cubic-bezier(.16,1,.3,1);
}
@keyframes tp4AiResultIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
.tp4-ai-bar__result-close {
    position: absolute; top: -2px; right: 0; z-index: 4;
    appearance: none; border: none; background: rgba(255, 255, 255, 0.06);
    color: #94a3b8; cursor: pointer;
    width: 28px; height: 28px; border-radius: 50%;
    font-size: 18px; line-height: 1; padding: 0;
    transition: background 180ms ease-out, color 180ms ease-out;
}
.tp4-ai-bar__result-close:hover { background: rgba(239, 68, 68, 0.20); color: #fca5a5; }

/* ── Overview card (resumo IA — estilo Google AI Overview) ─── */
.tp4-ai-overview {
    position: relative;
    padding: 18px 18px 16px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.16), rgba(34, 211, 238, 0.10) 60%, rgba(37, 99, 235, 0.14));
    border: 1px solid rgba(167, 139, 250, 0.40);
    border-radius: 14px;
    color: #e2e8f0;
    box-shadow:
        0 12px 30px -10px rgba(124, 58, 237, 0.40),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    overflow: hidden;
}
.tp4-ai-overview::before {
    content: ""; position: absolute; inset: -1px;
    background: linear-gradient(90deg, rgba(124, 58, 237, 0) 0%, rgba(124, 58, 237, 0.5) 50%, rgba(34, 211, 238, 0) 100%);
    transform: translateX(-100%);
    animation: tp4AiSheen 2.4s ease-in-out 0.2s 1;
    pointer-events: none;
    mix-blend-mode: overlay;
}
@keyframes tp4AiSheen { 0% { transform: translateX(-100%); } 100% { transform: translateX(120%); } }

.tp4-ai-overview__head {
    display: flex; align-items: center; gap: 8px;
    font-size: 11.5px; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: #a5f3fc; margin-bottom: 8px;
}
.tp4-ai-overview__head svg { color: #fde68a; }

.tp4-ai-overview__title {
    margin: 0 0 8px;
    font-size: 18px; font-weight: 800;
    color: #f8fafc; line-height: 1.25;
    font-family: 'Manrope', 'Inter', sans-serif;
    letter-spacing: -0.01em;
    animation: tp4AiFadeUp 0.4s ease-out 0.1s both;
}
.tp4-ai-overview__title:empty { display: none; }

.tp4-ai-overview__body {
    font-size: 14px; line-height: 1.55;
    color: #cbd5e1;
    animation: tp4AiFadeUp 0.4s ease-out 0.18s both;
}
.tp4-ai-overview__body p { margin: 0 0 8px; }
.tp4-ai-overview__body p:last-child { margin: 0; }

.tp4-ai-overview__bullets {
    list-style: none; padding: 0; margin: 10px 0 0;
    animation: tp4AiFadeUp 0.4s ease-out 0.22s both;
}
.tp4-ai-overview__bullets li {
    position: relative; padding: 4px 0 4px 22px;
    font-size: 13.5px; color: #d1d5db; line-height: 1.5;
}
.tp4-ai-overview__bullets li::before {
    content: ""; position: absolute; left: 6px; top: 12px;
    width: 6px; height: 6px; border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa, #67e8f9);
}

/* Chips com filtros extraídos pela IA (marca, modelo, ano…) */
.tp4-ai-overview__chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 12px;
    animation: tp4AiFadeUp 0.4s ease-out 0.28s both;
}
.tp4-ai-overview__chips:empty { display: none; }
.tp4-ai-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    background: rgba(124, 58, 237, 0.25);
    border: 1px solid rgba(167, 139, 250, 0.40);
    color: #e9d5ff;
    font-size: 11.5px; font-weight: 700;
    border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.tp4-ai-chip__key { color: #c7d2fe; text-transform: uppercase; font-size: 10px; opacity: 0.85; }
.tp4-ai-chip__val { color: #fff; }

/* Skeleton loader inside overview body */
.tp4-ai-overview__skeleton { display: flex; flex-direction: column; gap: 8px; }
.tp4-ai-overview__skeleton span {
    height: 12px; border-radius: 4px;
    background: linear-gradient(90deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.14) 50%, rgba(255,255,255,0.06) 100%);
    background-size: 200% 100%;
    animation: tp4AiShimmer 1.4s ease-in-out infinite;
}
.tp4-ai-overview__skeleton span:nth-child(1) { width: 92%; }
.tp4-ai-overview__skeleton span:nth-child(2) { width: 76%; }
.tp4-ai-overview__skeleton span:nth-child(3) { width: 60%; }
@keyframes tp4AiShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes tp4AiFadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Suggestions grid (anúncios sugeridos) ──────────────────── */
.tp4-ai-suggestions {
    margin-top: 14px;
    padding: 14px 16px 16px;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(147, 197, 253, 0.28);
    border-radius: 14px;
    color: #e2e8f0;
    animation: tp4AiFadeUp 0.45s ease-out 0.30s both;
}
.tp4-ai-suggestions__head {
    display: flex; align-items: center; gap: 6px;
    font-size: 11.5px; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: #a5f3fc; margin-bottom: 12px;
}
.tp4-ai-suggestions__head svg { color: #fde68a; }
.tp4-ai-suggestions__count {
    margin-left: auto;
    color: #94a3b8; font-size: 10.5px; font-weight: 700;
}

.tp4-ai-suggestions__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}
.tp4-ai-sugg-item {
    display: flex; flex-direction: column; gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(147, 197, 253, 0.18);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none; color: #e2e8f0;
    transition: transform 200ms ease-out, border-color 200ms ease-out, box-shadow 200ms ease-out;
}
.tp4-ai-sugg-item:hover {
    transform: translateY(-3px);
    border-color: rgba(167, 139, 250, 0.60);
    box-shadow: 0 12px 28px -8px rgba(124, 58, 237, 0.40);
    color: #fff;
}
.tp4-ai-sugg-item__thumb {
    aspect-ratio: 4 / 3;
    background: rgba(255, 255, 255, 0.04);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.tp4-ai-sugg-item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tp4-ai-sugg-item__thumb-fb { color: rgba(255, 255, 255, 0.25); }
.tp4-ai-sugg-item__meta {
    display: flex; flex-direction: column; gap: 3px;
    padding: 0 10px 10px;
}
.tp4-ai-sugg-item__name {
    margin: 0; font-size: 12.5px; font-weight: 700; line-height: 1.3;
    color: #f1f5f9;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tp4-ai-sugg-item__veh {
    font-size: 10.5px; color: #94a3b8;
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.tp4-ai-sugg-item__price {
    font-size: 13px; font-weight: 800;
    color: #fbbf24;
    margin-top: 2px;
}
.tp4-ai-sugg-empty {
    grid-column: 1 / -1;
    text-align: center; padding: 20px;
    color: #94a3b8; font-style: italic; font-size: 13px;
}
.tp4-ai-sugg-loading {
    grid-column: 1 / -1;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 20px; color: #94a3b8; font-size: 13px;
}
.tp4-ai-sugg-loading::before {
    content: ""; width: 14px; height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: #a78bfa; border-radius: 50%;
    animation: tp4AiSpin 0.9s linear infinite;
}

.tp4-ai-bar__cta-wrap { margin-top: 14px; display: flex; justify-content: flex-end; }

/* ── Mode switching — show only the active form/bar ─────────── */
.tp4-hero__searchbox[data-mode="text"]  .tp4-ai-bar { display: block; }
.tp4-hero__searchbox[data-mode="text"]  .tp4-hero__search.is-mode-ref { display: none; }
.tp4-hero__searchbox[data-mode="ref"]   .tp4-ai-bar { display: none; }
.tp4-hero__searchbox[data-mode="ref"]   .tp4-hero__search.is-mode-ref { display: flex; }
.tp4-hero__searchbox[data-mode="photo"] .tp4-ai-bar { display: block; }
.tp4-hero__searchbox[data-mode="photo"] .tp4-hero__search.is-mode-ref { display: none; }

@media (max-width: 640px) {
    .tp4-ai-bar { padding: 16px 14px; }
    .tp4-ai-bar__fields { padding: 4px; gap: 4px; }
    .tp4-ai-bar__input { padding: 10px; font-size: 15px; }
    .tp4-ai-bar__btn { width: 40px; height: 40px; }
    .tp4-ai-bar__go { min-width: 80px; padding: 0 12px; font-size: 13px; }
    .tp4-ai-bar__go-label { display: none; }
}
