/* AI Voice Search — Estilos del widget v1.3 */

/* ── Contenedor principal ── */
#aivs-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 99998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Botón del micrófono ── */
#aivs-mic-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
    transition: transform 0.15s ease, background 0.15s ease;
}

#aivs-mic-btn:hover { transform: scale(1.08); background: #1d4ed8; }
#aivs-mic-btn:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }

#aivs-mic-btn.recording {
    background: #dc2626;
    animation: aivs-pulse 1.2s ease-out infinite;
}

@keyframes aivs-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6); }
    70%  { box-shadow: 0 0 0 14px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ── Pop-up ── */
#aivs-popup[hidden] { display: none !important; }

#aivs-popup {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 340px;
    max-height: 520px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 99999;
    animation: aivs-slide-up 0.2s ease;
}

@keyframes aivs-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Móvil: el popup rompe fuera del widget y ocupa toda la pantalla ── */
@media (max-width: 600px) {
    #aivs-widget {
        right: 16px;
        bottom: 90px;
    }
    #aivs-popup {
        position: fixed !important;
        left: 8px !important;
        right: 8px !important;
        bottom: 170px !important;
        width: auto !important;
        max-width: none !important;
        max-height: 58vh !important;
    }
}

/* ── Cabecera ── */
#aivs-popup-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

#aivs-status {
    flex: 1;
    margin: 0;
    font-size: 14px;
    color: #374151;
    line-height: 1.5;
}

#aivs-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 4px;
    flex-shrink: 0;
    transition: color 0.1s;
}
#aivs-close-btn:hover { color: #374151; }

/* ── Transcripción ── */
#aivs-transcript-box[hidden] { display: none !important; }
#aivs-transcript-box {
    padding: 10px 16px;
    background: #f0f9ff;
    border-bottom: 1px solid #e0f2fe;
    font-size: 13px;
    color: #0369a1;
    flex-shrink: 0;
}
#aivs-transcript-box span { color: #64748b; }

/* ── Resultados ── */
#aivs-results {
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}
#aivs-results::-webkit-scrollbar        { width: 4px; }
#aivs-results::-webkit-scrollbar-track  { background: transparent; }
#aivs-results::-webkit-scrollbar-thumb  { background: #e2e8f0; border-radius: 2px; }

/* ── Tarjeta de producto ── */
.aivs-product-card {
    display: flex;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.aivs-product-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.09); border-color: #cbd5e1; }

.aivs-product-card img {
    width: 68px;
    height: 68px;
    object-fit: cover;
    border-radius: 7px;
    flex-shrink: 0;
    background: #e2e8f0;
}

.aivs-product-info { display: flex; flex-direction: column; gap: 3px; overflow: hidden; min-width: 0; }

.aivs-product-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aivs-product-desc {
    font-size: 11px;
    color: #64748b;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.aivs-product-price { font-size: 13px; font-weight: 700; color: #2563eb; }

.aivs-badge-sale {
    display: inline-block;
    background: #fef2f2;
    color: #dc2626;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid #fecaca;
    width: fit-content;
}

.aivs-no-results { text-align: center; color: #64748b; font-size: 14px; padding: 20px 0; margin: 0; }

/* ── Badge sin stock ── */
.aivs-badge-out {
    display: inline-block;
    background: #f1f5f9;
    color: #64748b;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    width: fit-content;
}

/* Tarjeta de producto agotado: imagen en gris */
.aivs-product-card.out-of-stock img {
    filter: grayscale(60%);
    opacity: 0.8;
}

.aivs-product-card.out-of-stock .aivs-product-name {
    color: #64748b;
}

/* ── Botón "ver últimos resultados" ── */
#aivs-review-btn {
    position: absolute;
    bottom: 68px;  /* Justo encima del mic */
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    color: #2563eb;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    transition: transform 0.15s, box-shadow 0.15s;
}
#aivs-review-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0,0,0,0.22);
}
#aivs-review-btn[hidden] { display: none !important; }

/* ── Tooltip "Buscá por voz" ── */
#aivs-hint {
    position: absolute;
    right: 68px;   /* A la izquierda del botón mic */
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e293b;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 22px;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    pointer-events: none;

    /* Aparece con fade, se queda 2.5s y desaparece para siempre */
    animation: aivs-hint-show 4s ease forwards;
}

@keyframes aivs-hint-show {
    0%   { opacity: 0; transform: translateX(8px); }
    15%  { opacity: 1; transform: translateX(0); }
    70%  { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(8px); pointer-events: none; display: none; }
}

/* Triángulo apuntando a la derecha (hacia el botón) */
#aivs-hint::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    border: 7px solid transparent;
    border-left-color: #1e293b;
    border-right: 0;
}
