/* Asistente de búsqueda inteligente — estilos
 * Aislado en el namespace .asistente-ia-* para no chocar con estilos del proyecto.
 */

/* --- Botón inyectado bajo el buscador ----------------------------------- */
.asistente-ia-cta-wrapper {
    width: 100%;
    margin: 12px 0 20px 0;
    text-align: center;
}

.asistente-ia-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.asistente-ia-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.asistente-ia-cta strong { font-weight: 700; }
.asistente-ia-cta-icono { font-size: 16px; }

/* --- Overlay (fondo oscuro) --------------------------------------------- */
.asistente-ia-overlay {
    position: fixed;
    inset: 0;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    /* z-index máximo seguro: el panel del buscador del proyecto usa valores muy altos */
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: asistenteIaFadeIn 0.18s ease;
}
.asistente-ia-overlay.asistente-ia-hidden {
    display: none;
}
@keyframes asistenteIaFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* --- Caja del modal ----------------------------------------------------- */
.asistente-ia-modal {
    position: relative;
    z-index: 2147483647;
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px 28px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    font-family: inherit;
    color: #1e293b;
}

.asistente-ia-cerrar {
    position: absolute;
    top: 8px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 8px;
}
.asistente-ia-cerrar:hover { color: #1e293b; }

.asistente-ia-modal h2 {
    margin: 0 0 6px 0;
    font-size: 20px;
    color: #1e293b;
}
.asistente-ia-ayuda {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #64748b;
}
.asistente-ia-ayuda em { color: #475569; }

/* --- Formulario interno ------------------------------------------------- */
.asistente-ia-form {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.asistente-ia-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
}
.asistente-ia-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.asistente-ia-buscar {
    padding: 10px 20px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}
.asistente-ia-buscar:hover { background: #4f46e5; }

/* --- Panel de filtros --------------------------------------------------- */
.asistente-ia-filtros {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.asistente-ia-filtros-fila {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.asistente-ia-filtro {
    flex: 1;
    min-width: 120px;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s ease;
}
.asistente-ia-filtro:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}
.asistente-ia-filtros-reset {
    padding: 7px 14px;
    background: #fff;
    color: #64748b;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.asistente-ia-filtros-reset:hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* --- Estado y mensajes -------------------------------------------------- */
.asistente-ia-estado {
    font-size: 13px;
    color: #475569;
    padding: 8px 0;
    min-height: 18px;
}
.asistente-ia-loading { color: #6366f1; }
.asistente-ia-error   { color: #dc2626; }
.asistente-ia-vacio   { color: #64748b; }
.asistente-ia-ok      { color: #047857; }

/* --- Resultados --------------------------------------------------------- */
.asistente-ia-lista {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}
/* Cada item es ahora un layout: [imagen] [info expansible] [botón añadir] */
.asistente-ia-item {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.asistente-ia-item:hover {
    border-color: #6366f1;
    background: #f5f3ff;
}

/* Imagen */
.asistente-ia-item-imagen {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 6px;
    overflow: hidden;
}
.asistente-ia-item-imagen img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.asistente-ia-item-imagen-vacia {
    background: #f1f5f9;
}

/* Bloque de info (nombre, ref, precio) — es el enlace al producto */
.asistente-ia-item-info {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 6px 12px;
    text-decoration: none;
    color: #1e293b;
    min-width: 0; /* permite truncar texto largo */
}
.asistente-ia-item-info:hover .asistente-ia-item-nombre {
    color: #6366f1;
}

.asistente-ia-item-nombre {
    font-weight: 500;
    font-size: 14px;
    grid-column: 1 / -1;
}
.asistente-ia-item-ref {
    font-size: 12px;
    color: #64748b;
    font-family: monospace;
}
.asistente-ia-item-precio {
    font-size: 14px;
    color: #1e293b;
    font-weight: 600;
    white-space: nowrap;
    text-align: right;
}
.asistente-ia-item-precio-oferta {
    color: #dc2626;
}
.asistente-ia-item-precio-anterior {
    font-size: 12px;
    color: #94a3b8;
    text-decoration: line-through;
    font-weight: 400;
    margin-right: 4px;
}

/* Botón Añadir */
.asistente-ia-item-add {
    padding: 8px 16px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.asistente-ia-item-add:hover {
    background: #4f46e5;
}
.asistente-ia-item-add-ok {
    background: #059669 !important;
}

/* Enlace "buscador" dentro del mensaje de cuota excedida */
.asistente-ia-link-buscador {
    color: #6366f1;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.15s ease;
}
.asistente-ia-link-buscador:hover {
    color: #4f46e5;
    text-decoration: underline;
}

/* Botón "Ver más resultados" (paginación) */
.asistente-ia-ver-mas {
    display: block;
    margin: 16px auto 0 auto;
    padding: 10px 24px;
    background: #fff;
    color: #6366f1;
    border: 1px solid #6366f1;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.asistente-ia-ver-mas:hover {
    background: #6366f1;
    color: #fff;
}
.asistente-ia-ver-mas:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 600px) {
    .asistente-ia-modal { padding: 20px 16px; }
    .asistente-ia-form { flex-direction: column; }
    .asistente-ia-item {
        grid-template-columns: 48px 1fr;
        gap: 8px;
    }
    .asistente-ia-item-imagen {
        width: 48px;
        height: 48px;
    }
    .asistente-ia-item-add {
        grid-column: 1 / -1;
        padding: 6px 12px;
    }
    .asistente-ia-item-info {
        grid-template-columns: 1fr;
        gap: 2px;
    }
    .asistente-ia-item-precio {
        text-align: left;
    }
}
